Move KICAD_T[] to std::initializer_list<KICAD_T>.
This commit is contained in:
parent
66b8ecb467
commit
aa2ad3b44c
|
@ -89,14 +89,14 @@ EDA_ITEM* EDA_ITEM::Clone() const
|
|||
|
||||
// see base_struct.h
|
||||
// many classes inherit this method, be careful:
|
||||
//TODO (snh): Fix this to use std::set instead of C-style vector
|
||||
INSPECT_RESULT EDA_ITEM::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||
INSPECT_RESULT EDA_ITEM::Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes )
|
||||
{
|
||||
#if 0 && defined(DEBUG)
|
||||
std::cout << GetClass().mb_str() << ' ';
|
||||
#endif
|
||||
|
||||
if( IsType( scanTypes ) )
|
||||
if( IsType( aScanTypes ) )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == inspector( this, testData ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2017 CERN
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -70,7 +70,6 @@ bool SELECTION::Contains( EDA_ITEM* aItem ) const
|
|||
/// Returns the center point of the selection area bounding box.
|
||||
VECTOR2I SELECTION::GetCenter() const
|
||||
{
|
||||
KICAD_T textTypes[] = { SCH_TEXT_T, SCH_LABEL_LOCATE_ANY_T, EOT };
|
||||
bool hasOnlyText = true;
|
||||
|
||||
// If the selection contains only texts calculate the center as the mean of all positions
|
||||
|
@ -79,7 +78,7 @@ VECTOR2I SELECTION::GetCenter() const
|
|||
|
||||
for( EDA_ITEM* item : m_items )
|
||||
{
|
||||
if( !item->IsType( textTypes ) )
|
||||
if( !item->IsType( { SCH_TEXT_T, SCH_LABEL_LOCATE_ANY_T } ) )
|
||||
{
|
||||
hasOnlyText = false;
|
||||
break;
|
||||
|
@ -101,7 +100,7 @@ VECTOR2I SELECTION::GetCenter() const
|
|||
|
||||
for( EDA_ITEM* item : m_items )
|
||||
{
|
||||
if( !item->IsType( textTypes ) )
|
||||
if( !item->IsType( { SCH_TEXT_T, SCH_LABEL_LOCATE_ANY_T } ) )
|
||||
bbox.Merge( item->GetBoundingBox() );
|
||||
}
|
||||
|
||||
|
|
|
@ -64,19 +64,13 @@ SELECTION_CONDITION SELECTION_CONDITIONS::HasType( KICAD_T aType )
|
|||
}
|
||||
|
||||
|
||||
SELECTION_CONDITION SELECTION_CONDITIONS::HasTypes( const KICAD_T aTypes[] )
|
||||
SELECTION_CONDITION SELECTION_CONDITIONS::HasTypes( const std::initializer_list<KICAD_T>& aTypes )
|
||||
{
|
||||
return std::bind( &SELECTION_CONDITIONS::hasTypesFunc, _1, aTypes );
|
||||
}
|
||||
|
||||
|
||||
SELECTION_CONDITION SELECTION_CONDITIONS::OnlyType( KICAD_T aType )
|
||||
{
|
||||
return std::bind( &SELECTION_CONDITIONS::onlyTypeFunc, _1, aType );
|
||||
}
|
||||
|
||||
|
||||
SELECTION_CONDITION SELECTION_CONDITIONS::OnlyTypes( const KICAD_T aTypes[] )
|
||||
SELECTION_CONDITION SELECTION_CONDITIONS::OnlyTypes( const std::initializer_list<KICAD_T>& aTypes )
|
||||
{
|
||||
return std::bind( &SELECTION_CONDITIONS::onlyTypesFunc, _1, aTypes );
|
||||
}
|
||||
|
@ -115,7 +109,8 @@ bool SELECTION_CONDITIONS::hasTypeFunc( const SELECTION& aSelection, KICAD_T aTy
|
|||
}
|
||||
|
||||
|
||||
bool SELECTION_CONDITIONS::hasTypesFunc( const SELECTION& aSelection, const KICAD_T aTypes[] )
|
||||
bool SELECTION_CONDITIONS::hasTypesFunc( const SELECTION& aSelection,
|
||||
const std::initializer_list<KICAD_T>& aTypes )
|
||||
{
|
||||
if( aSelection.Empty() )
|
||||
return false;
|
||||
|
@ -130,24 +125,8 @@ bool SELECTION_CONDITIONS::hasTypesFunc( const SELECTION& aSelection, const KICA
|
|||
}
|
||||
|
||||
|
||||
bool SELECTION_CONDITIONS::onlyTypeFunc( const SELECTION& aSelection, KICAD_T aType )
|
||||
{
|
||||
if( aSelection.Empty() )
|
||||
return false;
|
||||
|
||||
KICAD_T types[] = { aType, EOT };
|
||||
|
||||
for( const EDA_ITEM* item : aSelection )
|
||||
{
|
||||
if( !item->IsType( types ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool SELECTION_CONDITIONS::onlyTypesFunc( const SELECTION& aSelection, const KICAD_T aTypes[] )
|
||||
bool SELECTION_CONDITIONS::onlyTypesFunc( const SELECTION& aSelection,
|
||||
const std::initializer_list<KICAD_T>& aTypes )
|
||||
{
|
||||
if( aSelection.Empty() )
|
||||
return false;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
|
||||
* Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2022 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
|
||||
|
@ -319,8 +319,6 @@ bool SCH_EDIT_FRAME::BreakSegment( SCH_LINE* aSegment, const VECTOR2I& aPoint,
|
|||
|
||||
bool SCH_EDIT_FRAME::BreakSegments( const VECTOR2I& aPoint, SCH_SCREEN* aScreen )
|
||||
{
|
||||
static const KICAD_T wiresAndBuses[] = { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T, EOT };
|
||||
|
||||
if( aScreen == nullptr )
|
||||
aScreen = GetScreen();
|
||||
|
||||
|
@ -329,7 +327,7 @@ bool SCH_EDIT_FRAME::BreakSegments( const VECTOR2I& aPoint, SCH_SCREEN* aScreen
|
|||
|
||||
for( SCH_ITEM* item : aScreen->Items().Overlapping( SCH_LINE_T, aPoint ) )
|
||||
{
|
||||
if( item->IsType( wiresAndBuses ) )
|
||||
if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } ) )
|
||||
{
|
||||
SCH_LINE* wire = static_cast<SCH_LINE*>( item );
|
||||
|
||||
|
@ -380,9 +378,9 @@ void SCH_EDIT_FRAME::DeleteJunction( SCH_ITEM* aJunction, bool aAppend )
|
|||
SCH_SCREEN* screen = GetScreen();
|
||||
PICKED_ITEMS_LIST undoList;
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
|
||||
KICAD_T wiresAndBuses[] = { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T, EOT };
|
||||
|
||||
auto remove_item = [ & ]( SCH_ITEM* aItem ) -> void
|
||||
auto remove_item =
|
||||
[&]( SCH_ITEM* aItem ) -> void
|
||||
{
|
||||
aItem->SetFlags( STRUCT_DELETED );
|
||||
undoList.PushItem( ITEM_PICKER( screen, aItem, UNDO_REDO::DELETED ) );
|
||||
|
@ -399,10 +397,13 @@ void SCH_EDIT_FRAME::DeleteJunction( SCH_ITEM* aJunction, bool aAppend )
|
|||
{
|
||||
SCH_LINE* line = static_cast<SCH_LINE*>( item );
|
||||
|
||||
if( line->IsType( wiresAndBuses ) && line->IsEndPoint( aJunction->GetPosition() )
|
||||
if( line->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } )
|
||||
&& line->IsEndPoint( aJunction->GetPosition() )
|
||||
&& !( line->GetEditFlags() & STRUCT_DELETED ) )
|
||||
{
|
||||
lines.push_back( line );
|
||||
}
|
||||
}
|
||||
|
||||
alg::for_all_pairs( lines.begin(), lines.end(),
|
||||
[&]( SCH_LINE* firstLine, SCH_LINE* secondLine )
|
||||
|
|
|
@ -461,8 +461,6 @@ DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
|
|||
DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField ),
|
||||
m_field( aField )
|
||||
{
|
||||
static KICAD_T labelTypes[] = { SCH_LABEL_LOCATE_ANY_T, EOT };
|
||||
|
||||
m_isSheetFilename = false;
|
||||
|
||||
if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
|
||||
|
@ -490,7 +488,7 @@ DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if( aField->GetParent() && aField->GetParent()->IsType( labelTypes ) )
|
||||
else if( aField->GetParent() && aField->GetParent()->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
|
||||
{
|
||||
m_fieldId = LABELUSERFIELD_V;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -39,7 +39,6 @@
|
|||
#include <tools/sch_edit_tool.h>
|
||||
#include <widgets/unit_binder.h>
|
||||
#include <widgets/font_choice.h>
|
||||
#include "font/kicad_font_name.h"
|
||||
|
||||
static bool g_modifyReferences;
|
||||
static bool g_modifyValues;
|
||||
|
@ -423,18 +422,6 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
|
|||
}
|
||||
}
|
||||
|
||||
static KICAD_T wireTypes[] = { SCH_ITEM_LOCATE_WIRE_T,
|
||||
SCH_LABEL_LOCATE_WIRE_T,
|
||||
EOT };
|
||||
static KICAD_T busTypes[] = { SCH_ITEM_LOCATE_BUS_T,
|
||||
SCH_LABEL_LOCATE_BUS_T,
|
||||
EOT };
|
||||
static KICAD_T schTextAndGraphics[] = { SCH_TEXT_T,
|
||||
SCH_TEXTBOX_T,
|
||||
SCH_ITEM_LOCATE_GRAPHIC_LINE_T,
|
||||
SCH_SHAPE_T,
|
||||
EOT };
|
||||
|
||||
if( aItem->Type() == SCH_SYMBOL_T )
|
||||
{
|
||||
SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem;
|
||||
|
@ -520,17 +507,31 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
|
|||
}
|
||||
}
|
||||
}
|
||||
else if( m_wires->GetValue() && aItem->IsType( wireTypes ) )
|
||||
else if( m_wires->GetValue() && aItem->IsType( { SCH_ITEM_LOCATE_WIRE_T,
|
||||
SCH_LABEL_LOCATE_WIRE_T } ) )
|
||||
{
|
||||
processItem( aSheetPath, aItem );
|
||||
else if( m_buses->GetValue() && aItem->IsType( busTypes ) )
|
||||
}
|
||||
else if( m_buses->GetValue() && aItem->IsType( { SCH_ITEM_LOCATE_BUS_T,
|
||||
SCH_LABEL_LOCATE_BUS_T } ) )
|
||||
{
|
||||
processItem( aSheetPath, aItem );
|
||||
}
|
||||
else if( m_globalLabels->GetValue() && aItem->Type() == SCH_GLOBAL_LABEL_T )
|
||||
{
|
||||
processItem( aSheetPath, aItem );
|
||||
}
|
||||
else if( m_hierLabels->GetValue() && aItem->Type() == SCH_HIER_LABEL_T )
|
||||
{
|
||||
processItem( aSheetPath, aItem );
|
||||
else if( m_schTextAndGraphics->GetValue() && aItem->IsType( schTextAndGraphics ) )
|
||||
}
|
||||
else if( m_schTextAndGraphics->GetValue() && aItem->IsType( { SCH_TEXT_T, SCH_TEXTBOX_T,
|
||||
SCH_ITEM_LOCATE_GRAPHIC_LINE_T,
|
||||
SCH_SHAPE_T } ) )
|
||||
{
|
||||
processItem( aSheetPath, aItem );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2019 CERN
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -36,13 +36,7 @@
|
|||
#include "sch_reference_list.h"
|
||||
|
||||
|
||||
const KICAD_T EE_COLLECTOR::AllItems[] = {
|
||||
SCH_LOCATE_ANY_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T EE_COLLECTOR::EditableItems[] = {
|
||||
const std::initializer_list<KICAD_T> EE_COLLECTOR::EditableItems = {
|
||||
SCH_SHAPE_T,
|
||||
SCH_TEXT_T,
|
||||
SCH_TEXTBOX_T,
|
||||
|
@ -62,19 +56,7 @@ const KICAD_T EE_COLLECTOR::EditableItems[] = {
|
|||
};
|
||||
|
||||
|
||||
const KICAD_T EE_COLLECTOR::SymbolsOnly[] = {
|
||||
SCH_SYMBOL_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T EE_COLLECTOR::SheetsOnly[] = {
|
||||
SCH_SHEET_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T EE_COLLECTOR::MovableItems[] =
|
||||
const std::initializer_list<KICAD_T> EE_COLLECTOR::MovableItems =
|
||||
{
|
||||
SCH_MARKER_T,
|
||||
SCH_JUNCTION_T,
|
||||
|
@ -98,20 +80,10 @@ const KICAD_T EE_COLLECTOR::MovableItems[] =
|
|||
};
|
||||
|
||||
|
||||
const KICAD_T EE_COLLECTOR::WiresOnly[] = {
|
||||
SCH_LINE_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T EE_COLLECTOR::FieldOwners[] = {
|
||||
const std::initializer_list<KICAD_T> EE_COLLECTOR::FieldOwners = {
|
||||
SCH_SYMBOL_T,
|
||||
SCH_SHEET_T,
|
||||
SCH_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
EOT
|
||||
SCH_LABEL_LOCATE_ANY_T
|
||||
};
|
||||
|
||||
|
||||
|
@ -146,8 +118,9 @@ INSPECT_RESULT EE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
|
|||
}
|
||||
|
||||
|
||||
void EE_COLLECTOR::Collect( SCH_SCREEN* aScreen, const KICAD_T aFilterList[], const VECTOR2I& aPos,
|
||||
int aUnit, int aConvert )
|
||||
void EE_COLLECTOR::Collect( SCH_SCREEN* aScreen,
|
||||
const std::initializer_list<KICAD_T>& aFilterList,
|
||||
const VECTOR2I& aPos, int aUnit, int aConvert )
|
||||
{
|
||||
Empty(); // empty the collection just in case
|
||||
|
||||
|
@ -166,7 +139,8 @@ void EE_COLLECTOR::Collect( SCH_SCREEN* aScreen, const KICAD_T aFilterList[], co
|
|||
}
|
||||
|
||||
|
||||
void EE_COLLECTOR::Collect( LIB_ITEMS_CONTAINER& aItems, const KICAD_T aFilterList[],
|
||||
void EE_COLLECTOR::Collect( LIB_ITEMS_CONTAINER& aItems,
|
||||
const std::initializer_list<KICAD_T>& aFilterList,
|
||||
const VECTOR2I& aPos, int aUnit, int aConvert )
|
||||
{
|
||||
Empty(); // empty the collection just in case
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2011-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2011-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2019 CERN
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -39,15 +39,11 @@ class SCH_SYMBOL;
|
|||
class EE_COLLECTOR : public COLLECTOR
|
||||
{
|
||||
public:
|
||||
static const KICAD_T AllItems[];
|
||||
static const KICAD_T EditableItems[];
|
||||
static const KICAD_T MovableItems[];
|
||||
static const KICAD_T SymbolsOnly[];
|
||||
static const KICAD_T SheetsOnly[];
|
||||
static const KICAD_T WiresOnly[];
|
||||
static const KICAD_T FieldOwners[];
|
||||
static const std::initializer_list<KICAD_T> EditableItems;
|
||||
static const std::initializer_list<KICAD_T> MovableItems;
|
||||
static const std::initializer_list<KICAD_T> FieldOwners;
|
||||
|
||||
EE_COLLECTOR( const KICAD_T* aScanTypes = EE_COLLECTOR::AllItems ) :
|
||||
EE_COLLECTOR( const std::initializer_list<KICAD_T>& aScanTypes = { SCH_LOCATE_ANY_T } ) :
|
||||
m_Unit( 0 ),
|
||||
m_Convert( 0 ),
|
||||
m_ShowPinElectricalTypes( false )
|
||||
|
@ -75,29 +71,27 @@ public:
|
|||
* Scan a #EDA_ITEM using this class's Inspector method which does the collection.
|
||||
*
|
||||
* @param aScreen The eeschema screen to use for scanning
|
||||
* @param aFilterList A list of #KICAD_T types with a terminating #EOT, that determines
|
||||
* what is to be collected and the priority order of the resulting
|
||||
* collection.
|
||||
* @param aFilterList A list of #KICAD_T types that determines what is to be collected and
|
||||
* the priority order of the resulting collection.
|
||||
* @param aPos are the coordinates to use in hit testing.
|
||||
* @param aUnit is the symbol unit filter (for symbol editor).
|
||||
* @param aConvert is the DeMorgan filter (for symbol editor)
|
||||
*/
|
||||
void Collect( SCH_SCREEN* aScreen, const KICAD_T aFilterList[], const VECTOR2I& aPos,
|
||||
int aUnit = 0, int aConvert = 0 );
|
||||
void Collect( SCH_SCREEN* aScreen, const std::initializer_list<KICAD_T>& aFilterList,
|
||||
const VECTOR2I& aPos, int aUnit = 0, int aConvert = 0 );
|
||||
|
||||
/**
|
||||
* Scan an #EDA_ITEM using this class's Inspector method which does the collection.
|
||||
*
|
||||
* @param aItems is a LIB_SYMBOL multivector holding the symbol items.
|
||||
* @param aFilterList is a list of #KICAD_T types with a terminating #EOT, that determines
|
||||
* what is to be collected and the priority order of the resulting
|
||||
* collection.
|
||||
* @param aFilterList is a list of #KICAD_T types that determines what is to be collected
|
||||
* and the priority order of the resulting collection.
|
||||
* @param aPos are the coordinates to use in hit testing.
|
||||
* @param aUnit is the symbol unit filter (for symbol editor).
|
||||
* @param aConvert is the DeMorgan filter (for symbol editor).
|
||||
*/
|
||||
void Collect( LIB_ITEMS_CONTAINER& aItems, const KICAD_T aFilterList[], const VECTOR2I& aPos,
|
||||
int aUnit = 0, int aConvert = 0 );
|
||||
void Collect( LIB_ITEMS_CONTAINER& aItems, const std::initializer_list<KICAD_T>& aFilterList,
|
||||
const VECTOR2I& aPos, int aUnit = 0, int aConvert = 0 );
|
||||
|
||||
/**
|
||||
* Test if the collected items form a corner of two line segments.
|
||||
|
|
|
@ -56,7 +56,6 @@ bool SCH_EDIT_FRAME::LoadProjectSettings()
|
|||
GetRenderSettings()->m_LabelSizeRatio = settings.m_LabelSizeRatio;
|
||||
GetRenderSettings()->m_TextOffsetRatio = settings.m_TextOffsetRatio;
|
||||
GetRenderSettings()->m_PinSymbolSize = settings.m_PinSymbolSize;
|
||||
GetRenderSettings()->m_JunctionSize = settings.m_JunctionSize;
|
||||
|
||||
GetRenderSettings()->SetDashLengthRatio( settings.m_DashedLineDashRatio );
|
||||
GetRenderSettings()->SetGapLengthRatio( settings.m_DashedLineGapRatio );
|
||||
|
@ -94,7 +93,6 @@ void SCH_EDIT_FRAME::ShowSchematicSetupDialog( const wxString& aInitialPage )
|
|||
GetRenderSettings()->m_LabelSizeRatio = Schematic().Settings().m_LabelSizeRatio;
|
||||
GetRenderSettings()->m_TextOffsetRatio = Schematic().Settings().m_TextOffsetRatio;
|
||||
GetRenderSettings()->m_PinSymbolSize = Schematic().Settings().m_PinSymbolSize;
|
||||
GetRenderSettings()->m_JunctionSize = Schematic().Settings().m_JunctionSize;
|
||||
|
||||
GetRenderSettings()->SetDashLengthRatio( Schematic().Settings().m_DashedLineDashRatio );
|
||||
GetRenderSettings()->SetGapLengthRatio( Schematic().Settings().m_DashedLineGapRatio );
|
||||
|
|
|
@ -1237,12 +1237,12 @@ LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
|
|||
|
||||
|
||||
INSPECT_RESULT LIB_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData,
|
||||
const KICAD_T aFilterTypes[] )
|
||||
const std::initializer_list<KICAD_T>& aScanTypes )
|
||||
{
|
||||
// The part itself is never inspected, only its children
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.IsType( aFilterTypes ) )
|
||||
if( item.IsType( aScanTypes ) )
|
||||
{
|
||||
if( aInspector( &item, aTestData ) == INSPECT_RESULT::QUIT )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2022 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
|
||||
|
@ -502,7 +502,8 @@ public:
|
|||
LIB_ITEMS_CONTAINER& GetDrawItems() { return m_drawings; }
|
||||
const LIB_ITEMS_CONTAINER& GetDrawItems() const { return m_drawings; }
|
||||
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes ) override;
|
||||
|
||||
/**
|
||||
* Set the units per symbol count.
|
||||
|
|
|
@ -106,11 +106,6 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindo
|
|||
}
|
||||
|
||||
|
||||
SCH_BASE_FRAME::~SCH_BASE_FRAME()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SCH_SCREEN* SCH_BASE_FRAME::GetScreen() const
|
||||
{
|
||||
return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen();
|
||||
|
@ -187,10 +182,7 @@ void SCH_BASE_FRAME::UpdateStatusBar()
|
|||
MessageTextFromValue( GetUserUnits(), hypot( d.x, d.y ), false ) );
|
||||
SetStatusText( line, 3 );
|
||||
|
||||
// refresh grid display
|
||||
DisplayGridMsg();
|
||||
|
||||
// refresh units display
|
||||
DisplayUnitsMsg();
|
||||
}
|
||||
|
||||
|
@ -255,17 +247,6 @@ void SCH_BASE_FRAME::RedrawScreen( const VECTOR2I& aCenterPoint, bool aWarpPoint
|
|||
}
|
||||
|
||||
|
||||
void SCH_BASE_FRAME::CenterScreen( const VECTOR2I& aCenterPoint, bool aWarpPointer )
|
||||
{
|
||||
GetCanvas()->GetView()->SetCenter( aCenterPoint );
|
||||
|
||||
if( aWarpPointer )
|
||||
GetCanvas()->GetViewControls()->WarpMouseCursor( aCenterPoint, true );
|
||||
|
||||
GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void SCH_BASE_FRAME::HardRedraw()
|
||||
{
|
||||
if( GetCanvas() && GetCanvas()->GetView() )
|
||||
|
@ -342,15 +323,7 @@ void SCH_BASE_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpda
|
|||
GetCanvas()->GetView()->Update( aItem );
|
||||
|
||||
// Some children are drawn from their parents. Mark them for re-paint.
|
||||
static KICAD_T parentTypes[] = { SCH_SYMBOL_T,
|
||||
SCH_SHEET_T,
|
||||
SCH_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
EOT };
|
||||
|
||||
if( parent && parent->IsType( parentTypes ) )
|
||||
if( parent && parent->IsType( { SCH_SYMBOL_T, SCH_SHEET_T, SCH_LABEL_LOCATE_ANY_T } ) )
|
||||
GetCanvas()->GetView()->Update( parent, KIGFX::REPAINT );
|
||||
}
|
||||
|
||||
|
|
|
@ -92,13 +92,12 @@ LIB_SYMBOL* SchGetLibSymbol( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable,
|
|||
class SCH_BASE_FRAME : public EDA_DRAW_FRAME
|
||||
{
|
||||
public:
|
||||
SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
||||
FRAME_T aWindowType,
|
||||
const wxString& aTitle,
|
||||
const wxPoint& aPosition, const wxSize& aSize,
|
||||
long aStyle, const wxString & aFrameName );
|
||||
SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindowType, const wxString& aTitle,
|
||||
const wxPoint& aPosition, const wxSize& aSize, long aStyle,
|
||||
const wxString & aFrameName );
|
||||
|
||||
virtual ~SCH_BASE_FRAME();
|
||||
virtual ~SCH_BASE_FRAME()
|
||||
{ }
|
||||
|
||||
void createCanvas();
|
||||
|
||||
|
@ -198,8 +197,6 @@ public:
|
|||
|
||||
virtual void RedrawScreen( const VECTOR2I& aCenterPoint, bool aWarpPointer );
|
||||
|
||||
virtual void CenterScreen( const VECTOR2I& aCenterPoint, bool aWarpPointer );
|
||||
|
||||
void HardRedraw() override;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1353,8 +1353,7 @@ void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_SCREEN* aScreen, SCH_ITEM*
|
|||
|
||||
if( connected )
|
||||
{
|
||||
static KICAD_T autoRotatableLabelTypes[] = { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T };
|
||||
if( aItem->IsType( autoRotatableLabelTypes ) )
|
||||
if( aItem->IsType( { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T } ) )
|
||||
{
|
||||
auto label = static_cast<SCH_LABEL_BASE*>( aItem );
|
||||
if( label->AutoRotateOnPlacement() )
|
||||
|
|
|
@ -90,11 +90,6 @@ SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) :
|
|||
}
|
||||
|
||||
|
||||
SCH_FIELD::~SCH_FIELD()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD& SCH_FIELD::operator=( const SCH_FIELD& aField )
|
||||
{
|
||||
EDA_TEXT::operator=( aField );
|
||||
|
@ -125,8 +120,6 @@ EDA_ITEM* SCH_FIELD::Clone() const
|
|||
|
||||
void SCH_FIELD::SetId( int aId )
|
||||
{
|
||||
KICAD_T labelTypes[] = { SCH_LABEL_LOCATE_ANY_T, EOT };
|
||||
|
||||
m_id = aId;
|
||||
|
||||
if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
|
@ -147,7 +140,7 @@ void SCH_FIELD::SetId( int aId )
|
|||
default: SetLayer( LAYER_FIELDS ); break;
|
||||
}
|
||||
}
|
||||
else if( m_parent && m_parent->IsType( labelTypes ) )
|
||||
else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
|
||||
{
|
||||
// We can't use defined IDs for labels because there can be multiple net class
|
||||
// assignments.
|
||||
|
@ -164,8 +157,6 @@ void SCH_FIELD::SetId( int aId )
|
|||
|
||||
wxString SCH_FIELD::GetShownText( int aDepth ) const
|
||||
{
|
||||
KICAD_T labelTypes[] = { SCH_LABEL_LOCATE_ANY_T, EOT };
|
||||
|
||||
std::function<bool( wxString* )> symbolResolver =
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
|
@ -223,7 +214,7 @@ wxString SCH_FIELD::GetShownText( int aDepth ) const
|
|||
text = ExpandTextVars( text, &symbolResolver, nullptr, project );
|
||||
else if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
text = ExpandTextVars( text, &sheetResolver, nullptr, project );
|
||||
else if( m_parent && m_parent->IsType( labelTypes ) )
|
||||
else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
|
||||
text = ExpandTextVars( text, &labelResolver, nullptr, project );
|
||||
else
|
||||
text = ExpandTextVars( text, project );
|
||||
|
@ -790,8 +781,6 @@ void SCH_FIELD::DoHypertextMenu( EDA_DRAW_FRAME* aFrame )
|
|||
|
||||
wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
|
||||
{
|
||||
KICAD_T labelTypes[] = { SCH_LABEL_LOCATE_ANY_T, EOT };
|
||||
|
||||
if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
|
||||
{
|
||||
if( m_id >= 0 && m_id < MANDATORY_FIELDS )
|
||||
|
@ -810,7 +799,7 @@ wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
|
|||
else
|
||||
return m_name;
|
||||
}
|
||||
else if( m_parent && m_parent->IsType( labelTypes ) )
|
||||
else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
|
||||
{
|
||||
return SCH_LABEL_BASE::GetDefaultFieldName( m_name, aUseDefaultName );
|
||||
}
|
||||
|
@ -824,8 +813,6 @@ wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
|
|||
|
||||
wxString SCH_FIELD::GetCanonicalName() const
|
||||
{
|
||||
KICAD_T labelTypes[] = { SCH_LABEL_LOCATE_ANY_T, EOT };
|
||||
|
||||
if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
|
||||
{
|
||||
switch( m_id )
|
||||
|
@ -846,7 +833,7 @@ wxString SCH_FIELD::GetCanonicalName() const
|
|||
default: return m_name;
|
||||
}
|
||||
}
|
||||
else if( m_parent && m_parent->IsType( labelTypes ) )
|
||||
else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
|
||||
{
|
||||
// These should be stored in canonical format, but just in case:
|
||||
if( m_name == _( "Net Class" ) )
|
||||
|
|
|
@ -54,7 +54,8 @@ public:
|
|||
|
||||
SCH_FIELD( const SCH_FIELD& aText );
|
||||
|
||||
~SCH_FIELD();
|
||||
~SCH_FIELD()
|
||||
{ }
|
||||
|
||||
SCH_FIELD& operator=( const SCH_FIELD& aField );
|
||||
|
||||
|
@ -68,20 +69,20 @@ public:
|
|||
return wxT( "SCH_FIELD" );
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( SCH_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == SCH_FIELD_LOCATE_REFERENCE_T && m_id == REFERENCE_FIELD )
|
||||
if( scanType == SCH_FIELD_LOCATE_REFERENCE_T && m_id == REFERENCE_FIELD )
|
||||
return true;
|
||||
else if ( *p == SCH_FIELD_LOCATE_VALUE_T && m_id == VALUE_FIELD )
|
||||
else if ( scanType == SCH_FIELD_LOCATE_VALUE_T && m_id == VALUE_FIELD )
|
||||
return true;
|
||||
else if ( *p == SCH_FIELD_LOCATE_FOOTPRINT_T && m_id == FOOTPRINT_FIELD )
|
||||
else if ( scanType == SCH_FIELD_LOCATE_FOOTPRINT_T && m_id == FOOTPRINT_FIELD )
|
||||
return true;
|
||||
else if ( *p == SCH_FIELD_LOCATE_DATASHEET_T && m_id == DATASHEET_FIELD )
|
||||
else if ( scanType == SCH_FIELD_LOCATE_DATASHEET_T && m_id == DATASHEET_FIELD )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -157,20 +157,20 @@ public:
|
|||
return wxT( "SCH_ITEM" );
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( EDA_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == SCH_ITEM_LOCATE_WIRE_T && m_layer == LAYER_WIRE )
|
||||
if( scanType == SCH_ITEM_LOCATE_WIRE_T && m_layer == LAYER_WIRE )
|
||||
return true;
|
||||
|
||||
if ( *p == SCH_ITEM_LOCATE_BUS_T && m_layer == LAYER_BUS )
|
||||
if ( scanType == SCH_ITEM_LOCATE_BUS_T && m_layer == LAYER_BUS )
|
||||
return true;
|
||||
|
||||
if ( *p == SCH_ITEM_LOCATE_GRAPHIC_LINE_T
|
||||
if ( scanType == SCH_ITEM_LOCATE_GRAPHIC_LINE_T
|
||||
&& Type() == SCH_LINE_T && m_layer == LAYER_NOTES )
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -190,17 +190,14 @@ const wxString SCH_LABEL_BASE::GetDefaultFieldName( const wxString& aName, bool
|
|||
}
|
||||
|
||||
|
||||
bool SCH_LABEL_BASE::IsType( const KICAD_T aScanTypes[] ) const
|
||||
bool SCH_LABEL_BASE::IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const
|
||||
{
|
||||
static KICAD_T wireTypes[] = { SCH_ITEM_LOCATE_WIRE_T, SCH_PIN_T, EOT };
|
||||
static KICAD_T busTypes[] = { SCH_ITEM_LOCATE_BUS_T, EOT };
|
||||
|
||||
if( SCH_TEXT::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == SCH_LABEL_LOCATE_ANY_T )
|
||||
if( scanType == SCH_LABEL_LOCATE_ANY_T )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -213,22 +210,22 @@ bool SCH_LABEL_BASE::IsType( const KICAD_T aScanTypes[] ) const
|
|||
|
||||
const SCH_ITEM_SET& item_set = m_connected_items.at( Schematic()->CurrentSheet() );
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == SCH_LABEL_LOCATE_WIRE_T )
|
||||
if( scanType == SCH_LABEL_LOCATE_WIRE_T )
|
||||
{
|
||||
for( SCH_ITEM* connection : item_set )
|
||||
{
|
||||
if( connection->IsType( wireTypes ) )
|
||||
if( connection->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_PIN_T } ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( *p == SCH_LABEL_LOCATE_BUS_T )
|
||||
if ( scanType == SCH_LABEL_LOCATE_BUS_T )
|
||||
{
|
||||
for( SCH_ITEM* connection : item_set )
|
||||
{
|
||||
if( connection->IsType( busTypes ) )
|
||||
if( connection->IsType( { SCH_ITEM_LOCATE_BUS_T } ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -545,19 +542,19 @@ void SCH_LABEL_BASE::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFun
|
|||
|
||||
|
||||
INSPECT_RESULT SCH_LABEL_BASE::Visit( INSPECTOR aInspector, void* testData,
|
||||
const KICAD_T aFilterTypes[] )
|
||||
const std::initializer_list<KICAD_T>& aScanTypes )
|
||||
{
|
||||
KICAD_T stype;
|
||||
|
||||
if( IsType( aFilterTypes ) )
|
||||
if( IsType( aScanTypes ) )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( this, nullptr ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( stype == SCH_LOCATE_ANY_T || stype == SCH_FIELD_T )
|
||||
if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_FIELD_T )
|
||||
{
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
// Abstract class
|
||||
virtual wxString GetClass() const override = 0;
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override;
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override;
|
||||
|
||||
void SwapData( SCH_ITEM* aItem ) override;
|
||||
|
||||
|
@ -119,7 +119,8 @@ public:
|
|||
|
||||
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
|
||||
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& scanTypes ) override;
|
||||
|
||||
VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
|
||||
|
||||
|
|
|
@ -67,20 +67,20 @@ public:
|
|||
*/
|
||||
wxString GetNetname(const SCH_SHEET_PATH &aSheet);
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( SCH_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == SCH_ITEM_LOCATE_WIRE_T && m_layer == LAYER_WIRE )
|
||||
if( scanType == SCH_ITEM_LOCATE_WIRE_T && m_layer == LAYER_WIRE )
|
||||
return true;
|
||||
|
||||
if ( *p == SCH_ITEM_LOCATE_BUS_T && m_layer == LAYER_BUS )
|
||||
if ( scanType == SCH_ITEM_LOCATE_BUS_T && m_layer == LAYER_BUS )
|
||||
return true;
|
||||
|
||||
if ( *p == SCH_ITEM_LOCATE_GRAPHIC_LINE_T && m_layer == LAYER_NOTES )
|
||||
if ( scanType == SCH_ITEM_LOCATE_GRAPHIC_LINE_T && m_layer == LAYER_NOTES )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,8 @@ EESCHEMA_SETTINGS* eeconfig()
|
|||
}
|
||||
|
||||
|
||||
KICAD_T SCH_PAINTER::g_ScaledSelectionTypes[] = { SCH_MARKER_T,
|
||||
std::initializer_list<KICAD_T> SCH_PAINTER::g_ScaledSelectionTypes = {
|
||||
SCH_MARKER_T,
|
||||
SCH_JUNCTION_T,
|
||||
SCH_NO_CONNECT_T,
|
||||
SCH_BUS_WIRE_ENTRY_T,
|
||||
|
@ -85,8 +86,8 @@ KICAD_T SCH_PAINTER::g_ScaledSelectionTypes[] = { SCH_MARKER_T,
|
|||
SCH_DIRECTIVE_LABEL_T,
|
||||
LIB_SYMBOL_T, SCH_SYMBOL_T,
|
||||
SCH_SHEET_T,
|
||||
LIB_PIN_T, SCH_PIN_T,
|
||||
EOT };
|
||||
LIB_PIN_T, SCH_PIN_T
|
||||
};
|
||||
|
||||
|
||||
SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
|
||||
|
@ -99,8 +100,7 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
|
|||
m_OverrideItemColors( false ),
|
||||
m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ),
|
||||
m_TextOffsetRatio( DEFAULT_TEXT_OFFSET_RATIO ),
|
||||
m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ),
|
||||
m_JunctionSize( DEFAULT_JUNCTION_DIAM * IU_PER_MILS )
|
||||
m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 )
|
||||
{
|
||||
SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * IU_PER_MILS );
|
||||
SetDashLengthRatio( 12 ); // From ISO 128-2
|
||||
|
|
|
@ -122,9 +122,7 @@ public:
|
|||
double m_LabelSizeRatio; // Proportion of font size to label box
|
||||
double m_TextOffsetRatio; // Proportion of font size to offset text above/below
|
||||
// wires, buses, etc.
|
||||
|
||||
int m_PinSymbolSize;
|
||||
int m_JunctionSize;
|
||||
};
|
||||
|
||||
|
||||
|
@ -140,15 +138,9 @@ public:
|
|||
virtual bool Draw( const VIEW_ITEM*, int ) override;
|
||||
|
||||
/// @copydoc PAINTER::GetSettings()
|
||||
virtual SCH_RENDER_SETTINGS* GetSettings() override
|
||||
{
|
||||
return &m_schSettings;
|
||||
}
|
||||
virtual SCH_RENDER_SETTINGS* GetSettings() override { return &m_schSettings; }
|
||||
|
||||
void SetSchematic( SCHEMATIC* aSchematic )
|
||||
{
|
||||
m_schematic = aSchematic;
|
||||
}
|
||||
void SetSchematic( SCHEMATIC* aSchematic ) { m_schematic = aSchematic; }
|
||||
|
||||
private:
|
||||
void draw( LIB_PIN* aPin, int aLayer );
|
||||
|
@ -200,15 +192,13 @@ private:
|
|||
const TEXT_ATTRIBUTES& aAttributes );
|
||||
void bitmapText( const wxString& aText, const VECTOR2D& aPosition,
|
||||
const TEXT_ATTRIBUTES& aAttributes );
|
||||
void boxText( const wxString& aText, const VECTOR2D& aPosition,
|
||||
const TEXT_ATTRIBUTES& aAttrs );
|
||||
void boxText( const wxString& aText, const VECTOR2D& aPosition, const TEXT_ATTRIBUTES& aAttrs );
|
||||
|
||||
public:
|
||||
static KICAD_T g_ScaledSelectionTypes[];
|
||||
static std::initializer_list<KICAD_T> g_ScaledSelectionTypes;
|
||||
|
||||
private:
|
||||
SCH_RENDER_SETTINGS m_schSettings;
|
||||
|
||||
SCHEMATIC* m_schematic;
|
||||
};
|
||||
|
||||
|
|
|
@ -2355,12 +2355,11 @@ bool SCH_EAGLE_PLUGIN::CheckHeader( const wxString& aFileName )
|
|||
|
||||
void SCH_EAGLE_PLUGIN::moveLabels( SCH_LINE* aWire, const VECTOR2I& aNewEndPoint )
|
||||
{
|
||||
static KICAD_T labelTypes[] = { SCH_LABEL_LOCATE_ANY_T, EOT };
|
||||
SCH_SCREEN* screen = m_currentSheet->GetScreen();
|
||||
|
||||
for( SCH_ITEM* item : screen->Items().Overlapping( aWire->GetBoundingBox() ) )
|
||||
{
|
||||
if( !item->IsType( labelTypes ) )
|
||||
if( !item->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
|
||||
continue;
|
||||
|
||||
if( TestSegmentHit( item->GetPosition(), aWire->GetStartPoint(), aWire->GetEndPoint(), 0 ) )
|
||||
|
|
|
@ -24,11 +24,6 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file sch_screen.cpp
|
||||
* @brief Implementation of SCH_SCREEN and SCH_SCREENS classes.
|
||||
*/
|
||||
|
||||
#include <wx/filefn.h>
|
||||
|
||||
#include <eda_item.h>
|
||||
|
@ -92,7 +87,7 @@ SCH_SCREEN::~SCH_SCREEN()
|
|||
SCHEMATIC* SCH_SCREEN::Schematic() const
|
||||
{
|
||||
wxCHECK_MSG( GetParent() && GetParent()->Type() == SCHEMATIC_T, nullptr,
|
||||
"SCH_SCREEN must have a SCHEMATIC parent!" );
|
||||
wxT( "SCH_SCREEN must have a SCHEMATIC parent!" ) );
|
||||
|
||||
return static_cast<SCHEMATIC*>( GetParent() );
|
||||
}
|
||||
|
@ -123,8 +118,7 @@ void SCH_SCREEN::IncRefCount()
|
|||
|
||||
void SCH_SCREEN::DecRefCount()
|
||||
{
|
||||
wxCHECK_RET( m_refCount != 0,
|
||||
wxT( "Screen reference count already zero. Bad programmer!" ) );
|
||||
wxCHECK_RET( m_refCount != 0, wxT( "Screen reference count already zero. Bad programmer!" ) );
|
||||
m_refCount--;
|
||||
}
|
||||
|
||||
|
@ -1284,17 +1278,9 @@ void SCH_SCREEN::EnsureAlternateReferencesExist()
|
|||
|
||||
void SCH_SCREEN::GetHierarchicalItems( std::vector<SCH_ITEM*>* aItems ) const
|
||||
{
|
||||
static KICAD_T hierarchicalTypes[] = { SCH_SYMBOL_T,
|
||||
SCH_SHEET_T,
|
||||
SCH_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
EOT };
|
||||
|
||||
for( SCH_ITEM* item : Items() )
|
||||
{
|
||||
if( item->IsType( hierarchicalTypes ) )
|
||||
if( item->IsType( { SCH_SYMBOL_T, SCH_SHEET_T, SCH_LABEL_LOCATE_ANY_T } ) )
|
||||
aItems->push_back( item );
|
||||
}
|
||||
}
|
||||
|
@ -1317,7 +1303,9 @@ void SCH_SCREEN::GetSheets( std::vector<SCH_ITEM*>* aItems ) const
|
|||
return a->GetPosition().y < b->GetPosition().y;
|
||||
}
|
||||
else
|
||||
{
|
||||
return a->GetPosition().x < b->GetPosition().x;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -943,20 +943,19 @@ std::vector<VECTOR2I> SCH_SHEET::GetConnectionPoints() const
|
|||
}
|
||||
|
||||
|
||||
INSPECT_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData, const KICAD_T aFilterTypes[] )
|
||||
INSPECT_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes )
|
||||
{
|
||||
KICAD_T stype;
|
||||
|
||||
for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
// If caller wants to inspect my type
|
||||
if( stype == SCH_LOCATE_ANY_T || stype == Type() )
|
||||
if( scanType == SCH_LOCATE_ANY_T || scanType == Type() )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( this, nullptr ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
if( stype == SCH_LOCATE_ANY_T || stype == SCH_FIELD_T )
|
||||
if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_FIELD_T )
|
||||
{
|
||||
// Test the sheet fields.
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
|
@ -966,7 +965,7 @@ INSPECT_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData, const KIC
|
|||
}
|
||||
}
|
||||
|
||||
if( stype == SCH_LOCATE_ANY_T || stype == SCH_SHEET_PIN_T )
|
||||
if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_SHEET_PIN_T )
|
||||
{
|
||||
// Test the sheet labels.
|
||||
for( SCH_SHEET_PIN* sheetPin : m_pins )
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -350,7 +350,8 @@ public:
|
|||
|
||||
std::vector<VECTOR2I> GetConnectionPoints() const override;
|
||||
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes ) override;
|
||||
|
||||
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
|
||||
|
||||
|
|
|
@ -1724,21 +1724,19 @@ wxString SCH_SYMBOL::GetSelectMenuText( EDA_UNITS aUnits ) const
|
|||
|
||||
|
||||
INSPECT_RESULT SCH_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData,
|
||||
const KICAD_T aFilterTypes[] )
|
||||
const std::initializer_list<KICAD_T>& aScanTypes )
|
||||
{
|
||||
KICAD_T stype;
|
||||
|
||||
for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( stype == SCH_LOCATE_ANY_T
|
||||
|| ( stype == SCH_SYMBOL_T )
|
||||
|| ( stype == SCH_SYMBOL_LOCATE_POWER_T && m_part && m_part->IsPower() ) )
|
||||
if( scanType == SCH_LOCATE_ANY_T
|
||||
|| ( scanType == SCH_SYMBOL_T )
|
||||
|| ( scanType == SCH_SYMBOL_LOCATE_POWER_T && m_part && m_part->IsPower() ) )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
if( stype == SCH_LOCATE_ANY_T || stype == SCH_FIELD_T )
|
||||
if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_FIELD_T )
|
||||
{
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
|
@ -1747,32 +1745,32 @@ INSPECT_RESULT SCH_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData,
|
|||
}
|
||||
}
|
||||
|
||||
if( stype == SCH_FIELD_LOCATE_REFERENCE_T )
|
||||
if( scanType == SCH_FIELD_LOCATE_REFERENCE_T )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( REFERENCE_FIELD ), (void*) this ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
if( stype == SCH_FIELD_LOCATE_VALUE_T
|
||||
|| ( stype == SCH_SYMBOL_LOCATE_POWER_T && m_part && m_part->IsPower() ) )
|
||||
if( scanType == SCH_FIELD_LOCATE_VALUE_T
|
||||
|| ( scanType == SCH_SYMBOL_LOCATE_POWER_T && m_part && m_part->IsPower() ) )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( VALUE_FIELD ), (void*) this ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
if( stype == SCH_FIELD_LOCATE_FOOTPRINT_T )
|
||||
if( scanType == SCH_FIELD_LOCATE_FOOTPRINT_T )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( FOOTPRINT_FIELD ), (void*) this ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
if( stype == SCH_FIELD_LOCATE_DATASHEET_T )
|
||||
if( scanType == SCH_FIELD_LOCATE_DATASHEET_T )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( DATASHEET_FIELD ), (void*) this ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
if( stype == SCH_LOCATE_ANY_T || stype == SCH_PIN_T )
|
||||
if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_PIN_T )
|
||||
{
|
||||
for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
|
||||
{
|
||||
|
|
|
@ -638,7 +638,8 @@ public:
|
|||
|
||||
std::vector<VECTOR2I> GetConnectionPoints() const override;
|
||||
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes ) override;
|
||||
|
||||
/**
|
||||
* Return the symbol library item at \a aPosition that is part of this symbol.
|
||||
|
|
|
@ -283,7 +283,7 @@ int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else if( m_frame->IsType( FRAME_SCH ) )
|
||||
{
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_SYMBOL_T } );
|
||||
|
||||
if( selection.Empty() )
|
||||
return 0;
|
||||
|
|
|
@ -406,17 +406,6 @@ void EE_POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
|
|||
|
||||
int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
static KICAD_T supportedTypes[] = {
|
||||
LIB_SHAPE_T,
|
||||
LIB_TEXTBOX_T,
|
||||
SCH_SHAPE_T,
|
||||
SCH_TEXTBOX_T,
|
||||
SCH_SHEET_T,
|
||||
SCH_ITEM_LOCATE_GRAPHIC_LINE_T,
|
||||
SCH_BITMAP_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
if( !m_selectionTool )
|
||||
return 0;
|
||||
|
||||
|
@ -430,8 +419,14 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
const EE_SELECTION& selection = m_selectionTool->GetSelection();
|
||||
|
||||
if( selection.Size() != 1 || !selection.Front()->IsType( supportedTypes ) )
|
||||
if( selection.Size() != 1 || !selection.Front()->IsType( { LIB_SHAPE_T, SCH_SHAPE_T,
|
||||
LIB_TEXTBOX_T, SCH_TEXTBOX_T,
|
||||
SCH_SHEET_T,
|
||||
SCH_ITEM_LOCATE_GRAPHIC_LINE_T,
|
||||
SCH_BITMAP_T } ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Wait till drawing tool is done
|
||||
if( selection.Front()->IsNew() )
|
||||
|
|
|
@ -144,6 +144,23 @@ EE_SELECTION_TOOL::~EE_SELECTION_TOOL()
|
|||
using E_C = EE_CONDITIONS;
|
||||
|
||||
|
||||
static std::initializer_list<KICAD_T> connectedTypes =
|
||||
{
|
||||
SCH_SYMBOL_LOCATE_POWER_T,
|
||||
SCH_PIN_T,
|
||||
SCH_ITEM_LOCATE_WIRE_T,
|
||||
SCH_ITEM_LOCATE_BUS_T,
|
||||
SCH_BUS_WIRE_ENTRY_T,
|
||||
SCH_BUS_BUS_ENTRY_T,
|
||||
SCH_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_SHEET_PIN_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
SCH_JUNCTION_T
|
||||
};
|
||||
|
||||
|
||||
bool EE_SELECTION_TOOL::Init()
|
||||
{
|
||||
m_frame = getEditFrame<SCH_BASE_FRAME>();
|
||||
|
@ -162,25 +179,12 @@ bool EE_SELECTION_TOOL::Init()
|
|||
m_isSymbolViewer = symbolViewerFrame != nullptr;
|
||||
}
|
||||
|
||||
static KICAD_T wireOrBusTypes[] = { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T, EOT };
|
||||
static KICAD_T connectedTypes[] = { SCH_ITEM_LOCATE_WIRE_T,
|
||||
SCH_ITEM_LOCATE_BUS_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_LABEL_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
SCH_SHEET_PIN_T,
|
||||
SCH_PIN_T,
|
||||
EOT };
|
||||
|
||||
static KICAD_T crossProbingTypes[] = { SCH_SYMBOL_T, SCH_PIN_T, SCH_SHEET_T, EOT };
|
||||
|
||||
auto wireSelection = E_C::Count( 1 ) && E_C::OnlyType( SCH_ITEM_LOCATE_WIRE_T );
|
||||
auto busSelection = E_C::Count( 1 ) && E_C::OnlyType( SCH_ITEM_LOCATE_BUS_T );
|
||||
auto wireOrBusSelection = E_C::Count( 1 ) && E_C::OnlyTypes( wireOrBusTypes );
|
||||
auto wireSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_ITEM_LOCATE_WIRE_T } );
|
||||
auto busSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_ITEM_LOCATE_BUS_T });
|
||||
auto wireOrBusSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } );
|
||||
auto connectedSelection = E_C::Count( 1 ) && E_C::OnlyTypes( connectedTypes );
|
||||
auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
|
||||
auto crossProbingSelection = E_C::MoreThan( 0 ) && E_C::HasTypes( crossProbingTypes );
|
||||
auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } );
|
||||
auto crossProbingSelection = E_C::MoreThan( 0 ) && E_C::HasTypes( { SCH_SYMBOL_T, SCH_PIN_T, SCH_SHEET_T } );
|
||||
|
||||
auto schEditSheetPageNumberCondition =
|
||||
[&] ( const SELECTION& aSel )
|
||||
|
@ -188,7 +192,7 @@ bool EE_SELECTION_TOOL::Init()
|
|||
if( m_isSymbolEditor || m_isSymbolViewer )
|
||||
return false;
|
||||
|
||||
return E_C::LessThan( 2 )( aSel ) && E_C::OnlyType( SCH_SHEET_T )( aSel );
|
||||
return E_C::LessThan( 2 )( aSel ) && E_C::OnlyTypes( { SCH_SHEET_T } )( aSel );
|
||||
};
|
||||
|
||||
auto schEditCondition =
|
||||
|
@ -304,24 +308,6 @@ void EE_SELECTION_TOOL::Reset( RESET_REASON aReason )
|
|||
}
|
||||
|
||||
|
||||
const KICAD_T movableSymbolItems[] =
|
||||
{
|
||||
LIB_SHAPE_T,
|
||||
LIB_TEXT_T,
|
||||
LIB_TEXTBOX_T,
|
||||
LIB_PIN_T,
|
||||
LIB_FIELD_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T movableSymbolAliasItems[] =
|
||||
{
|
||||
LIB_FIELD_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
|
@ -416,7 +402,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
if( m_selection.Empty() )
|
||||
{
|
||||
ClearSelection();
|
||||
SelectPoint( evt->Position(), EE_COLLECTOR::AllItems, nullptr, &selCancelled );
|
||||
SelectPoint( evt->Position(), { SCH_LOCATE_ANY_T }, nullptr, &selCancelled );
|
||||
m_selection.SetIsHover( true );
|
||||
}
|
||||
// If the cursor has moved off the bounding box of the selection by more than
|
||||
|
@ -432,7 +418,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
for( EDA_ITEM* item : saved_selection )
|
||||
RemoveItemFromSel( item, true );
|
||||
|
||||
SelectPoint( evt->Position(), EE_COLLECTOR::AllItems, nullptr, &selCancelled );
|
||||
SelectPoint( evt->Position(), { SCH_LOCATE_ANY_T }, nullptr, &selCancelled );
|
||||
|
||||
if( m_selection.Empty() )
|
||||
{
|
||||
|
@ -507,9 +493,17 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
if( m_isSymbolEditor )
|
||||
{
|
||||
if( static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->IsSymbolAlias() )
|
||||
m_selection = RequestSelection( movableSymbolAliasItems );
|
||||
{
|
||||
m_selection = RequestSelection( { LIB_FIELD_T } );
|
||||
}
|
||||
else
|
||||
m_selection = RequestSelection( movableSymbolItems );
|
||||
{
|
||||
m_selection = RequestSelection( { LIB_SHAPE_T,
|
||||
LIB_TEXT_T,
|
||||
LIB_TEXTBOX_T,
|
||||
LIB_PIN_T,
|
||||
LIB_FIELD_T } );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -747,7 +741,7 @@ int EE_SELECTION_TOOL::disambiguateCursor( const TOOL_EVENT& aEvent )
|
|||
keyboardState.AltDown() );
|
||||
|
||||
m_skip_heuristics = true;
|
||||
SelectPoint( m_originalCursor, EE_COLLECTOR::AllItems, nullptr, &m_canceledMenu, false,
|
||||
SelectPoint( m_originalCursor, { SCH_LOCATE_ANY_T }, nullptr, &m_canceledMenu, false,
|
||||
m_additive, m_subtractive, m_exclusive_or );
|
||||
m_skip_heuristics = false;
|
||||
|
||||
|
@ -783,7 +777,7 @@ EE_SELECTION& EE_SELECTION_TOOL::GetSelection()
|
|||
|
||||
|
||||
bool EE_SELECTION_TOOL::CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& aWhere,
|
||||
const KICAD_T* aFilterList )
|
||||
const std::initializer_list<KICAD_T>& aFilterList )
|
||||
{
|
||||
int pixelThreshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||
int gridThreshold = KiROUND( getView()->GetGAL()->GetGridSize().EuclideanNorm() / 2 );
|
||||
|
@ -938,7 +932,8 @@ bool EE_SELECTION_TOOL::selectPoint( EE_COLLECTOR& aCollector, const VECTOR2I& a
|
|||
}
|
||||
|
||||
|
||||
bool EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T* aFilterList,
|
||||
bool EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere,
|
||||
const std::initializer_list<KICAD_T>& aFilterList,
|
||||
EDA_ITEM** aItem, bool* aSelectionCancelledFlag,
|
||||
bool aCheckLocked, bool aAdd, bool aSubtract,
|
||||
bool aExclusiveOr )
|
||||
|
@ -1147,7 +1142,8 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
|
|||
}
|
||||
|
||||
|
||||
EE_SELECTION& EE_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] )
|
||||
EE_SELECTION&
|
||||
EE_SELECTION_TOOL::RequestSelection( const std::initializer_list<KICAD_T>& aFilterList )
|
||||
{
|
||||
if( m_selection.Empty() )
|
||||
{
|
||||
|
@ -1417,24 +1413,6 @@ bool EE_SELECTION_TOOL::selectMultiple()
|
|||
}
|
||||
|
||||
|
||||
static KICAD_T nodeTypes[] =
|
||||
{
|
||||
SCH_SYMBOL_LOCATE_POWER_T,
|
||||
SCH_PIN_T,
|
||||
SCH_ITEM_LOCATE_WIRE_T,
|
||||
SCH_ITEM_LOCATE_BUS_T,
|
||||
SCH_BUS_WIRE_ENTRY_T,
|
||||
SCH_BUS_BUS_ENTRY_T,
|
||||
SCH_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_SHEET_PIN_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
SCH_JUNCTION_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
EDA_ITEM* EE_SELECTION_TOOL::GetNode( VECTOR2I aPosition )
|
||||
{
|
||||
EE_COLLECTOR collector;
|
||||
|
@ -1447,7 +1425,7 @@ EDA_ITEM* EE_SELECTION_TOOL::GetNode( VECTOR2I aPosition )
|
|||
for( int threshold : { 0, thresholdMax/4, thresholdMax/2, thresholdMax } )
|
||||
{
|
||||
collector.m_Threshold = threshold;
|
||||
collector.Collect( m_frame->GetScreen(), nodeTypes, aPosition );
|
||||
collector.Collect( m_frame->GetScreen(), connectedTypes, aPosition );
|
||||
|
||||
if( collector.GetCount() > 0 )
|
||||
break;
|
||||
|
@ -1461,7 +1439,7 @@ int EE_SELECTION_TOOL::SelectNode( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( false );
|
||||
|
||||
SelectPoint( cursorPos, nodeTypes );
|
||||
SelectPoint( cursorPos, connectedTypes );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1469,9 +1447,7 @@ int EE_SELECTION_TOOL::SelectNode( const TOOL_EVENT& aEvent )
|
|||
|
||||
int EE_SELECTION_TOOL::SelectConnection( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
static KICAD_T wiresAndBuses[] = { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T, EOT };
|
||||
|
||||
RequestSelection( wiresAndBuses );
|
||||
RequestSelection( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } );
|
||||
|
||||
if( m_selection.Empty() )
|
||||
return 0;
|
||||
|
@ -1484,8 +1460,11 @@ int EE_SELECTION_TOOL::SelectConnection( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( SCH_ITEM* item : conns )
|
||||
{
|
||||
if( item->IsType( wiresAndBuses ) && !item->IsSelected() )
|
||||
if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } )
|
||||
&& !item->IsSelected() )
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
|
||||
select( item );
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 CERN
|
||||
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -82,13 +82,15 @@ public:
|
|||
* Return either an existing selection (filtered), or the selection at the current
|
||||
* cursor if the existing selection is empty.
|
||||
*/
|
||||
EE_SELECTION& RequestSelection( const KICAD_T* aFilterList = EE_COLLECTOR::AllItems );
|
||||
EE_SELECTION&
|
||||
RequestSelection( const std::initializer_list<KICAD_T>& aFilterList = { SCH_LOCATE_ANY_T } );
|
||||
|
||||
/**
|
||||
* This overload of SelectPoint will create an EE_COLLECTOR and collect hits at location aWhere
|
||||
* before calling the primary SelectPoint method.
|
||||
*
|
||||
* @param aWhere is the location where the item(s) should be collected
|
||||
* @param aFilterList is a list of items that are acceptable for collection
|
||||
* @param aItem is set to the newly selected item if only one was selected, otherwise is
|
||||
* unchanged.
|
||||
* @param aSelectionCancelledFlag allows the function to inform its caller that a selection
|
||||
|
@ -99,7 +101,8 @@ public:
|
|||
* @param aSubtract indicates if found item(s) should be subtracted from the selection
|
||||
* @param aExclusiveOr indicates if found item(s) should be toggle in the selection
|
||||
*/
|
||||
bool SelectPoint( const VECTOR2I& aWhere, const KICAD_T* aFilterList = EE_COLLECTOR::AllItems,
|
||||
bool SelectPoint( const VECTOR2I& aWhere,
|
||||
const std::initializer_list<KICAD_T>& aFilterList = { SCH_LOCATE_ANY_T },
|
||||
EDA_ITEM** aItem = nullptr, bool* aSelectionCancelledFlag = nullptr,
|
||||
bool aCheckLocked = false, bool aAdd = false, bool aSubtract = false,
|
||||
bool aExclusiveOr = false );
|
||||
|
@ -154,7 +157,7 @@ public:
|
|||
* @param aCheckLocked indicates if locked items should be excluded.
|
||||
*/
|
||||
bool CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& aWhere,
|
||||
const KICAD_T* aFilterList = EE_COLLECTOR::AllItems );
|
||||
const std::initializer_list<KICAD_T>& aFilterList = { SCH_LOCATE_ANY_T } );
|
||||
|
||||
protected:
|
||||
SELECTION& selection() override { return m_selection; }
|
||||
|
|
|
@ -1330,7 +1330,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
SCH_HIERLABEL* label = nullptr;
|
||||
SCH_SHEET* sheet = nullptr;
|
||||
|
||||
if( m_selectionTool->SelectPoint( cursorPos, EE_COLLECTOR::SheetsOnly, &i ) )
|
||||
if( m_selectionTool->SelectPoint( cursorPos, { SCH_SHEET_T }, &i ) )
|
||||
sheet = dynamic_cast<SCH_SHEET*>( i );
|
||||
|
||||
m_selectionTool->ClearSelection();
|
||||
|
|
|
@ -176,7 +176,7 @@ bool SCH_EDIT_TOOL::Init()
|
|||
return sheet->HasUndefinedPins();
|
||||
};
|
||||
|
||||
auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
|
||||
auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } );
|
||||
|
||||
auto haveHighlight =
|
||||
[&]( const SELECTION& sel )
|
||||
|
@ -325,44 +325,58 @@ bool SCH_EDIT_TOOL::Init()
|
|||
return false;
|
||||
};
|
||||
|
||||
static KICAD_T allTextTypes[] = { SCH_LABEL_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
static std::initializer_list<KICAD_T> allTextTypes = { SCH_LABEL_LOCATE_ANY_T,
|
||||
SCH_TEXT_T,
|
||||
SCH_TEXTBOX_T,
|
||||
EOT };
|
||||
SCH_TEXTBOX_T };
|
||||
|
||||
auto toChangeCondition = ( E_C::OnlyTypes( allTextTypes ) );
|
||||
|
||||
static KICAD_T toLabelTypes[] = { SCH_DIRECTIVE_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, SCH_TEXTBOX_T, EOT };
|
||||
auto toLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toLabelTypes ) )
|
||||
auto toLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_DIRECTIVE_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_TEXT_T,
|
||||
SCH_TEXTBOX_T } ) )
|
||||
|| ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
|
||||
|
||||
static KICAD_T toCLabelTypes[] = { SCH_LABEL_T, SCH_HIER_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, SCH_TEXTBOX_T, EOT };
|
||||
auto toCLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toCLabelTypes ) )
|
||||
auto toCLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_TEXT_T,
|
||||
SCH_TEXTBOX_T } ) )
|
||||
|| ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
|
||||
|
||||
static KICAD_T toHLabelTypes[] = { SCH_LABEL_T, SCH_DIRECTIVE_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, SCH_TEXTBOX_T, EOT };
|
||||
auto toHLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toHLabelTypes ) )
|
||||
auto toHLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_TEXT_T,
|
||||
SCH_TEXTBOX_T } ) )
|
||||
|| ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
|
||||
|
||||
static KICAD_T toGLabelTypes[] = { SCH_LABEL_T, SCH_DIRECTIVE_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, SCH_TEXTBOX_T, EOT };
|
||||
auto toGLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toGLabelTypes ) )
|
||||
auto toGLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_TEXT_T,
|
||||
SCH_TEXTBOX_T } ) )
|
||||
|| ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
|
||||
|
||||
static KICAD_T toTextTypes[] = { SCH_LABEL_T, SCH_DIRECTIVE_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXTBOX_T, EOT };
|
||||
auto toTextCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toTextTypes ) )
|
||||
auto toTextCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_TEXTBOX_T } ) )
|
||||
|| ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
|
||||
|
||||
static KICAD_T toTextBoxTypes[] = { SCH_LABEL_T, SCH_DIRECTIVE_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
|
||||
auto toTextBoxCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toTextBoxTypes ) )
|
||||
auto toTextBoxCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_TEXT_T } ) )
|
||||
|| ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
|
||||
|
||||
static KICAD_T entryTypes[] = { SCH_BUS_WIRE_ENTRY_T, SCH_BUS_BUS_ENTRY_T, EOT };
|
||||
auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( entryTypes );
|
||||
auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( { SCH_BUS_WIRE_ENTRY_T,
|
||||
SCH_BUS_BUS_ENTRY_T} );
|
||||
|
||||
auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
|
||||
auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } );
|
||||
|
||||
//
|
||||
// Add edit actions to the move tool menu
|
||||
|
@ -509,7 +523,7 @@ bool SCH_EDIT_TOOL::Init()
|
|||
}
|
||||
|
||||
|
||||
const KICAD_T rotatableItems[] = {
|
||||
const std::initializer_list<KICAD_T> rotatableItems = {
|
||||
SCH_SHAPE_T,
|
||||
SCH_TEXT_T,
|
||||
SCH_TEXTBOX_T,
|
||||
|
@ -526,8 +540,7 @@ const KICAD_T rotatableItems[] = {
|
|||
SCH_BUS_WIRE_ENTRY_T,
|
||||
SCH_LINE_T,
|
||||
SCH_JUNCTION_T,
|
||||
SCH_NO_CONNECT_T,
|
||||
EOT
|
||||
SCH_NO_CONNECT_T
|
||||
};
|
||||
|
||||
|
||||
|
@ -1067,7 +1080,7 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
static KICAD_T deletableItems[] =
|
||||
static std::initializer_list<KICAD_T> deletableItems =
|
||||
{
|
||||
SCH_MARKER_T,
|
||||
SCH_JUNCTION_T,
|
||||
|
@ -1086,8 +1099,7 @@ static KICAD_T deletableItems[] =
|
|||
SCH_SHEET_PIN_T,
|
||||
SCH_SYMBOL_T,
|
||||
SCH_FIELD_T, // Will be hidden
|
||||
SCH_BITMAP_T,
|
||||
EOT
|
||||
SCH_BITMAP_T
|
||||
};
|
||||
|
||||
|
||||
|
@ -1298,19 +1310,14 @@ void SCH_EDIT_TOOL::editFieldText( SCH_FIELD* aField )
|
|||
|
||||
int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
static KICAD_T Nothing[] = { EOT };
|
||||
static KICAD_T CmpOrReference[] = { SCH_FIELD_LOCATE_REFERENCE_T, SCH_SYMBOL_T, EOT };
|
||||
static KICAD_T CmpOrValue[] = { SCH_FIELD_LOCATE_VALUE_T, SCH_SYMBOL_T, EOT };
|
||||
static KICAD_T CmpOrFootprint[] = { SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_SYMBOL_T, EOT };
|
||||
|
||||
KICAD_T* filter = Nothing;
|
||||
std::initializer_list<KICAD_T> filter = {};
|
||||
|
||||
if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
|
||||
filter = CmpOrReference;
|
||||
filter = { SCH_FIELD_LOCATE_REFERENCE_T, SCH_SYMBOL_T };
|
||||
else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
|
||||
filter = CmpOrValue;
|
||||
filter = { SCH_FIELD_LOCATE_VALUE_T, SCH_SYMBOL_T };
|
||||
else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
|
||||
filter = CmpOrFootprint;
|
||||
filter = { SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_SYMBOL_T };
|
||||
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( filter );
|
||||
|
||||
|
@ -1405,7 +1412,7 @@ int SCH_EDIT_TOOL::AutoplaceFields( const TOOL_EVENT& aEvent )
|
|||
int SCH_EDIT_TOOL::ChangeSymbols( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCH_SYMBOL* selectedSymbol = nullptr;
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_SYMBOL_T } );
|
||||
|
||||
if( !selection.Empty() )
|
||||
selectedSymbol = dynamic_cast<SCH_SYMBOL*>( selection.Front() );
|
||||
|
@ -1428,7 +1435,7 @@ int SCH_EDIT_TOOL::ChangeSymbols( const TOOL_EVENT& aEvent )
|
|||
|
||||
int SCH_EDIT_TOOL::ConvertDeMorgan( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_SYMBOL_T } );
|
||||
|
||||
if( selection.Empty() )
|
||||
return 0;
|
||||
|
@ -1770,14 +1777,9 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
|||
int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
KICAD_T convertTo = aEvent.Parameter<KICAD_T>();
|
||||
KICAD_T allTextTypes[] = { SCH_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_DIRECTIVE_LABEL_T,
|
||||
EE_SELECTION selection = m_selectionTool->RequestSelection( { SCH_LABEL_LOCATE_ANY_T,
|
||||
SCH_TEXT_T,
|
||||
SCH_TEXTBOX_T,
|
||||
EOT };
|
||||
EE_SELECTION selection = m_selectionTool->RequestSelection( allTextTypes );
|
||||
SCH_TEXTBOX_T } );
|
||||
|
||||
for( unsigned int i = 0; i < selection.GetSize(); ++i )
|
||||
{
|
||||
|
@ -2056,7 +2058,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
|||
int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
wxPoint cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::WiresOnly );
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_LINE_T } );
|
||||
|
||||
std::vector<SCH_LINE*> lines;
|
||||
|
||||
|
@ -2097,7 +2099,7 @@ int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent )
|
|||
|
||||
int SCH_EDIT_TOOL::CleanupSheetPins( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_SHEET_T } );
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
|
||||
|
||||
if( !sheet || !sheet->HasUndefinedPins() )
|
||||
|
@ -2122,7 +2124,7 @@ int SCH_EDIT_TOOL::CleanupSheetPins( const TOOL_EVENT& aEvent )
|
|||
|
||||
int SCH_EDIT_TOOL::EditPageNumber( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
|
||||
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_SHEET_T } );
|
||||
|
||||
if( selection.GetSize() > 1 )
|
||||
return 0;
|
||||
|
|
|
@ -729,13 +729,8 @@ void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aF
|
|||
|
||||
#ifdef KICAD_SPICE
|
||||
|
||||
static KICAD_T wires[] = { SCH_ITEM_LOCATE_WIRE_T, EOT };
|
||||
static KICAD_T wiresAndPins[] = { SCH_ITEM_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT };
|
||||
static KICAD_T fieldsAndSymbols[] = { SCH_SYMBOL_T, SCH_FIELD_T, EOT };
|
||||
|
||||
#define HITTEST_THRESHOLD_PIXELS 5
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
LOCALE_IO toggle;
|
||||
|
@ -835,7 +830,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
|
|||
simFrame->AddCurrentPlot( name );
|
||||
}
|
||||
}
|
||||
else if( item->IsType( wires ) )
|
||||
else if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T } ) )
|
||||
{
|
||||
if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection() )
|
||||
{
|
||||
|
@ -854,7 +849,9 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
EE_COLLECTOR collector;
|
||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||
collector.Collect( m_frame->GetScreen(), wiresAndPins, (wxPoint) aPos );
|
||||
collector.Collect( m_frame->GetScreen(), { SCH_ITEM_LOCATE_WIRE_T,
|
||||
SCH_PIN_T,
|
||||
SCH_SHEET_PIN_T }, aPos );
|
||||
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||
|
@ -935,7 +932,7 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
EDA_ITEM* item = nullptr;
|
||||
selTool->SelectPoint( aPosition, fieldsAndSymbols, &item );
|
||||
selTool->SelectPoint( aPosition, { SCH_SYMBOL_T, SCH_FIELD_T }, &item );
|
||||
|
||||
if( !item )
|
||||
return false;
|
||||
|
@ -970,7 +967,7 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
EE_COLLECTOR collector;
|
||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||
collector.Collect( m_frame->GetScreen(), fieldsAndSymbols, (wxPoint) aPos );
|
||||
collector.Collect( m_frame->GetScreen(), { SCH_SYMBOL_T, SCH_FIELD_T }, aPos );
|
||||
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||
|
@ -2000,7 +1997,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
int SCH_EDITOR_CONTROL::EditWithSymbolEditor( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
|
||||
EE_SELECTION& selection = selTool->RequestSelection( { SCH_SYMBOL_T } );
|
||||
SCH_SYMBOL* symbol = nullptr;
|
||||
SYMBOL_EDIT_FRAME* symbolEditor;
|
||||
|
||||
|
|
|
@ -94,8 +94,7 @@ private:
|
|||
{
|
||||
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) getToolManager()->GetToolHolder();
|
||||
EE_SELECTION_TOOL* selTool = getToolManager()->GetTool<EE_SELECTION_TOOL>();
|
||||
KICAD_T busType[] = { SCH_ITEM_LOCATE_BUS_T, EOT };
|
||||
EE_SELECTION& selection = selTool->RequestSelection( busType );
|
||||
EE_SELECTION& selection = selTool->RequestSelection( { SCH_ITEM_LOCATE_BUS_T } );
|
||||
SCH_LINE* bus = (SCH_LINE*) selection.Front();
|
||||
|
||||
Clear();
|
||||
|
@ -106,7 +105,7 @@ private:
|
|||
frame->RecalculateConnections( NO_CLEANUP );
|
||||
|
||||
// Pick up the pointer again because it may have been changed by SchematicCleanUp
|
||||
selection = selTool->RequestSelection( busType );
|
||||
selection = selTool->RequestSelection( { SCH_ITEM_LOCATE_BUS_T } );
|
||||
bus = (SCH_LINE*) selection.Front();
|
||||
}
|
||||
|
||||
|
@ -200,7 +199,7 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init()
|
|||
};
|
||||
|
||||
auto busSelection = EE_CONDITIONS::MoreThan( 0 )
|
||||
&& EE_CONDITIONS::OnlyType( SCH_ITEM_LOCATE_BUS_T );
|
||||
&& EE_CONDITIONS::OnlyTypes( { SCH_ITEM_LOCATE_BUS_T } );
|
||||
|
||||
auto haveHighlight =
|
||||
[&]( const SELECTION& sel )
|
||||
|
@ -264,22 +263,22 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init()
|
|||
|
||||
bool SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine( const SELECTION& aSelection )
|
||||
{
|
||||
static KICAD_T graphicLineType[] = { SCH_ITEM_LOCATE_GRAPHIC_LINE_T, EOT };
|
||||
return IsDrawingLineWireOrBus( aSelection ) && aSelection.Front()->IsType( graphicLineType );
|
||||
return IsDrawingLineWireOrBus( aSelection )
|
||||
&& aSelection.Front()->IsType( { SCH_ITEM_LOCATE_GRAPHIC_LINE_T } );
|
||||
}
|
||||
|
||||
|
||||
bool SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire( const SELECTION& aSelection )
|
||||
{
|
||||
static KICAD_T wireType[] = { SCH_ITEM_LOCATE_WIRE_T, EOT };
|
||||
return IsDrawingLineWireOrBus( aSelection ) && aSelection.Front()->IsType( wireType );
|
||||
return IsDrawingLineWireOrBus( aSelection )
|
||||
&& aSelection.Front()->IsType( { SCH_ITEM_LOCATE_WIRE_T } );
|
||||
}
|
||||
|
||||
|
||||
bool SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus( const SELECTION& aSelection )
|
||||
{
|
||||
static KICAD_T busType[] = { SCH_ITEM_LOCATE_BUS_T, EOT };
|
||||
return IsDrawingLineWireOrBus( aSelection ) && aSelection.Front()->IsType( busType );
|
||||
return IsDrawingLineWireOrBus( aSelection )
|
||||
&& aSelection.Front()->IsType( { SCH_ITEM_LOCATE_BUS_T } );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ bool SCH_MOVE_TOOL::Init()
|
|||
auto moveCondition =
|
||||
[]( const SELECTION& aSel )
|
||||
{
|
||||
if( aSel.Empty() || SELECTION_CONDITIONS::OnlyType( SCH_MARKER_T )( aSel ) )
|
||||
if( aSel.Empty() || SELECTION_CONDITIONS::OnlyTypes( { SCH_MARKER_T } )( aSel ) )
|
||||
return false;
|
||||
|
||||
if( SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) )
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 CERN
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -188,7 +188,7 @@ int SCH_NAVIGATE_TOOL::ChangeSheet( const TOOL_EVENT& aEvent )
|
|||
int SCH_NAVIGATE_TOOL::EnterSheet( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
|
||||
const EE_SELECTION& selection = selTool->RequestSelection( { SCH_SHEET_T } );
|
||||
|
||||
if( selection.GetSize() == 1 )
|
||||
{
|
||||
|
|
|
@ -239,14 +239,13 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
static KICAD_T nonFields[] =
|
||||
static std::initializer_list<KICAD_T> nonFields =
|
||||
{
|
||||
LIB_SYMBOL_T,
|
||||
LIB_SHAPE_T,
|
||||
LIB_TEXT_T,
|
||||
LIB_TEXTBOX_T,
|
||||
LIB_PIN_T,
|
||||
EOT
|
||||
LIB_PIN_T
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -89,8 +89,6 @@ void SYMBOL_EDITOR_MOVE_TOOL::Reset( RESET_REASON aReason )
|
|||
|
||||
int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
static KICAD_T fieldsOnly[] = { LIB_FIELD_T, EOT };
|
||||
|
||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
|
||||
m_anchorPos = { 0, 0 };
|
||||
|
@ -98,7 +96,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
// Be sure that there is at least one item that we can move. If there's no selection try
|
||||
// looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
|
||||
EE_SELECTION& selection = m_frame->IsSymbolAlias()
|
||||
? m_selectionTool->RequestSelection( fieldsOnly )
|
||||
? m_selectionTool->RequestSelection( { LIB_FIELD_T } )
|
||||
: m_selectionTool->RequestSelection();
|
||||
bool unselect = selection.IsHover();
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::Init()
|
|||
return editor->IsSymbolEditable() && !editor->IsSymbolAlias();
|
||||
};
|
||||
|
||||
auto singlePinCondition = EE_CONDITIONS::Count( 1 ) && EE_CONDITIONS::OnlyType( LIB_PIN_T );
|
||||
auto singlePinCondition = EE_CONDITIONS::Count( 1 ) && EE_CONDITIONS::OnlyTypes( { LIB_PIN_T } );
|
||||
|
||||
CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -75,24 +75,17 @@ EDA_RECT GBR_LAYOUT::ComputeBoundingBox() const
|
|||
}
|
||||
|
||||
|
||||
INSPECT_RESULT GBR_LAYOUT::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||
INSPECT_RESULT GBR_LAYOUT::Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes )
|
||||
{
|
||||
KICAD_T stype;
|
||||
INSPECT_RESULT result = INSPECT_RESULT::CONTINUE;
|
||||
const KICAD_T* p = scanTypes;
|
||||
bool done = false;
|
||||
|
||||
#if 0 && defined(DEBUG)
|
||||
std::cout << GetClass().mb_str() << ' ';
|
||||
#endif
|
||||
|
||||
while( !done )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
stype = *p;
|
||||
|
||||
switch( stype )
|
||||
if( scanType == GERBER_LAYOUT_T )
|
||||
{
|
||||
case GERBER_LAYOUT_T:
|
||||
for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
|
||||
{
|
||||
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
|
||||
|
@ -100,23 +93,11 @@ INSPECT_RESULT GBR_LAYOUT::Visit( INSPECTOR inspector, void* testData, const KIC
|
|||
if( gerber == nullptr ) // Graphic layer not yet used
|
||||
continue;
|
||||
|
||||
result = gerber->Visit( inspector, testData, p );
|
||||
|
||||
if( result == INSPECT_RESULT::QUIT )
|
||||
break;
|
||||
if( gerber->Visit( inspector, testData, { scanType } ) == INSPECT_RESULT::QUIT )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++p;
|
||||
break;
|
||||
|
||||
default: // catch EOT or ANY OTHER type here and return.
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if( result == INSPECT_RESULT::QUIT )
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -78,7 +78,8 @@ public:
|
|||
void SetBoundingBox( const EDA_RECT& aBox ) { m_BoundingBox = aBox; }
|
||||
|
||||
///< @copydoc EDA_ITEM::Visit()
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes ) override;
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -19,13 +19,6 @@
|
|||
|
||||
#include "gerber_collectors.h"
|
||||
|
||||
const KICAD_T GERBER_COLLECTOR::AllItems[] = {
|
||||
GERBER_LAYOUT_T,
|
||||
GERBER_IMAGE_T,
|
||||
GERBER_DRAW_ITEM_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The examining function within the INSPECTOR which is passed to the iterate function.
|
||||
|
@ -43,14 +36,11 @@ INSPECT_RESULT GERBER_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
}
|
||||
|
||||
|
||||
void GERBER_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aScanList[],
|
||||
const VECTOR2I& aRefPos /*, const COLLECTORS_GUIDE& aGuide*/ )
|
||||
void GERBER_COLLECTOR::Collect( EDA_ITEM* aItem, const std::initializer_list<KICAD_T>& aScanList,
|
||||
const VECTOR2I& aRefPos )
|
||||
{
|
||||
Empty(); // empty the collection, primary criteria list
|
||||
|
||||
// remember guide, pass it to Inspect()
|
||||
//SetGuide( &aGuide );
|
||||
|
||||
SetScanTypes( aScanList );
|
||||
|
||||
// remember where the snapshot was taken from and pass refPos to
|
||||
|
@ -58,7 +48,4 @@ void GERBER_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aScanList[],
|
|||
SetRefPos( aRefPos );
|
||||
|
||||
aItem->Visit( m_inspector, nullptr, m_scanTypes );
|
||||
|
||||
// record the length of the primary list before concatenating on to it.
|
||||
m_PrimaryLength = m_list.size();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -28,20 +28,9 @@
|
|||
class GERBER_COLLECTOR : public COLLECTOR
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A scan list for all selectable gerber items
|
||||
*/
|
||||
static const KICAD_T AllItems[];
|
||||
|
||||
GERBER_COLLECTOR()
|
||||
{
|
||||
m_PrimaryLength = 0;
|
||||
SetScanTypes( AllItems );
|
||||
}
|
||||
|
||||
void Empty2nd()
|
||||
{
|
||||
m_List2nd.clear();
|
||||
SetScanTypes( { GERBER_LAYOUT_T, GERBER_IMAGE_T, GERBER_DRAW_ITEM_T } );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,11 +47,6 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number if items which met the primary search criteria.
|
||||
*/
|
||||
int GetPrimaryCount() { return m_PrimaryLength; }
|
||||
|
||||
/**
|
||||
* The examining function within the INSPECTOR which is passed to the Iterate function.
|
||||
*
|
||||
|
@ -76,29 +60,12 @@ public:
|
|||
* Scan an EDA_ITEM using this class's Inspector method, which does the collection.
|
||||
*
|
||||
* @param aItem An EDA_ITEM to scan
|
||||
* @param aScanList A list of KICAD_Ts with a terminating EOT, that specs
|
||||
* what is to be collected and the priority order of the resultant
|
||||
* collection in "m_list".
|
||||
* @param aScanList A list of KICAD_Ts that specs what is to be collected and the priority
|
||||
* order of the resultant collection in "m_list".
|
||||
* @param aRefPos A VECTOR2I to use in hit-testing.
|
||||
* @param aGuide The COLLECTORS_GUIDE to use in collecting items.
|
||||
*/
|
||||
void Collect( EDA_ITEM* aItem, const KICAD_T aScanList[],
|
||||
const VECTOR2I& aRefPos /*, const COLLECTORS_GUIDE& aGuide */ );
|
||||
|
||||
protected:
|
||||
/**
|
||||
* A place to hold collected objects which don't match precisely the search
|
||||
* criteria, but would be acceptable if nothing else is found.
|
||||
* "2nd" choice, which will be appended to the end of COLLECTOR's prime
|
||||
* "list" at the end of the search.
|
||||
*/
|
||||
std::vector<EDA_ITEM*> m_List2nd;
|
||||
|
||||
/**
|
||||
* The number of items that were originally in the primary list before the
|
||||
* m_List2nd was concatenated onto the end of it.
|
||||
*/
|
||||
int m_PrimaryLength;
|
||||
void Collect( EDA_ITEM* aItem, const std::initializer_list<KICAD_T>& aScanList,
|
||||
const VECTOR2I& aRefPos );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -402,18 +402,6 @@ const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const
|
|||
}
|
||||
|
||||
|
||||
void GERBER_DRAW_ITEM::MoveAB( const VECTOR2I& aMoveVector )
|
||||
{
|
||||
VECTOR2I xymove = GetXYPosition( aMoveVector );
|
||||
|
||||
m_Start += xymove;
|
||||
m_End += xymove;
|
||||
m_ArcCentre += xymove;
|
||||
|
||||
m_Polygon.Move( xymove );
|
||||
}
|
||||
|
||||
|
||||
void GERBER_DRAW_ITEM::MoveXY( const VECTOR2I& aMoveVector )
|
||||
{
|
||||
m_Start += aMoveVector;
|
||||
|
@ -997,16 +985,16 @@ double GERBER_DRAW_ITEM::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
|||
|
||||
|
||||
INSPECT_RESULT GERBER_DRAW_ITEM::Visit( INSPECTOR inspector, void* testData,
|
||||
const KICAD_T scanTypes[] )
|
||||
const std::initializer_list<KICAD_T>& aScanTypes )
|
||||
{
|
||||
KICAD_T stype = *scanTypes;
|
||||
|
||||
// If caller wants to inspect my type
|
||||
if( stype == Type() )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( scanType == Type() )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == inspector( this, testData ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
}
|
||||
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
@ -1014,9 +1002,7 @@ INSPECT_RESULT GERBER_DRAW_ITEM::Visit( INSPECTOR inspector, void* testData,
|
|||
|
||||
wxString GERBER_DRAW_ITEM::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
{
|
||||
wxString layerName;
|
||||
|
||||
layerName = GERBER_FILE_IMAGE_LIST::GetImagesList().GetDisplayName( GetLayer(), true );
|
||||
wxString layerName = GERBER_FILE_IMAGE_LIST::GetImagesList().GetDisplayName( GetLayer(), true );
|
||||
|
||||
return wxString::Format( _( "%s (D%d) on layer %d: %s" ),
|
||||
ShowGBRShape(),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2016 <Jean-Pierre Charras>
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -75,10 +75,7 @@ public:
|
|||
*/
|
||||
int GetLayer() const;
|
||||
|
||||
bool GetLayerPolarity() const
|
||||
{
|
||||
return m_LayerNegative;
|
||||
}
|
||||
bool GetLayerPolarity() const { return m_LayerNegative; }
|
||||
|
||||
/**
|
||||
* Return the best size and orientation to display the D_Code on screen.
|
||||
|
@ -106,17 +103,7 @@ public:
|
|||
*/
|
||||
void SetLayerParameters();
|
||||
|
||||
void SetLayerPolarity( bool aNegative)
|
||||
{
|
||||
m_LayerNegative = aNegative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move this object.
|
||||
*
|
||||
* @param aMoveVector the move vector for this object.
|
||||
*/
|
||||
void MoveAB( const VECTOR2I& aMoveVector );
|
||||
void SetLayerPolarity( bool aNegative) { m_LayerNegative = aNegative; }
|
||||
|
||||
/**
|
||||
* Move this object.
|
||||
|
@ -231,7 +218,8 @@ public:
|
|||
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
||||
|
||||
///< @copydoc EDA_ITEM::Visit()
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes ) override;
|
||||
|
||||
///< @copydoc EDA_ITEM::GetSelectMenuText()
|
||||
virtual wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2019 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -84,7 +84,6 @@ GERBER_FILE_IMAGE::GERBER_FILE_IMAGE( int aLayer ) :
|
|||
EDA_ITEM( nullptr, GERBER_IMAGE_T )
|
||||
{
|
||||
m_GraphicLayer = aLayer; // Graphic layer Number
|
||||
m_IsVisible = true; // must be drawn
|
||||
m_PositiveDrawColor = WHITE; // The color used to draw positive items for this image
|
||||
|
||||
m_Selected_Tool = 0;
|
||||
|
@ -99,7 +98,6 @@ GERBER_FILE_IMAGE::GERBER_FILE_IMAGE( int aLayer ) :
|
|||
|
||||
GERBER_FILE_IMAGE::~GERBER_FILE_IMAGE()
|
||||
{
|
||||
|
||||
for( GERBER_DRAW_ITEM* item : GetItems() )
|
||||
delete item;
|
||||
|
||||
|
@ -269,21 +267,6 @@ int GERBER_FILE_IMAGE::GetDcodesCount()
|
|||
}
|
||||
|
||||
|
||||
void GERBER_FILE_IMAGE::InitToolTable()
|
||||
{
|
||||
for( int count = 0; count < TOOLS_MAX_COUNT; count++ )
|
||||
{
|
||||
if( m_Aperture_List[count] == nullptr )
|
||||
continue;
|
||||
|
||||
m_Aperture_List[count]->m_Num_Dcode = count + FIRST_DCODE;
|
||||
m_Aperture_List[count]->Clear_D_CODE_Data();
|
||||
}
|
||||
|
||||
m_aperture_macros.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function StepAndRepeatItem
|
||||
* Gerber format has a command Step an Repeat
|
||||
|
@ -405,38 +388,17 @@ void GERBER_FILE_IMAGE::RemoveAttribute( X2_ATTRIBUTE& aAttribute )
|
|||
}
|
||||
|
||||
|
||||
INSPECT_RESULT GERBER_FILE_IMAGE::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||
INSPECT_RESULT GERBER_FILE_IMAGE::Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes )
|
||||
{
|
||||
KICAD_T stype;
|
||||
INSPECT_RESULT result = INSPECT_RESULT::CONTINUE;
|
||||
const KICAD_T* p = scanTypes;
|
||||
bool done = false;
|
||||
|
||||
while( !done )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
stype = *p;
|
||||
|
||||
switch( stype )
|
||||
if( scanType == GERBER_DRAW_ITEM_T )
|
||||
{
|
||||
case GERBER_IMAGE_T:
|
||||
case GERBER_LAYOUT_T:
|
||||
++p;
|
||||
break;
|
||||
|
||||
case GERBER_DRAW_ITEM_T:
|
||||
result = IterateForward( GetItems(), inspector, testData, p );
|
||||
++p;
|
||||
break;
|
||||
|
||||
case EOT:
|
||||
default: // catch EOT or ANY OTHER type here and return.
|
||||
done = true;
|
||||
break;
|
||||
if( IterateForward( GetItems(), inspector, testData, { scanType } ) == INSPECT_RESULT::QUIT )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
}
|
||||
|
||||
if( result == INSPECT_RESULT::QUIT )
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2010-2019 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -212,8 +212,6 @@ public:
|
|||
m_messagesList.Add( aMessage );
|
||||
}
|
||||
|
||||
void InitToolTable();
|
||||
|
||||
/**
|
||||
* Return the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm).
|
||||
*
|
||||
|
@ -299,7 +297,8 @@ public:
|
|||
void RemoveAttribute( X2_ATTRIBUTE& aAttribute );
|
||||
|
||||
///< @copydoc EDA_ITEM::Visit()
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes ) override;
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
||||
|
@ -356,78 +355,58 @@ private:
|
|||
* @param gerber_file Which file to read from for continuation.
|
||||
* @return true if a macro was read in successfully, else false.
|
||||
*/
|
||||
bool ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
|
||||
char* & text, FILE * gerber_file );
|
||||
bool ReadApertureMacro( char *aBuff, unsigned int aBuffSize, char*& text, FILE* gerber_file );
|
||||
|
||||
// functions to execute G commands or D basic commands:
|
||||
bool Execute_G_Command( char*& text, int G_command );
|
||||
bool Execute_DCODE_Command( char*& text, int D_command );
|
||||
|
||||
public:
|
||||
bool m_InUse; // true if this image is currently in use
|
||||
// (a file is loaded in it)
|
||||
bool m_InUse; ///< true if this image is currently in use (a file
|
||||
///< is loaded in it)
|
||||
///< false if it must be not drawn
|
||||
COLOR4D m_PositiveDrawColor; ///< The color used to draw positive items
|
||||
wxString m_FileName; ///< Full File Name for this layer
|
||||
wxString m_ImageName; ///< Image name, from IN <name>* command
|
||||
|
||||
///< True if the draw layer is visible and must be drawn.
|
||||
bool m_IsVisible;
|
||||
// false if it must be not drawn
|
||||
COLOR4D m_PositiveDrawColor; // The color used to draw positive items
|
||||
wxString m_FileName; // Full File Name for this layer
|
||||
wxString m_ImageName; // Image name, from IN <name>* command
|
||||
bool m_IsX2_file; ///< True if a X2 gerber attribute was found in file
|
||||
X2_ATTRIBUTE_FILEFUNCTION* m_FileFunction; ///< file function parameters, found in a %TF
|
||||
///< command or a G04
|
||||
wxString m_MD5_value; ///< MD5 value found in a %TF.MD5 command
|
||||
wxString m_PartString; ///< string found in a %TF.Part command
|
||||
int m_GraphicLayer; ///< Graphic layer Number
|
||||
bool m_ImageNegative; ///< true = Negative image
|
||||
|
||||
///< True if a X2 gerber attribute was found in file.
|
||||
bool m_IsX2_file;
|
||||
X2_ATTRIBUTE_FILEFUNCTION* m_FileFunction; // file function parameters, found in a
|
||||
// %TF command or a G04
|
||||
wxString m_MD5_value; // MD5 value found in a %TF.MD5 command
|
||||
wxString m_PartString; // string found in a %TF.Part command
|
||||
int m_GraphicLayer; // Graphic layer Number
|
||||
bool m_ImageNegative; // true = Negative image
|
||||
bool m_ImageJustifyXCenter; ///< Image Justify Center on X axis (default = false)
|
||||
bool m_ImageJustifyYCenter; ///< Image Justify Center on Y axis (default = false)
|
||||
VECTOR2I m_ImageJustifyOffset; ///< Image Justify Offset on XY axis (default = 0,0)
|
||||
|
||||
///< Image Justify Center on X axis (default = false).
|
||||
bool m_ImageJustifyXCenter;
|
||||
bool m_GerbMetric; ///< false = Inches, true = metric
|
||||
bool m_Relative; ///< false = absolute Coord, true = relative Coord.
|
||||
bool m_NoTrailingZeros; ///< true: remove tailing zeros.
|
||||
VECTOR2I m_ImageOffset; ///< Coord Offset, from IO command
|
||||
wxSize m_FmtScale; ///< Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4
|
||||
wxSize m_FmtLen; ///< Nb chars per coord. ex fmt 2.3, m_FmtLen = 5
|
||||
|
||||
///< Image Justify Center on Y axis (default = false).
|
||||
bool m_ImageJustifyYCenter;
|
||||
int m_ImageRotation; ///< Image rotation (0, 90, 180, 270 only) in degrees
|
||||
double m_LocalRotation; ///< Local rotation added to m_ImageRotation
|
||||
///< @note This value is stored in 0.1 degrees
|
||||
|
||||
///< Image Justify Offset on XY axis (default = 0,0).
|
||||
VECTOR2I m_ImageJustifyOffset;
|
||||
bool m_GerbMetric; // false = Inches, true = metric
|
||||
|
||||
///< false = absolute Coord, true = relative Coord.
|
||||
bool m_Relative;
|
||||
bool m_NoTrailingZeros; // true: remove tailing zeros.
|
||||
VECTOR2I m_ImageOffset; // Coord Offset, from IO command
|
||||
|
||||
///< Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4.
|
||||
wxSize m_FmtScale;
|
||||
|
||||
///< Nb chars per coord. ex fmt 2.3, m_FmtLen = 5.
|
||||
wxSize m_FmtLen;
|
||||
|
||||
///< Image rotation (0, 90, 180, 270 only) in degrees.
|
||||
int m_ImageRotation;
|
||||
|
||||
///< Local rotation in degrees added to m_ImageRotation.
|
||||
///< @note This value is stored in 0.1 degrees.
|
||||
double m_LocalRotation;
|
||||
VECTOR2I m_Offset; // Coord Offset, from OF command
|
||||
VECTOR2I m_Scale; // scale (X and Y) of layer.
|
||||
bool m_SwapAxis; // false (default) if A = X and B = Y
|
||||
// true if A = Y, B = X
|
||||
bool m_MirrorA; // true: mirror / axis A (X)
|
||||
bool m_MirrorB; // true: mirror / axis B (Y)
|
||||
int m_Iterpolation; // Linear, 90 arc, Circ.
|
||||
int m_Current_Tool; // Current Tool (Dcode) number selected
|
||||
|
||||
///< Current or last pen state (0..9, set by Dn option with n < 10.
|
||||
int m_Last_Pen_Command;
|
||||
int m_CommandState; // state of gerber analysis command.
|
||||
|
||||
///< Line number of the gerber file while reading.
|
||||
int m_LineNum;
|
||||
VECTOR2I m_CurrentPos; // current specified coord for plot
|
||||
VECTOR2I m_PreviousPos; // old current specified coord for plot
|
||||
VECTOR2I m_IJPos; // IJ coord (for arcs & circles )
|
||||
VECTOR2I m_Offset; ///< Coord Offset, from OF command
|
||||
VECTOR2I m_Scale; ///< scale (X and Y) of layer.
|
||||
bool m_SwapAxis; ///< false if A = X and B = Y (default); true if
|
||||
///< A = Y, B = X
|
||||
bool m_MirrorA; ///< true: mirror / axis A (X)
|
||||
bool m_MirrorB; ///< true: mirror / axis B (Y)
|
||||
int m_Iterpolation; ///< Linear, 90 arc, Circ.
|
||||
int m_Current_Tool; ///< Current Tool (Dcode) number selected
|
||||
int m_Last_Pen_Command; ///< Current or last pen state (0..9, set by Dn
|
||||
///< option with n < 10
|
||||
int m_CommandState; ///< state of gerber analysis command
|
||||
int m_LineNum; ///< Line number of the gerber file while reading.
|
||||
VECTOR2I m_CurrentPos; ///< current specified coord for plot
|
||||
VECTOR2I m_PreviousPos; ///< old current specified coord for plot
|
||||
VECTOR2I m_IJPos; ///< IJ coord (for arcs & circles )
|
||||
|
||||
///< True if a IJ coord was read (for arcs & circles ).
|
||||
bool m_LastCoordIsIJPos;
|
||||
|
|
|
@ -223,7 +223,7 @@ bool GERBVIEW_SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere )
|
|||
GERBER_COLLECTOR collector;
|
||||
EDA_ITEM* model = getModel<EDA_ITEM>();
|
||||
|
||||
collector.Collect( model, GERBER_COLLECTOR::AllItems, wxPoint( aWhere.x, aWhere.y ) );
|
||||
collector.Collect( model, { GERBER_LAYOUT_T, GERBER_IMAGE_T, GERBER_DRAW_ITEM_T }, aWhere );
|
||||
|
||||
// Remove unselectable items
|
||||
for( int i = collector.GetCount() - 1; i >= 0; --i )
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2022 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
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
COLLECTOR() :
|
||||
m_Threshold( 0 ),
|
||||
m_MenuCancelled( false ),
|
||||
m_scanTypes( nullptr ),
|
||||
m_scanTypes( {} ),
|
||||
// Inspect() is virtual so calling it from a class common inspector preserves
|
||||
// polymorphism.
|
||||
m_inspector( [=]( EDA_ITEM* aItem, void* aTestData )
|
||||
|
@ -207,13 +207,9 @@ public:
|
|||
/**
|
||||
* Record the list of #KICAD_T types to consider for collection by the Inspect() function.
|
||||
*
|
||||
* @param scanTypes An array of KICAD_T, terminated by EOT. No copy is
|
||||
* is made of this array (so cannot come from caller's stack).
|
||||
* @param aScanTypes A list of KICAD_Ts.
|
||||
*/
|
||||
void SetScanTypes( const KICAD_T* scanTypes )
|
||||
{
|
||||
m_scanTypes = scanTypes;
|
||||
}
|
||||
void SetScanTypes( const std::initializer_list<KICAD_T>& aTypes ) { m_scanTypes = aTypes; }
|
||||
|
||||
void SetRefPos( const VECTOR2I& aRefPos ) { m_refPos = aRefPos; }
|
||||
|
||||
|
@ -247,10 +243,11 @@ protected:
|
|||
std::vector<EDA_ITEM*> m_list; // Primary list of most likely items
|
||||
std::vector<EDA_ITEM*> m_backupList; // Secondary list with items removed by heuristics
|
||||
|
||||
const KICAD_T* m_scanTypes;
|
||||
std::initializer_list<KICAD_T> m_scanTypes;
|
||||
INSPECTOR_FUNC m_inspector;
|
||||
VECTOR2I m_refPos; // Reference position used to generate the collection.
|
||||
EDA_RECT m_refBox; // Selection rectangle used to generate the collection.};
|
||||
|
||||
VECTOR2I m_refPos; // Reference pos used to generate the collection.
|
||||
EDA_RECT m_refBox; // Selection rect used to generate the collection.
|
||||
};
|
||||
|
||||
#endif // COLLECTOR_H
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2013-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2022 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
|
||||
|
@ -190,14 +190,11 @@ public:
|
|||
* @param aScanTypes List of item types
|
||||
* @return true if the item type is contained in the list aScanTypes
|
||||
*/
|
||||
virtual bool IsType( const KICAD_T aScanTypes[] ) const
|
||||
virtual bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const
|
||||
{
|
||||
if( aScanTypes[0] == SCH_LOCATE_ANY_T )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( m_structType == *p )
|
||||
if( scanType == SCH_LOCATE_ANY_T || scanType == m_structType )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -295,33 +292,35 @@ public:
|
|||
* May be re-implemented for each derived class in order to handle all the types given
|
||||
* by its member data.
|
||||
*
|
||||
* Implementations should call inspector->Inspect() on types in scanTypes[], and may use
|
||||
* Implementations should call inspector->Inspect() on types in aScanTypes, and may use
|
||||
* #IterateForward() to do so on lists of such data.
|
||||
*
|
||||
* @param inspector An #INSPECTOR instance to use in the inspection.
|
||||
* @param testData Arbitrary data used by the inspector.
|
||||
* @param scanTypes Which# KICAD_T types are of interest and the order
|
||||
* is significant too, terminated by EOT.
|
||||
* @param aScanTypes Which #KICAD_T types are of interest and the order in which they should
|
||||
* be processed.
|
||||
* @return #SEARCH_RESULT SEARCH_QUIT if the Iterator is to stop the scan,
|
||||
* else #SCAN_CONTINUE, and determined by the inspector.
|
||||
*/
|
||||
virtual INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] );
|
||||
virtual INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes );
|
||||
|
||||
/**
|
||||
* This changes first parameter to avoid the DList and use the main queue instead.
|
||||
*/
|
||||
template< class T >
|
||||
static INSPECT_RESULT IterateForward( std::deque<T>& aList,
|
||||
INSPECTOR inspector,
|
||||
void* testData,
|
||||
const KICAD_T scanTypes[] )
|
||||
static INSPECT_RESULT IterateForward( std::deque<T>& aList, INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& scanTypes )
|
||||
{
|
||||
for( auto it : aList )
|
||||
for( const auto& it : aList )
|
||||
{
|
||||
if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
|
||||
testData,
|
||||
scanTypes ) == INSPECT_RESULT::QUIT )
|
||||
{
|
||||
if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
}
|
||||
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
@ -330,15 +329,19 @@ public:
|
|||
* Change first parameter to avoid the DList and use std::vector instead.
|
||||
*/
|
||||
template <class T>
|
||||
static INSPECT_RESULT IterateForward(
|
||||
std::vector<T>& aList, INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||
static INSPECT_RESULT IterateForward( std::vector<T>& aList, INSPECTOR inspector,
|
||||
void* testData,
|
||||
const std::initializer_list<KICAD_T>& scanTypes )
|
||||
{
|
||||
for( auto it : aList )
|
||||
for( const auto& it : aList )
|
||||
{
|
||||
if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
|
||||
testData,
|
||||
scanTypes ) == INSPECT_RESULT::QUIT )
|
||||
{
|
||||
if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
}
|
||||
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 Joshua Redstone redstone at gmail.com
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -162,7 +162,7 @@ public:
|
|||
|
||||
///< @copydoc EDA_ITEM::Visit
|
||||
INSPECT_RESULT Visit( INSPECTOR aInspector, void* aTestData,
|
||||
const KICAD_T aScanTypes[] ) override;
|
||||
const std::initializer_list<KICAD_T>& aScanTypes ) override;
|
||||
|
||||
///< @copydoc VIEW_ITEM::ViewGetLayers
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 CERN
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -70,55 +70,31 @@ class SELECTION_CONDITIONS
|
|||
public:
|
||||
/**
|
||||
* The default condition function (always returns true).
|
||||
*
|
||||
* @param aSelection is the selection to be tested.
|
||||
* @return Always true.
|
||||
*/
|
||||
static bool ShowAlways( const SELECTION& aSelection )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
static bool ShowAlways( const SELECTION& aSelection ) { return true; }
|
||||
|
||||
/**
|
||||
* Always returns false.
|
||||
*
|
||||
* @param aSelection is the selection to be tested.
|
||||
* @return Always false.
|
||||
*/
|
||||
static bool ShowNever( const SELECTION& aSelection )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
static bool ShowNever( const SELECTION& aSelection ) { return false; }
|
||||
|
||||
/**
|
||||
* Test if there are any items selected.
|
||||
*
|
||||
* @param aSelection is the selection to be tested.
|
||||
* @return True if there is at least one item selected.
|
||||
*/
|
||||
static bool NotEmpty( const SELECTION& aSelection );
|
||||
|
||||
/**
|
||||
* Test if there are no items selected.
|
||||
*
|
||||
* @param aSelection is the selection to be tested.
|
||||
* @return True if there are no items selected.
|
||||
*/
|
||||
static bool Empty( const SELECTION& aSelection );
|
||||
|
||||
/**
|
||||
* Test if there no items selected or being edited.
|
||||
*
|
||||
* @param aSelection is the selection to be tested.
|
||||
* @return True if there are no items being edited or no items selected.
|
||||
*/
|
||||
static bool Idle( const SELECTION& aSelection );
|
||||
|
||||
/**
|
||||
* Test if all selected items are not being edited.
|
||||
*
|
||||
* @param aSelection is the selection to be tested.
|
||||
* @return True if no selected items are being edited.
|
||||
*/
|
||||
static bool IdleSelection( const SELECTION& aSelection );
|
||||
|
||||
|
@ -135,28 +111,18 @@ public:
|
|||
* Create a functor that tests if among the selected items there is at least one of a
|
||||
* given types.
|
||||
*
|
||||
* @param aTypes is an array containing types that are searched. It has to be ended with
|
||||
* #KICAD_T::EOT as end marker.
|
||||
* @param aTypes is an array containing types that are searched.
|
||||
* @return Functor testing for presence of items of a given types.
|
||||
*/
|
||||
static SELECTION_CONDITION HasTypes( const KICAD_T aTypes[] );
|
||||
|
||||
/**
|
||||
* Create a functor that tests if the selected items are *only* of given type.
|
||||
*
|
||||
* @param aType is the type that is searched.
|
||||
* @return Functor testing if selected items are exclusively of one type.
|
||||
*/
|
||||
static SELECTION_CONDITION OnlyType( KICAD_T aType );
|
||||
static SELECTION_CONDITION HasTypes( const std::initializer_list<KICAD_T>& aTypes );
|
||||
|
||||
/**
|
||||
* Create a functor that tests if the selected items are *only* of given types.
|
||||
*
|
||||
* @param aTypes is an array containing types that are searched. It has to be ended with
|
||||
* #KICAD_T::EOT as end marker.
|
||||
* @param aTypes is an array containing types that are searched.
|
||||
* @return Functor testing if selected items are exclusively of the requested types.
|
||||
*/
|
||||
static SELECTION_CONDITION OnlyTypes( const KICAD_T aTypes[] );
|
||||
static SELECTION_CONDITION OnlyTypes( const std::initializer_list<KICAD_T>& aTypes );
|
||||
|
||||
/**
|
||||
* Create a functor that tests if the number of selected items is equal to the value given as
|
||||
|
@ -190,13 +156,12 @@ private:
|
|||
static bool hasTypeFunc( const SELECTION& aSelection, KICAD_T aType );
|
||||
|
||||
///< Helper function used by HasTypes()
|
||||
static bool hasTypesFunc( const SELECTION& aSelection, const KICAD_T aTypes[] );
|
||||
|
||||
///< Helper function used by OnlyType()
|
||||
static bool onlyTypeFunc( const SELECTION& aSelection, KICAD_T aType );
|
||||
static bool hasTypesFunc( const SELECTION& aSelection,
|
||||
const std::initializer_list<KICAD_T>& aTypes );
|
||||
|
||||
///< Helper function used by OnlyTypes()
|
||||
static bool onlyTypesFunc( const SELECTION& aSelection, const KICAD_T aTypes[] );
|
||||
static bool onlyTypesFunc( const SELECTION& aSelection,
|
||||
const std::initializer_list<KICAD_T>& aTypes );
|
||||
|
||||
///< Helper function used by Count()
|
||||
static bool countFunc( const SELECTION& aSelection, int aNumber );
|
||||
|
|
|
@ -148,12 +148,10 @@ void PL_POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
|
|||
|
||||
int PL_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
static KICAD_T pointTypes[] = { WSG_LINE_T, WSG_RECT_T, EOT };
|
||||
|
||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
const PL_SELECTION& selection = m_selectionTool->GetSelection();
|
||||
|
||||
if( selection.Size() != 1 || !selection.Front()->IsType( pointTypes ) )
|
||||
if( selection.Size() != 1 || !selection.Front()->IsType( { WSG_LINE_T, WSG_RECT_T } ) )
|
||||
return 0;
|
||||
|
||||
EDA_ITEM* item = (EDA_ITEM*) selection.Front();
|
||||
|
|
187
pcbnew/board.cpp
187
pcbnew/board.cpp
|
@ -310,63 +310,17 @@ void BOARD::SetPosition( const VECTOR2I& aPos )
|
|||
|
||||
void BOARD::Move( const VECTOR2I& aMoveVector ) // overload
|
||||
{
|
||||
// @todo : anything like this elsewhere? maybe put into GENERAL_COLLECTOR class.
|
||||
static const KICAD_T top_level_board_stuff[] = {
|
||||
PCB_MARKER_T,
|
||||
PCB_BITMAP_T,
|
||||
PCB_TEXT_T,
|
||||
PCB_TEXTBOX_T,
|
||||
PCB_SHAPE_T,
|
||||
PCB_DIM_ALIGNED_T,
|
||||
PCB_DIM_ORTHOGONAL_T,
|
||||
PCB_DIM_CENTER_T,
|
||||
PCB_DIM_RADIAL_T,
|
||||
PCB_DIM_LEADER_T,
|
||||
PCB_TARGET_T,
|
||||
PCB_VIA_T,
|
||||
PCB_TRACE_T,
|
||||
PCB_ARC_T,
|
||||
PCB_FOOTPRINT_T,
|
||||
PCB_ZONE_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData )
|
||||
INSPECTOR_FUNC inspector =
|
||||
[&] ( EDA_ITEM* item, void* testData )
|
||||
{
|
||||
BOARD_ITEM* brd_item = (BOARD_ITEM*) item;
|
||||
|
||||
// aMoveVector was snapshotted, don't need "data".
|
||||
brd_item->Move( aMoveVector );
|
||||
|
||||
static_cast<BOARD_ITEM*>( item )->Move( aMoveVector );
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
};
|
||||
|
||||
Visit( inspector, nullptr, top_level_board_stuff );
|
||||
Visit( inspector, nullptr, GENERAL_COLLECTOR::BoardLevelItems );
|
||||
}
|
||||
|
||||
|
||||
TRACKS BOARD::TracksInNet( int aNetCode )
|
||||
{
|
||||
TRACKS ret;
|
||||
|
||||
INSPECTOR_FUNC inspector = [aNetCode, &ret]( EDA_ITEM* item, void* testData )
|
||||
{
|
||||
PCB_TRACK* t = static_cast<PCB_TRACK*>( item );
|
||||
|
||||
if( t->GetNetCode() == aNetCode )
|
||||
ret.push_back( t );
|
||||
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
};
|
||||
|
||||
// visit this BOARD's PCB_TRACKs and PCB_VIAs with above TRACK INSPECTOR which
|
||||
// appends all in aNetCode to ret.
|
||||
Visit( inspector, nullptr, GENERAL_COLLECTOR::Tracks );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool BOARD::SetLayerDescr( PCB_LAYER_ID aIndex, const LAYER& aLayer )
|
||||
{
|
||||
if( unsigned( aIndex ) < arrayDim( m_layers ) )
|
||||
|
@ -1272,27 +1226,25 @@ void BOARD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>
|
|||
}
|
||||
|
||||
|
||||
INSPECT_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||
INSPECT_RESULT BOARD::Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& scanTypes )
|
||||
{
|
||||
KICAD_T stype;
|
||||
INSPECT_RESULT result = INSPECT_RESULT::CONTINUE;
|
||||
const KICAD_T* p = scanTypes;
|
||||
bool done = false;
|
||||
|
||||
#if 0 && defined(DEBUG)
|
||||
std::cout << GetClass().mb_str() << ' ';
|
||||
#endif
|
||||
|
||||
while( !done )
|
||||
{
|
||||
stype = *p;
|
||||
bool footprintsScanned = false;
|
||||
bool drawingsScanned = false;
|
||||
bool tracksScanned = false;
|
||||
|
||||
switch( stype )
|
||||
for( KICAD_T scanType : scanTypes )
|
||||
{
|
||||
switch( scanType )
|
||||
{
|
||||
case PCB_T:
|
||||
result = inspector( this, testData ); // inspect me
|
||||
// skip over any types handled in the above call.
|
||||
++p;
|
||||
if( inspector( this, testData ) == INSPECT_RESULT::QUIT )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
|
||||
break;
|
||||
|
||||
/*
|
||||
|
@ -1312,33 +1264,15 @@ INSPECT_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T
|
|||
case PCB_FP_DIM_RADIAL_T:
|
||||
case PCB_FP_DIM_ORTHOGONAL_T:
|
||||
case PCB_FP_ZONE_T:
|
||||
|
||||
// this calls FOOTPRINT::Visit() on each footprint.
|
||||
result = IterateForward<FOOTPRINT*>( m_footprints, inspector, testData, p );
|
||||
|
||||
// skip over any types handled in the above call.
|
||||
for( ; ; )
|
||||
if( !footprintsScanned )
|
||||
{
|
||||
switch( stype = *++p )
|
||||
if( IterateForward<FOOTPRINT*>( m_footprints, inspector, testData, scanTypes )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
{
|
||||
case PCB_FOOTPRINT_T:
|
||||
case PCB_PAD_T:
|
||||
case PCB_FP_TEXT_T:
|
||||
case PCB_FP_TEXTBOX_T:
|
||||
case PCB_FP_SHAPE_T:
|
||||
case PCB_FP_DIM_ALIGNED_T:
|
||||
case PCB_FP_DIM_LEADER_T:
|
||||
case PCB_FP_DIM_CENTER_T:
|
||||
case PCB_FP_DIM_RADIAL_T:
|
||||
case PCB_FP_DIM_ORTHOGONAL_T:
|
||||
case PCB_FP_ZONE_T:
|
||||
continue;
|
||||
|
||||
default:
|
||||
;
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
break;
|
||||
footprintsScanned = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1353,84 +1287,68 @@ INSPECT_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T
|
|||
case PCB_DIM_ORTHOGONAL_T:
|
||||
case PCB_DIM_LEADER_T:
|
||||
case PCB_TARGET_T:
|
||||
result = IterateForward<BOARD_ITEM*>( m_drawings, inspector, testData, p );
|
||||
|
||||
// skip over any types handled in the above call.
|
||||
for( ; ; )
|
||||
if( !drawingsScanned )
|
||||
{
|
||||
switch( stype = *++p )
|
||||
if( IterateForward<BOARD_ITEM*>( m_drawings, inspector, testData, scanTypes )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
{
|
||||
case PCB_SHAPE_T:
|
||||
case PCB_BITMAP_T:
|
||||
case PCB_TEXT_T:
|
||||
case PCB_TEXTBOX_T:
|
||||
case PCB_DIM_ALIGNED_T:
|
||||
case PCB_DIM_CENTER_T:
|
||||
case PCB_DIM_RADIAL_T:
|
||||
case PCB_DIM_ORTHOGONAL_T:
|
||||
case PCB_DIM_LEADER_T:
|
||||
case PCB_TARGET_T:
|
||||
continue;
|
||||
|
||||
default:
|
||||
;
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
break;
|
||||
drawingsScanned = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PCB_VIA_T:
|
||||
result = IterateForward<PCB_TRACK*>( m_tracks, inspector, testData, p );
|
||||
++p;
|
||||
break;
|
||||
|
||||
case PCB_TRACE_T:
|
||||
case PCB_ARC_T:
|
||||
result = IterateForward<PCB_TRACK*>( m_tracks, inspector, testData, p );
|
||||
++p;
|
||||
if( !tracksScanned )
|
||||
{
|
||||
if( IterateForward<PCB_TRACK*>( m_tracks, inspector, testData, scanTypes )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
{
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
tracksScanned = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PCB_MARKER_T:
|
||||
for( PCB_MARKER* marker : m_markers )
|
||||
{
|
||||
result = marker->Visit( inspector, testData, p );
|
||||
|
||||
if( result == INSPECT_RESULT::QUIT )
|
||||
break;
|
||||
if( marker->Visit( inspector, testData, { scanType } ) == INSPECT_RESULT::QUIT )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
++p;
|
||||
break;
|
||||
|
||||
case PCB_ZONE_T:
|
||||
for( ZONE* zone : m_zones)
|
||||
{
|
||||
result = zone->Visit( inspector, testData, p );
|
||||
|
||||
if( result == INSPECT_RESULT::QUIT )
|
||||
break;
|
||||
if( zone->Visit( inspector, testData, { scanType } ) == INSPECT_RESULT::QUIT )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
++p;
|
||||
break;
|
||||
|
||||
case PCB_GROUP_T:
|
||||
result = IterateForward<PCB_GROUP*>( m_groups, inspector, testData, p );
|
||||
++p;
|
||||
break;
|
||||
|
||||
default: // catch EOT or ANY OTHER type here and return.
|
||||
done = true;
|
||||
break;
|
||||
if( IterateForward<PCB_GROUP*>( m_groups, inspector, testData, { scanType } )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
{
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
if( result == INSPECT_RESULT::QUIT )
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1982,13 +1900,6 @@ const std::vector<BOARD_CONNECTED_ITEM*> BOARD::AllConnectedItems()
|
|||
}
|
||||
|
||||
|
||||
void BOARD::ClearAllNetCodes()
|
||||
{
|
||||
for( BOARD_CONNECTED_ITEM* item : AllConnectedItems() )
|
||||
item->SetNetCode( 0 );
|
||||
}
|
||||
|
||||
|
||||
void BOARD::MapNets( const BOARD* aDestBoard )
|
||||
{
|
||||
for( BOARD_CONNECTED_ITEM* item : AllConnectedItems() )
|
||||
|
|
|
@ -806,12 +806,12 @@ public:
|
|||
* to do so on lists of such data.
|
||||
* @param inspector An INSPECTOR instance to use in the inspection.
|
||||
* @param testData Arbitrary data used by the inspector.
|
||||
* @param scanTypes Which KICAD_T types are of interest and the order
|
||||
* is significant too, terminated by EOT.
|
||||
* @param scanTypes Which KICAD_T types are of interest and the order to process them in.
|
||||
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE, and
|
||||
* determined by the inspector.
|
||||
*/
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& scanTypes ) override;
|
||||
|
||||
/**
|
||||
* Search for a FOOTPRINT within this board with the given reference designator.
|
||||
|
@ -1010,15 +1010,6 @@ public:
|
|||
*/
|
||||
std::tuple<int, double, double> GetTrackLength( const PCB_TRACK& aTrack ) const;
|
||||
|
||||
/**
|
||||
* Collect all the TRACKs and VIAs that are members of a net given by aNetCode.
|
||||
* Used from python.
|
||||
*
|
||||
* @param aNetCode gives the id of the net.
|
||||
* @return list of track which are in the net identified by @a aNetCode.
|
||||
*/
|
||||
TRACKS TracksInNet( int aNetCode );
|
||||
|
||||
/**
|
||||
* Get a footprint by its bounding rectangle at \a aPosition on \a aLayer.
|
||||
*
|
||||
|
@ -1034,11 +1025,6 @@ public:
|
|||
FOOTPRINT* GetFootprint( const VECTOR2I& aPosition, PCB_LAYER_ID aActiveLayer,
|
||||
bool aVisibleOnly, bool aIgnoreLocked = false ) const;
|
||||
|
||||
/**
|
||||
* Reset all items' netcodes to 0 (no net).
|
||||
*/
|
||||
void ClearAllNetCodes();
|
||||
|
||||
/**
|
||||
* Map all nets in the given board to nets with the same name (if any) in the destination
|
||||
* board. This allows us to share layouts which came from the same hierarchical sheet in
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -37,16 +37,8 @@
|
|||
#include <macros.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
|
||||
/*
|
||||
* This module contains out of line member functions for classes given in
|
||||
* collectors.h. Those classes augment the functionality of class PCB_EDIT_FRAME.
|
||||
*/
|
||||
|
||||
|
||||
const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
|
||||
// there are some restrictions on the order of items in the general case.
|
||||
// all items in m_Drawings for instance should be contiguous.
|
||||
// *** all items in a same list (shown here) must be contiguous ****
|
||||
const std::initializer_list<KICAD_T> GENERAL_COLLECTOR::AllBoardItems = {
|
||||
PCB_MARKER_T, // in m_markers
|
||||
PCB_TEXT_T, // in m_drawings
|
||||
PCB_BITMAP_T, // in m_drawings
|
||||
|
@ -66,12 +58,11 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
|
|||
PCB_FP_TEXTBOX_T, // in footprints
|
||||
PCB_FOOTPRINT_T, // in m_footprints
|
||||
PCB_GROUP_T, // in m_groups
|
||||
PCB_ZONE_T, // in m_zones
|
||||
EOT
|
||||
PCB_ZONE_T // in m_zones
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T GENERAL_COLLECTOR::BoardLevelItems[] = {
|
||||
const std::initializer_list<KICAD_T> GENERAL_COLLECTOR::BoardLevelItems = {
|
||||
PCB_MARKER_T,
|
||||
PCB_BITMAP_T,
|
||||
PCB_TEXT_T,
|
||||
|
@ -88,27 +79,11 @@ const KICAD_T GENERAL_COLLECTOR::BoardLevelItems[] = {
|
|||
PCB_TRACE_T,
|
||||
PCB_FOOTPRINT_T,
|
||||
PCB_GROUP_T,
|
||||
PCB_ZONE_T,
|
||||
EOT
|
||||
PCB_ZONE_T
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T GENERAL_COLLECTOR::Footprints[] = {
|
||||
PCB_FOOTPRINT_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T GENERAL_COLLECTOR::PadsOrTracks[] = {
|
||||
PCB_PAD_T,
|
||||
PCB_VIA_T,
|
||||
PCB_TRACE_T,
|
||||
PCB_ARC_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T GENERAL_COLLECTOR::FootprintItems[] = {
|
||||
const std::initializer_list<KICAD_T> GENERAL_COLLECTOR::FootprintItems = {
|
||||
PCB_FP_TEXT_T,
|
||||
PCB_FP_TEXTBOX_T,
|
||||
PCB_FP_SHAPE_T,
|
||||
|
@ -120,57 +95,15 @@ const KICAD_T GENERAL_COLLECTOR::FootprintItems[] = {
|
|||
PCB_PAD_T,
|
||||
PCB_FP_ZONE_T,
|
||||
PCB_GROUP_T,
|
||||
PCB_BITMAP_T,
|
||||
EOT
|
||||
PCB_BITMAP_T
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T GENERAL_COLLECTOR::Tracks[] = {
|
||||
PCB_TRACE_T,
|
||||
PCB_ARC_T,
|
||||
PCB_VIA_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T GENERAL_COLLECTOR::LockableItems[] = {
|
||||
PCB_FOOTPRINT_T,
|
||||
PCB_GROUP_T, // Can a group be locked?
|
||||
PCB_TRACE_T,
|
||||
PCB_ARC_T,
|
||||
PCB_VIA_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T GENERAL_COLLECTOR::Zones[] = {
|
||||
PCB_ZONE_T,
|
||||
PCB_FP_ZONE_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T GENERAL_COLLECTOR::Dimensions[] = {
|
||||
PCB_DIM_ALIGNED_T,
|
||||
PCB_DIM_LEADER_T,
|
||||
PCB_DIM_ORTHOGONAL_T,
|
||||
PCB_DIM_CENTER_T,
|
||||
PCB_DIM_RADIAL_T,
|
||||
PCB_FP_DIM_ALIGNED_T,
|
||||
PCB_FP_DIM_LEADER_T,
|
||||
PCB_FP_DIM_ORTHOGONAL_T,
|
||||
PCB_FP_DIM_CENTER_T,
|
||||
PCB_FP_DIM_RADIAL_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T GENERAL_COLLECTOR::DraggableItems[] = {
|
||||
const std::initializer_list<KICAD_T> GENERAL_COLLECTOR::DraggableItems = {
|
||||
PCB_TRACE_T,
|
||||
PCB_VIA_T,
|
||||
PCB_FOOTPRINT_T,
|
||||
PCB_ARC_T,
|
||||
EOT
|
||||
PCB_ARC_T
|
||||
};
|
||||
|
||||
|
||||
|
@ -184,7 +117,6 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
PCB_VIA* via = nullptr;
|
||||
PCB_MARKER* marker = nullptr;
|
||||
ZONE* zone = nullptr;
|
||||
PCB_SHAPE* shape = nullptr;
|
||||
PCB_DIMENSION_BASE* dimension = nullptr;
|
||||
|
||||
#if 0 // debugging
|
||||
|
@ -291,7 +223,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
case PCB_TRACE_T:
|
||||
case PCB_ARC_T:
|
||||
if( m_Guide->IgnoreTracks() )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
break;
|
||||
|
||||
|
@ -307,10 +239,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
|
||||
case PCB_TEXT_T:
|
||||
case PCB_TEXTBOX_T:
|
||||
break;
|
||||
|
||||
case PCB_SHAPE_T:
|
||||
shape = static_cast<PCB_SHAPE*>( item );
|
||||
break;
|
||||
|
||||
case PCB_FP_DIM_ALIGNED_T:
|
||||
|
@ -344,14 +273,14 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
FP_TEXT *text = static_cast<FP_TEXT*>( item );
|
||||
|
||||
if( !text->IsVisible() )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
||||
if( m_Guide->IgnoreFPTextOnBack() && IsBackLayer( layer ) )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
if( m_Guide->IgnoreFPTextOnFront() && IsFrontLayer( layer ) )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
/*
|
||||
* The three text types have different criteria: reference and value have their own
|
||||
|
@ -368,19 +297,19 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
{
|
||||
case FP_TEXT::TEXT_is_REFERENCE:
|
||||
if( m_Guide->IgnoreFPReferences() )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
break;
|
||||
|
||||
case FP_TEXT::TEXT_is_VALUE:
|
||||
if( m_Guide->IgnoreFPValues() )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
break;
|
||||
|
||||
case FP_TEXT::TEXT_is_DIVERS:
|
||||
if( !m_Guide->IsLayerVisible( layer ) )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -391,7 +320,6 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
}
|
||||
|
||||
case PCB_FP_SHAPE_T:
|
||||
shape = static_cast<FP_SHAPE*>( item );
|
||||
break;
|
||||
|
||||
case PCB_FOOTPRINT_T:
|
||||
|
@ -415,10 +343,10 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( footprint ) // true from case PCB_PAD_T, PCB_FP_TEXT_T, or PCB_FOOTPRINT_T
|
||||
{
|
||||
if( m_Guide->IgnoreFootprintsOnBack() && ( footprint->GetLayer() == B_Cu ) )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
if( m_Guide->IgnoreFootprintsOnFront() && ( footprint->GetLayer() == F_Cu ) )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
||||
// Pads are not sensitive to the layer visibility controls.
|
||||
|
@ -427,15 +355,15 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( pad )
|
||||
{
|
||||
if( m_Guide->IgnorePads() )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
if( ! pad_through )
|
||||
{
|
||||
if( m_Guide->IgnorePadsOnFront() && pad->IsOnLayer(F_Cu ) )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
if( m_Guide->IgnorePadsOnBack() && pad->IsOnLayer(B_Cu ) )
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,7 +373,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( marker->HitTest( m_refPos ) )
|
||||
Append( item );
|
||||
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
||||
if( group )
|
||||
|
@ -454,7 +382,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( group->HitTest( m_refPos ) )
|
||||
Append( item );
|
||||
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
||||
if( via )
|
||||
|
@ -465,7 +393,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
|| ( m_Guide->IgnoreBlindBuriedVias() && type == VIATYPE::BLIND_BURIED )
|
||||
|| ( m_Guide->IgnoreMicroVias() && type == VIATYPE::MICROVIA ) )
|
||||
{
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,7 +413,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
|| zone->HitTestForEdge( m_refPos, accuracy ) )
|
||||
{
|
||||
Append( item );
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
else if( !m_Guide->IgnoreZoneFills() )
|
||||
{
|
||||
|
@ -495,7 +423,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
&& zone->HitTestFilledArea( layer, m_refPos ) )
|
||||
{
|
||||
Append( item );
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -506,7 +434,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
&& footprint->HitTestAccurate( m_refPos, accuracy ) )
|
||||
{
|
||||
Append( item );
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
else if( pad || via )
|
||||
|
@ -514,7 +442,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( item->HitTest( m_refPos, accuracy ) )
|
||||
{
|
||||
Append( item );
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -533,14 +461,13 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( item->HitTest( m_refPos, accuracy ) )
|
||||
{
|
||||
Append( item );
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( m_Guide->IncludeSecondary()
|
||||
&& ( !item->IsLocked() || !m_Guide->IgnoreLockedItems() ) )
|
||||
if( m_Guide->IncludeSecondary() && ( !item->IsLocked() || !m_Guide->IgnoreLockedItems() ) )
|
||||
{
|
||||
// for now, "secondary" means "tolerate any visible layer". It has no effect on other
|
||||
// criteria, since there is a separate "ignore" control for those in the COLLECTORS_GUIDE
|
||||
|
@ -558,7 +485,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
|| zone->HitTestForEdge( m_refPos, accuracy ) )
|
||||
{
|
||||
Append2nd( item );
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
else if( !m_Guide->IgnoreZoneFills() )
|
||||
{
|
||||
|
@ -568,7 +495,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
&& zone->HitTestFilledArea( layer, m_refPos ) )
|
||||
{
|
||||
Append2nd( item );
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -579,7 +506,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
&& footprint->HitTestAccurate( m_refPos, accuracy ) )
|
||||
{
|
||||
Append2nd( item );
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
else if( pad || via )
|
||||
|
@ -587,7 +514,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( item->HitTest( m_refPos, accuracy ) )
|
||||
{
|
||||
Append2nd( item );
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -606,18 +533,18 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( item->HitTest( m_refPos, accuracy ) )
|
||||
{
|
||||
Append2nd( item );
|
||||
goto exit;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
return INSPECT_RESULT::CONTINUE; // always when collecting
|
||||
}
|
||||
|
||||
|
||||
void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
|
||||
void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes,
|
||||
const VECTOR2I& aRefPos, const COLLECTORS_GUIDE& aGuide )
|
||||
{
|
||||
Empty(); // empty the collection, primary criteria list
|
||||
|
@ -626,7 +553,7 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
|
|||
// remember guide, pass it to Inspect()
|
||||
SetGuide( &aGuide );
|
||||
|
||||
SetScanTypes( aScanList );
|
||||
SetScanTypes( aScanTypes );
|
||||
|
||||
// remember where the snapshot was taken from and pass refPos to
|
||||
// the Inspect() function.
|
||||
|
@ -634,9 +561,6 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
|
|||
|
||||
aItem->Visit( m_inspector, nullptr, m_scanTypes );
|
||||
|
||||
// record the length of the primary list before concatenating on to it.
|
||||
m_PrimaryLength = m_list.size();
|
||||
|
||||
// append 2nd list onto end of the first list
|
||||
for( unsigned i = 0; i<m_List2nd.size(); ++i )
|
||||
Append( m_List2nd[i] );
|
||||
|
@ -647,19 +571,18 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
|
|||
|
||||
INSPECT_RESULT PCB_TYPE_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
||||
{
|
||||
// The Visit() function only visits the testItem if its type was in the
|
||||
// the scanList, so therefore we can collect anything given to us here.
|
||||
// The Visit() function only visits the testItem if its type was in the the scanList,
|
||||
// so therefore we can collect anything given to us here.
|
||||
Append( testItem );
|
||||
|
||||
return INSPECT_RESULT::CONTINUE; // always when collecting
|
||||
}
|
||||
|
||||
|
||||
void PCB_TYPE_COLLECTOR::Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] )
|
||||
void PCB_TYPE_COLLECTOR::Collect( BOARD_ITEM* aBoard, const std::initializer_list<KICAD_T>& aTypes )
|
||||
{
|
||||
Empty(); // empty any existing collection
|
||||
|
||||
aBoard->Visit( m_inspector, nullptr, aScanList );
|
||||
Empty();
|
||||
aBoard->Visit( m_inspector, nullptr, aTypes );
|
||||
}
|
||||
|
||||
|
||||
|
@ -674,9 +597,8 @@ INSPECT_RESULT PCB_LAYER_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData
|
|||
}
|
||||
|
||||
|
||||
void PCB_LAYER_COLLECTOR::Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] )
|
||||
void PCB_LAYER_COLLECTOR::Collect( BOARD_ITEM* aBoard, const std::initializer_list<KICAD_T>& aTypes )
|
||||
{
|
||||
Empty();
|
||||
|
||||
aBoard->Visit( m_inspector, nullptr, aScanList );
|
||||
aBoard->Visit( m_inspector, nullptr, aTypes );
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -25,35 +25,27 @@
|
|||
#ifndef COLLECTORS_H
|
||||
#define COLLECTORS_H
|
||||
|
||||
|
||||
/*
|
||||
* This module contains a number of COLLECTOR implementations which are used
|
||||
* to augment the functionality of class PCB_EDIT_FRAME.
|
||||
*/
|
||||
|
||||
|
||||
#include <collector.h>
|
||||
#include <layer_ids.h> // LAYER_COUNT, layer defs
|
||||
#include <view/view.h>
|
||||
#include <board_item.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* An abstract base class whose derivatives may be passed to a GENERAL_COLLECTOR,
|
||||
* telling GENERAL_COLLECTOR what should be collected (aside from HitTest()ing
|
||||
* and KICAD_T scanTypes[], information which are provided to the GENERAL_COLLECTOR
|
||||
* through attributes or arguments separately).
|
||||
* An abstract base class whose derivatives may be passed to a GENERAL_COLLECTOR telling it what
|
||||
* should be collected (aside from HitTest()ing and KICAD_T scanTypes, which are provided to the
|
||||
* GENERAL_COLLECTOR through attributes or arguments separately).
|
||||
* <p>
|
||||
* A justification for this class is to keep the structural storage details of
|
||||
* the program's "global preferences" or "configuration options" out of
|
||||
* GENERAL_COLLECTOR::Inspect(). This class carries all the necessary details
|
||||
* in with it to the Inspect() call. The constructors or other functions of
|
||||
* this class's derivatives are then the only place where knowledge of the
|
||||
* specific structure of the global preference storage is needed. Thus,
|
||||
* GENERAL_COLLECTOR::Inspect() can be kept as simple as possible, and insulated
|
||||
* from changes in global preference storage (and even then it is
|
||||
* not simple enough).
|
||||
* A justification for this class is to keep the structural storage details of the program's
|
||||
* "configuration options" out of GENERAL_COLLECTOR::Inspect(). This class carries all the
|
||||
* necessary details with it into the Inspect() call. The constructors or other functions of this
|
||||
* class's derivatives are then the only place where knowledge of the specific structure of the
|
||||
* global preference storage is needed. Thus, GENERAL_COLLECTOR::Inspect() can be kept as simple
|
||||
* as possible, and insulated from changes in global preference storage.
|
||||
* </p>
|
||||
* This class introduces the notion of layer locking.
|
||||
*/
|
||||
|
@ -62,19 +54,8 @@ class COLLECTORS_GUIDE
|
|||
public:
|
||||
virtual ~COLLECTORS_GUIDE() {}
|
||||
|
||||
/**
|
||||
* @return true if the given layer is visible, else false.
|
||||
*/
|
||||
virtual bool IsLayerVisible( PCB_LAYER_ID layer ) const = 0;
|
||||
|
||||
/**
|
||||
* @return the preferred layer for HitTest()ing.
|
||||
*/
|
||||
virtual PCB_LAYER_ID GetPreferredLayer() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore locked items, else false.
|
||||
*/
|
||||
virtual bool IgnoreLockedItems() const = 0;
|
||||
|
||||
/**
|
||||
|
@ -89,91 +70,29 @@ public:
|
|||
*/
|
||||
virtual bool IgnoreHiddenFPText() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore footprint text on back layers
|
||||
*/
|
||||
virtual bool IgnoreFPTextOnBack() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore footprint text on front layers.
|
||||
*/
|
||||
virtual bool IgnoreFPTextOnFront() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore FOOTPRINTs on Back Side.
|
||||
*/
|
||||
virtual bool IgnoreFootprintsOnBack() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore FOOTPRINTs on Front Side.
|
||||
*/
|
||||
virtual bool IgnoreFootprintsOnFront() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore Pads on Back Side.
|
||||
*/
|
||||
virtual bool IgnorePadsOnBack() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore PADSs on Front Side.
|
||||
*/
|
||||
virtual bool IgnorePadsOnFront() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore through-hole PADSs.
|
||||
*/
|
||||
virtual bool IgnoreThroughHolePads() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore PADSs on Front side and Back side.
|
||||
*/
|
||||
virtual bool IgnorePads() const
|
||||
{
|
||||
return IgnorePadsOnFront() && IgnorePadsOnBack() && IgnoreThroughHolePads();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if should ignore footprint values.
|
||||
*/
|
||||
virtual bool IgnoreFPValues() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore footprint references.
|
||||
*/
|
||||
virtual bool IgnoreFPReferences() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore through-hole vias
|
||||
*/
|
||||
virtual bool IgnoreThroughVias() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore blind/buried vias
|
||||
*/
|
||||
virtual bool IgnoreBlindBuriedVias() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore micro vias
|
||||
*/
|
||||
virtual bool IgnoreMicroVias() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore tracks
|
||||
*/
|
||||
virtual bool IgnoreTracks() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if should ignore the interiors of zones
|
||||
*/
|
||||
virtual bool IgnoreZoneFills() const = 0;
|
||||
|
||||
virtual double OnePixelInIU() const = 0;
|
||||
|
||||
/**
|
||||
* @return true if Inspect() should use BOARD_ITEM::HitTest()
|
||||
* or false if Inspect() should use BOARD_ITEM::BoundsTest().
|
||||
virtual bool UseHitTesting() const = 0;
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
|
@ -210,10 +129,9 @@ public:
|
|||
* Used when the right click button is pressed, or when the select tool is in effect.
|
||||
* This class can be used by window classes such as PCB_EDIT_FRAME.
|
||||
*
|
||||
* Philosophy: this class knows nothing of the context in which a BOARD is used
|
||||
* and that means it knows nothing about which layers are visible or current,
|
||||
* but can handle those concerns by the SetPreferredLayer() function and the
|
||||
* SetLayerSet() function.
|
||||
* Philosophy: this class knows nothing of the context in which a BOARD is used and that means
|
||||
* it knows nothing about which layers are visible or current, but can handle those concerns by
|
||||
* the SetPreferredLayer() function and the SetLayerSet() function.
|
||||
*/
|
||||
class GENERAL_COLLECTOR : public PCB_COLLECTOR
|
||||
{
|
||||
|
@ -231,69 +149,32 @@ protected:
|
|||
*/
|
||||
const COLLECTORS_GUIDE* m_Guide;
|
||||
|
||||
/**
|
||||
* The number of items that were originally in the primary list before the
|
||||
* m_List2nd was concatenated onto the end of it.
|
||||
*/
|
||||
int m_PrimaryLength;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* A scan list for all editable board items
|
||||
*/
|
||||
static const KICAD_T AllBoardItems[];
|
||||
|
||||
/**
|
||||
* A scan list for zones outlines only
|
||||
*/
|
||||
static const KICAD_T Zones[];
|
||||
static const std::initializer_list<KICAD_T> AllBoardItems;
|
||||
|
||||
/**
|
||||
* A scan list for all primary board items, omitting items which are subordinate to
|
||||
* a FOOTPRINT, such as PAD and FP_TEXT.
|
||||
*/
|
||||
static const KICAD_T BoardLevelItems[];
|
||||
|
||||
/**
|
||||
* A scan list for only FOOTPRINTs
|
||||
*/
|
||||
static const KICAD_T Footprints[];
|
||||
|
||||
/**
|
||||
* A scan list for PADs, TRACKs, or VIAs
|
||||
*/
|
||||
static const KICAD_T PadsOrTracks[];
|
||||
static const std::initializer_list<KICAD_T> BoardLevelItems;
|
||||
|
||||
/**
|
||||
* A scan list for primary footprint items.
|
||||
*/
|
||||
static const KICAD_T FootprintItems[];
|
||||
|
||||
/**
|
||||
* A scan list for only TRACKs
|
||||
*/
|
||||
static const KICAD_T Tracks[];
|
||||
|
||||
/**
|
||||
* A scan list for TRACKs, VIAs, FOOTPRINTs
|
||||
*/
|
||||
static const KICAD_T LockableItems[];
|
||||
|
||||
/**
|
||||
* A scan list for dimensions
|
||||
*/
|
||||
static const KICAD_T Dimensions[];
|
||||
static const std::initializer_list<KICAD_T> FootprintItems;
|
||||
|
||||
/**
|
||||
* A scan list for items that can be dragged
|
||||
*/
|
||||
static const KICAD_T DraggableItems[];
|
||||
static const std::initializer_list<KICAD_T> DraggableItems;
|
||||
|
||||
GENERAL_COLLECTOR()
|
||||
GENERAL_COLLECTOR() :
|
||||
m_Guide( nullptr )
|
||||
{
|
||||
m_Guide = nullptr;
|
||||
m_PrimaryLength = 0;
|
||||
SetScanTypes( AllBoardItems );
|
||||
}
|
||||
|
||||
|
@ -316,20 +197,13 @@ public:
|
|||
|
||||
const COLLECTORS_GUIDE* GetGuide() const { return m_Guide; }
|
||||
|
||||
/**
|
||||
* @return The number of items which met the primary search criteria
|
||||
*/
|
||||
int GetPrimaryCount() { return m_PrimaryLength; }
|
||||
|
||||
/**
|
||||
* The examining function within the INSPECTOR which is passed to the Iterate function.
|
||||
*
|
||||
* Search and collect all the objects which match the test data.
|
||||
*
|
||||
* @param testItem An EDA_ITEM to examine.
|
||||
* @param testData is not used in this class.
|
||||
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
||||
* else SCAN_CONTINUE;
|
||||
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE
|
||||
*/
|
||||
INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
||||
|
||||
|
@ -337,14 +211,13 @@ public:
|
|||
* Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
|
||||
*
|
||||
* @param aItem A BOARD_ITEM to scan, may be a BOARD or FOOTPRINT, or whatever.
|
||||
* @param aScanList A list of KICAD_Ts with a terminating EOT, that specs
|
||||
* what is to be collected and the priority order of the resultant
|
||||
* collection in "m_list".
|
||||
* @param aScanList A list of KICAD_Ts that specs what is to be collected and the priority
|
||||
* order of the resultant collection in "m_list".
|
||||
* @param aRefPos A wxPoint to use in hit-testing.
|
||||
* @param aGuide The COLLECTORS_GUIDE to use in collecting items.
|
||||
*/
|
||||
void Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[], const VECTOR2I& aRefPos,
|
||||
const COLLECTORS_GUIDE& aGuide );
|
||||
void Collect( BOARD_ITEM* aItem, const std::initializer_list<KICAD_T>& aScanList,
|
||||
const VECTOR2I& aRefPos, const COLLECTORS_GUIDE& aGuide );
|
||||
};
|
||||
|
||||
|
||||
|
@ -557,7 +430,7 @@ public:
|
|||
*
|
||||
* @param testItem An EDA_ITEM to examine.
|
||||
* @param testData is not used in this class.
|
||||
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE;
|
||||
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE
|
||||
*/
|
||||
INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
||||
|
||||
|
@ -565,9 +438,9 @@ public:
|
|||
* Collect #BOARD_ITEM objects using this class's Inspector method, which does the collection.
|
||||
*
|
||||
* @param aBoard The BOARD_ITEM to scan.
|
||||
* @param aScanList The KICAD_Ts to gather up.
|
||||
* @param aTypes The KICAD_Ts to gather up.
|
||||
*/
|
||||
void Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] );
|
||||
void Collect( BOARD_ITEM* aBoard, const std::initializer_list<KICAD_T>& aTypes );
|
||||
};
|
||||
|
||||
|
||||
|
@ -581,8 +454,7 @@ class PCB_LAYER_COLLECTOR : public PCB_COLLECTOR
|
|||
public:
|
||||
PCB_LAYER_COLLECTOR( PCB_LAYER_ID aLayerId = UNDEFINED_LAYER ) :
|
||||
m_layer_id( aLayerId )
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
void SetLayerId( PCB_LAYER_ID aLayerId ) { m_layer_id = aLayerId; }
|
||||
|
||||
|
@ -591,8 +463,7 @@ public:
|
|||
*
|
||||
* @param testItem An EDA_ITEM to examine.
|
||||
* @param testData is not used in this class.
|
||||
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
||||
* else SCAN_CONTINUE;
|
||||
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE
|
||||
*/
|
||||
INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
||||
|
||||
|
@ -600,9 +471,9 @@ public:
|
|||
* Test a BOARD_ITEM using this class's Inspector method, which does the collection.
|
||||
*
|
||||
* @param aBoard The BOARD_ITEM to scan.
|
||||
* @param aScanList The KICAD_Ts to gather up.
|
||||
* @param aTypes The KICAD_Ts to gather up.
|
||||
*/
|
||||
void Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] );
|
||||
void Collect( BOARD_ITEM* aBoard, const std::initializer_list<KICAD_T>& aTypes );
|
||||
|
||||
private:
|
||||
PCB_LAYER_ID m_layer_id;
|
||||
|
|
|
@ -291,11 +291,17 @@ void CN_CONNECTIVITY_ALGO::searchConnections()
|
|||
const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUSTER_SEARCH_MODE aMode )
|
||||
{
|
||||
if( aMode == CSM_PROPAGATE )
|
||||
{
|
||||
return SearchClusters( aMode,
|
||||
{ PCB_TRACE_T, PCB_ARC_T, PCB_PAD_T, PCB_VIA_T, PCB_FOOTPRINT_T }, -1 );
|
||||
{ PCB_TRACE_T, PCB_ARC_T, PCB_PAD_T, PCB_VIA_T, PCB_FOOTPRINT_T },
|
||||
-1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
return SearchClusters( aMode,
|
||||
{ PCB_TRACE_T, PCB_ARC_T, PCB_PAD_T, PCB_VIA_T, PCB_ZONE_T, PCB_FOOTPRINT_T }, -1 );
|
||||
{ PCB_TRACE_T, PCB_ARC_T, PCB_PAD_T, PCB_VIA_T, PCB_ZONE_T, PCB_FOOTPRINT_T },
|
||||
-1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -489,7 +489,8 @@ void CONNECTIVITY_DATA::Clear()
|
|||
|
||||
const std::vector<BOARD_CONNECTED_ITEM*>
|
||||
CONNECTIVITY_DATA::GetConnectedItems( const BOARD_CONNECTED_ITEM *aItem,
|
||||
const std::initializer_list<KICAD_T>& aTypes, bool aIgnoreNetcodes ) const
|
||||
const std::initializer_list<KICAD_T>& aTypes,
|
||||
bool aIgnoreNetcodes ) const
|
||||
{
|
||||
std::vector<BOARD_CONNECTED_ITEM*> rv;
|
||||
CN_CONNECTIVITY_ALGO::CLUSTER_SEARCH_MODE searchMode;
|
||||
|
@ -518,21 +519,23 @@ CONNECTIVITY_DATA::GetConnectedItems( const BOARD_CONNECTED_ITEM *aItem,
|
|||
}
|
||||
|
||||
|
||||
const std::vector<BOARD_CONNECTED_ITEM*> CONNECTIVITY_DATA::GetNetItems( int aNetCode,
|
||||
const KICAD_T aTypes[] ) const
|
||||
const std::vector<BOARD_CONNECTED_ITEM*>
|
||||
CONNECTIVITY_DATA::GetNetItems( int aNetCode, const std::initializer_list<KICAD_T>& aTypes ) const
|
||||
{
|
||||
std::vector<BOARD_CONNECTED_ITEM*> items;
|
||||
items.reserve( 32 );
|
||||
|
||||
std::bitset<MAX_STRUCT_TYPE_ID> type_bits;
|
||||
|
||||
for( unsigned int i = 0; aTypes[i] != EOT; ++i )
|
||||
for( KICAD_T scanType : aTypes )
|
||||
{
|
||||
wxASSERT( aTypes[i] < MAX_STRUCT_TYPE_ID );
|
||||
type_bits.set( aTypes[i] );
|
||||
wxASSERT( scanType < MAX_STRUCT_TYPE_ID );
|
||||
type_bits.set( scanType );
|
||||
}
|
||||
|
||||
m_connAlgo->ForEachItem( [&]( CN_ITEM& aItem ) {
|
||||
m_connAlgo->ForEachItem(
|
||||
[&]( CN_ITEM& aItem )
|
||||
{
|
||||
if( aItem.Valid() && ( aItem.Net() == aNetCode ) && type_bits[aItem.Parent()->Type()] )
|
||||
items.push_back( aItem.Parent() );
|
||||
} );
|
||||
|
@ -568,8 +571,8 @@ bool CONNECTIVITY_DATA::CheckConnectivity( std::vector<CN_DISJOINT_NET_ENTRY>& a
|
|||
}
|
||||
|
||||
|
||||
const std::vector<PCB_TRACK*> CONNECTIVITY_DATA::GetConnectedTracks(
|
||||
const BOARD_CONNECTED_ITEM* aItem ) const
|
||||
const std::vector<PCB_TRACK*>
|
||||
CONNECTIVITY_DATA::GetConnectedTracks( const BOARD_CONNECTED_ITEM* aItem ) const
|
||||
{
|
||||
auto& entry = m_connAlgo->ItemEntry( aItem );
|
||||
|
||||
|
@ -584,9 +587,11 @@ const std::vector<PCB_TRACK*> CONNECTIVITY_DATA::GetConnectedTracks(
|
|||
( connected->Parent()->Type() == PCB_TRACE_T ||
|
||||
connected->Parent()->Type() == PCB_VIA_T ||
|
||||
connected->Parent()->Type() == PCB_ARC_T ) )
|
||||
{
|
||||
tracks.insert( static_cast<PCB_TRACK*> ( connected->Parent() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::copy( tracks.begin(), tracks.end(), std::back_inserter( rv ) );
|
||||
return rv;
|
||||
|
@ -814,27 +819,27 @@ bool CONNECTIVITY_DATA::TestTrackEndpointDangling( PCB_TRACK* aTrack, VECTOR2I*
|
|||
}
|
||||
|
||||
|
||||
const std::vector<BOARD_CONNECTED_ITEM*> CONNECTIVITY_DATA::GetConnectedItemsAtAnchor(
|
||||
const BOARD_CONNECTED_ITEM* aItem,
|
||||
const std::vector<BOARD_CONNECTED_ITEM*>
|
||||
CONNECTIVITY_DATA::GetConnectedItemsAtAnchor( const BOARD_CONNECTED_ITEM* aItem,
|
||||
const VECTOR2I& aAnchor,
|
||||
const KICAD_T aTypes[],
|
||||
const std::initializer_list<KICAD_T>& aTypes,
|
||||
const int& aMaxError ) const
|
||||
{
|
||||
auto& entry = m_connAlgo->ItemEntry( aItem );
|
||||
CN_CONNECTIVITY_ALGO::ITEM_MAP_ENTRY& entry = m_connAlgo->ItemEntry( aItem );
|
||||
std::vector<BOARD_CONNECTED_ITEM*> rv;
|
||||
SEG::ecoord maxErrorSq = (SEG::ecoord) aMaxError * aMaxError;
|
||||
SEG::ecoord maxError_sq = (SEG::ecoord) aMaxError * aMaxError;
|
||||
|
||||
for( CN_ITEM* cnItem : entry.GetItems() )
|
||||
{
|
||||
for( CN_ITEM* connected : cnItem->ConnectedItems() )
|
||||
{
|
||||
for( std::shared_ptr<CN_ANCHOR>& anchor : connected->Anchors() )
|
||||
for( const std::shared_ptr<CN_ANCHOR>& anchor : connected->Anchors() )
|
||||
{
|
||||
if( ( anchor->Pos() - aAnchor ).SquaredEuclideanNorm() <= maxErrorSq )
|
||||
if( ( anchor->Pos() - aAnchor ).SquaredEuclideanNorm() <= maxError_sq )
|
||||
{
|
||||
for( int i = 0; aTypes[i] > 0; i++ )
|
||||
for( KICAD_T type : aTypes )
|
||||
{
|
||||
if( connected->Valid() && connected->Parent()->Type() == aTypes[i] )
|
||||
if( connected->Valid() && connected->Parent()->Type() == type )
|
||||
{
|
||||
rv.push_back( connected->Parent() );
|
||||
break;
|
||||
|
|
|
@ -201,8 +201,7 @@ public:
|
|||
*/
|
||||
unsigned int GetUnconnectedCount() const;
|
||||
|
||||
bool IsConnectedOnLayer( const BOARD_CONNECTED_ITEM* aItem,
|
||||
int aLayer,
|
||||
bool IsConnectedOnLayer( const BOARD_CONNECTED_ITEM* aItem, int aLayer,
|
||||
const std::initializer_list<KICAD_T>& aTypes = {},
|
||||
bool aCheckOptionalFlashing = false ) const;
|
||||
|
||||
|
@ -226,10 +225,9 @@ public:
|
|||
* @param aMaxError Maximum distance of the found items' anchors to aAnchor in IU
|
||||
* @return
|
||||
*/
|
||||
const std::vector<BOARD_CONNECTED_ITEM*> GetConnectedItemsAtAnchor(
|
||||
const BOARD_CONNECTED_ITEM* aItem,
|
||||
const VECTOR2I& aAnchor,
|
||||
const KICAD_T aTypes[],
|
||||
const std::vector<BOARD_CONNECTED_ITEM*>
|
||||
GetConnectedItemsAtAnchor( const BOARD_CONNECTED_ITEM* aItem, const VECTOR2I& aAnchor,
|
||||
const std::initializer_list<KICAD_T>& aTypes,
|
||||
const int& aMaxError = 0 ) const;
|
||||
|
||||
void GetUnconnectedEdges( std::vector<CN_EDGE>& aEdges ) const;
|
||||
|
@ -257,10 +255,7 @@ public:
|
|||
const CONNECTIVITY_DATA* aDynamicData,
|
||||
VECTOR2I aInternalOffset = { 0, 0 } );
|
||||
|
||||
const std::vector<RN_DYNAMIC_LINE>& GetDynamicRatsnest() const
|
||||
{
|
||||
return m_dynamicRatsnest;
|
||||
}
|
||||
const std::vector<RN_DYNAMIC_LINE>& GetDynamicRatsnest() const { return m_dynamicRatsnest; }
|
||||
|
||||
/**
|
||||
* Function GetConnectedItems()
|
||||
|
@ -268,8 +263,10 @@ public:
|
|||
* @param aItem is the reference item to find other connected items.
|
||||
* @param aTypes allows one to filter by item types.
|
||||
*/
|
||||
const std::vector<BOARD_CONNECTED_ITEM*> GetConnectedItems( const BOARD_CONNECTED_ITEM* aItem,
|
||||
const std::initializer_list<KICAD_T>& aTypes, bool aIgnoreNetcodes = false ) const;
|
||||
const std::vector<BOARD_CONNECTED_ITEM*>
|
||||
GetConnectedItems( const BOARD_CONNECTED_ITEM* aItem,
|
||||
const std::initializer_list<KICAD_T>& aTypes,
|
||||
bool aIgnoreNetcodes = false ) const;
|
||||
|
||||
/**
|
||||
* Function GetNetItems()
|
||||
|
@ -277,28 +274,19 @@ public:
|
|||
* @param aNetCode is the net code.
|
||||
* @param aTypes allows one to filter by item types.
|
||||
*/
|
||||
const std::vector<BOARD_CONNECTED_ITEM*> GetNetItems( int aNetCode,
|
||||
const KICAD_T aTypes[] ) const;
|
||||
const std::vector<BOARD_CONNECTED_ITEM*>
|
||||
GetNetItems( int aNetCode, const std::initializer_list<KICAD_T>& aTypes ) const;
|
||||
|
||||
void BlockRatsnestItems( const std::vector<BOARD_ITEM*>& aItems );
|
||||
|
||||
std::shared_ptr<CN_CONNECTIVITY_ALGO> GetConnectivityAlgo() const
|
||||
{
|
||||
return m_connAlgo;
|
||||
}
|
||||
std::shared_ptr<CN_CONNECTIVITY_ALGO> GetConnectivityAlgo() const { return m_connAlgo; }
|
||||
|
||||
KISPINLOCK& GetLock()
|
||||
{
|
||||
return m_lock;
|
||||
}
|
||||
KISPINLOCK& GetLock() { return m_lock; }
|
||||
|
||||
void MarkItemNetAsDirty( BOARD_ITEM* aItem );
|
||||
void SetProgressReporter( PROGRESS_REPORTER* aReporter );
|
||||
|
||||
const std::map<int, wxString>& GetNetclassMap() const
|
||||
{
|
||||
return m_netclassMap;
|
||||
}
|
||||
const std::map<int, wxString>& GetNetclassMap() const { return m_netclassMap; }
|
||||
|
||||
void AddExclusion( const KIID& aBoardItemId1, const KIID& aBoardItemId2 );
|
||||
void RemoveExclusion( const KIID& aBoardItemId1, const KIID& aBoardItemId2 );
|
||||
|
@ -312,10 +300,7 @@ public:
|
|||
bool aSkipInternalConnections = false );
|
||||
#endif
|
||||
|
||||
std::shared_ptr<FROM_TO_CACHE> GetFromToCache()
|
||||
{
|
||||
return m_fromToCache;
|
||||
}
|
||||
std::shared_ptr<FROM_TO_CACHE> GetFromToCache() { return m_fromToCache; }
|
||||
|
||||
private:
|
||||
void updateRatsnest();
|
||||
|
|
|
@ -846,8 +846,7 @@ bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, int aE
|
|||
bool success = false;
|
||||
|
||||
// Get all the PCB and FP shapes into 'items', then keep only those on layer == Edge_Cuts.
|
||||
static const KICAD_T scan_graphics[] = { PCB_SHAPE_T, PCB_FP_SHAPE_T, EOT };
|
||||
items.Collect( aBoard, scan_graphics );
|
||||
items.Collect( aBoard, { PCB_SHAPE_T, PCB_FP_SHAPE_T } );
|
||||
|
||||
// Make a working copy of aSegList, because the list is modified during calculations
|
||||
std::vector<PCB_SHAPE*> segList;
|
||||
|
@ -1072,8 +1071,7 @@ bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, in
|
|||
bool success = false;
|
||||
|
||||
// Get all the SHAPEs into 'items', then keep only those on layer == Edge_Cuts.
|
||||
static const KICAD_T scan_graphics[] = { PCB_SHAPE_T, PCB_FP_SHAPE_T, EOT };
|
||||
items.Collect( aBoard, scan_graphics );
|
||||
items.Collect( aBoard, { PCB_SHAPE_T, PCB_FP_SHAPE_T } );
|
||||
|
||||
// Make a working copy of aSegList, because the list is modified during calculations
|
||||
std::vector<PCB_SHAPE*> segList;
|
||||
|
|
|
@ -64,15 +64,12 @@ void PCB_EDIT_FRAME::SetTrackSegmentWidth( PCB_TRACK* aTrackItem,
|
|||
new_drill = GetDesignSettings().GetCurrentViaDrill();
|
||||
}
|
||||
|
||||
// Old versions set a drill value <= 0, when the default netclass it used
|
||||
// but it could be better to set the drill value to the actual value
|
||||
// to avoid issues for existing vias, if the default drill value is modified
|
||||
// in the netclass, and not in current vias.
|
||||
// Old versions set a drill value <= 0, when the default netclass it used but it could
|
||||
// be better to set the drill value to the actual value to avoid issues for existing vias,
|
||||
// if the default drill value is modified in the netclass, and not in current vias.
|
||||
if( via->GetDrill() <= 0 ) // means default netclass drill value used
|
||||
{
|
||||
initial_drill = -1; // Force drill vias re-initialization
|
||||
}
|
||||
}
|
||||
|
||||
if( initial_width != new_width || initial_drill != new_drill )
|
||||
{
|
||||
|
|
|
@ -207,17 +207,11 @@ std::vector<DRILL_LAYER_PAIR> GENDRILL_WRITER_BASE::getUniqueLayerPairs() const
|
|||
{
|
||||
wxASSERT( m_pcb );
|
||||
|
||||
static const KICAD_T interesting_stuff_to_collect[] = {
|
||||
PCB_VIA_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
PCB_TYPE_COLLECTOR vias;
|
||||
|
||||
vias.Collect( m_pcb, interesting_stuff_to_collect );
|
||||
vias.Collect( m_pcb, { PCB_VIA_T } );
|
||||
|
||||
std::set<DRILL_LAYER_PAIR> unique;
|
||||
|
||||
DRILL_LAYER_PAIR layer_pair;
|
||||
|
||||
for( int i = 0; i < vias.GetCount(); ++i )
|
||||
|
@ -229,17 +223,15 @@ std::vector<DRILL_LAYER_PAIR> GENDRILL_WRITER_BASE::getUniqueLayerPairs() const
|
|||
// only make note of blind buried.
|
||||
// thru hole is placed unconditionally as first in fetched list.
|
||||
if( layer_pair != DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
|
||||
{
|
||||
unique.insert( layer_pair );
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<DRILL_LAYER_PAIR> ret;
|
||||
|
||||
ret.emplace_back( F_Cu, B_Cu ); // always first in returned list
|
||||
|
||||
for( std::set<DRILL_LAYER_PAIR>::const_iterator it = unique.begin(); it != unique.end(); ++it )
|
||||
ret.push_back( *it );
|
||||
for( const DRILL_LAYER_PAIR& pair : unique )
|
||||
ret.push_back( pair );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1241,50 +1241,51 @@ void FOOTPRINT::Add3DModel( FP_3DMODEL* a3DModel )
|
|||
|
||||
|
||||
// see footprint.h
|
||||
INSPECT_RESULT FOOTPRINT::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||
INSPECT_RESULT FOOTPRINT::Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes )
|
||||
{
|
||||
KICAD_T stype;
|
||||
INSPECT_RESULT result = INSPECT_RESULT::CONTINUE;
|
||||
const KICAD_T* p = scanTypes;
|
||||
bool done = false;
|
||||
|
||||
#if 0 && defined(DEBUG)
|
||||
std::cout << GetClass().mb_str() << ' ';
|
||||
#endif
|
||||
|
||||
while( !done )
|
||||
{
|
||||
stype = *p;
|
||||
bool drawingsScanned = false;
|
||||
|
||||
switch( stype )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
switch( scanType )
|
||||
{
|
||||
case PCB_FOOTPRINT_T:
|
||||
result = inspector( this, testData ); // inspect me
|
||||
++p;
|
||||
if( inspector( this, testData ) == INSPECT_RESULT::QUIT )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
|
||||
break;
|
||||
|
||||
case PCB_PAD_T:
|
||||
result = IterateForward<PAD*>( m_pads, inspector, testData, p );
|
||||
++p;
|
||||
if( IterateForward<PAD*>( m_pads, inspector, testData, { scanType } )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
{
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PCB_FP_ZONE_T:
|
||||
result = IterateForward<FP_ZONE*>( m_fp_zones, inspector, testData, p );
|
||||
++p;
|
||||
if( IterateForward<FP_ZONE*>( m_fp_zones, inspector, testData, { scanType } )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
{
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PCB_FP_TEXT_T:
|
||||
result = inspector( m_reference, testData );
|
||||
if( inspector( m_reference, testData ) == INSPECT_RESULT::QUIT )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
|
||||
if( result == INSPECT_RESULT::QUIT )
|
||||
break;
|
||||
if( inspector( m_value, testData ) == INSPECT_RESULT::QUIT )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
|
||||
result = inspector( m_value, testData );
|
||||
|
||||
if( result == INSPECT_RESULT::QUIT )
|
||||
break;
|
||||
|
||||
// Intentionally fall through since m_Drawings can hold PCB_FP_SHAPE_T also
|
||||
// Intentionally fall through since m_Drawings can hold PCB_FP_TEXT_T also
|
||||
KI_FALLTHROUGH;
|
||||
|
||||
case PCB_FP_DIM_ALIGNED_T:
|
||||
|
@ -1294,47 +1295,34 @@ INSPECT_RESULT FOOTPRINT::Visit( INSPECTOR inspector, void* testData, const KICA
|
|||
case PCB_FP_DIM_ORTHOGONAL_T:
|
||||
case PCB_FP_SHAPE_T:
|
||||
case PCB_FP_TEXTBOX_T:
|
||||
result = IterateForward<BOARD_ITEM*>( m_drawings, inspector, testData, p );
|
||||
|
||||
// skip over any types handled in the above call.
|
||||
for( ; ; )
|
||||
if( !drawingsScanned )
|
||||
{
|
||||
switch( stype = *++p )
|
||||
if( IterateForward<BOARD_ITEM*>( m_drawings, inspector, testData, aScanTypes )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
{
|
||||
case PCB_FP_TEXT_T:
|
||||
case PCB_FP_TEXTBOX_T:
|
||||
case PCB_FP_SHAPE_T:
|
||||
case PCB_FP_DIM_ALIGNED_T:
|
||||
case PCB_FP_DIM_LEADER_T:
|
||||
case PCB_FP_DIM_CENTER_T:
|
||||
case PCB_FP_DIM_RADIAL_T:
|
||||
case PCB_FP_DIM_ORTHOGONAL_T:
|
||||
continue;
|
||||
|
||||
default:
|
||||
;
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
break;
|
||||
drawingsScanned = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PCB_GROUP_T:
|
||||
result = IterateForward<PCB_GROUP*>( m_fp_groups, inspector, testData, p );
|
||||
++p;
|
||||
if( IterateForward<PCB_GROUP*>( m_fp_groups, inspector, testData, { scanType } )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
{
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if( result == INSPECT_RESULT::QUIT )
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -637,7 +637,8 @@ public:
|
|||
*/
|
||||
void Add3DModel( FP_3DMODEL* a3DModel );
|
||||
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes ) override;
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -50,16 +50,16 @@ public:
|
|||
return aItem && PCB_FP_SHAPE_T == aItem->Type();
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( BOARD_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == PCB_LOCATE_GRAPHIC_T )
|
||||
if( scanType == PCB_LOCATE_GRAPHIC_T )
|
||||
return true;
|
||||
else if( *p == PCB_LOCATE_BOARD_EDGE_T )
|
||||
else if( scanType == PCB_LOCATE_BOARD_EDGE_T )
|
||||
return m_layer == Edge_Cuts;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -64,14 +64,14 @@ public:
|
|||
return aItem && aItem->Type() == PCB_FP_TEXT_T;
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( BOARD_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == PCB_LOCATE_TEXT_T )
|
||||
if( scanType == PCB_LOCATE_TEXT_T )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,14 +50,14 @@ public:
|
|||
return aItem && aItem->Type() == PCB_FP_TEXT_T;
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( BOARD_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == PCB_LOCATE_TEXT_T )
|
||||
if( scanType == PCB_LOCATE_TEXT_T )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,20 +151,14 @@ bool NETINFO_ITEM::Matches( const wxFindReplaceData& aSearchData, void* aAuxData
|
|||
|
||||
const EDA_RECT NETINFO_ITEM::GetBoundingBox() const
|
||||
{
|
||||
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_ZONE_T, PCB_PAD_T, EOT };
|
||||
auto connectivity = GetBoard()->GetConnectivity();
|
||||
std::shared_ptr<CONNECTIVITY_DATA> conn = GetBoard()->GetConnectivity();
|
||||
EDA_RECT bbox;
|
||||
|
||||
std::vector<BOARD_CONNECTED_ITEM*> items = connectivity->GetNetItems( m_netCode, types );
|
||||
EDA_RECT bbox = EDA_RECT( VECTOR2I( 0, 0 ), VECTOR2I( 0, 0 ) );
|
||||
|
||||
if( items.size() >= 1 )
|
||||
{
|
||||
bbox = items.at( 0 )->GetBoundingBox();
|
||||
|
||||
for( BOARD_CONNECTED_ITEM* item : items )
|
||||
for( BOARD_ITEM* item : conn->GetNetItems( m_netCode, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T,
|
||||
PCB_ZONE_T, PCB_PAD_T } ) )
|
||||
{
|
||||
bbox.Merge( item->GetBoundingBox() );
|
||||
}
|
||||
}
|
||||
|
||||
return bbox;
|
||||
}
|
12
pcbnew/pad.h
12
pcbnew/pad.h
|
@ -82,20 +82,20 @@ public:
|
|||
return aItem && PCB_PAD_T == aItem->Type();
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( m_drill.x > 0 && m_drill.y > 0 )
|
||||
if( HasHole() )
|
||||
{
|
||||
if( *p == PCB_LOCATE_HOLE_T )
|
||||
if( scanType == PCB_LOCATE_HOLE_T )
|
||||
return true;
|
||||
else if( *p == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
|
||||
else if( scanType == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
|
||||
return true;
|
||||
else if( *p == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
|
||||
else if( scanType == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,7 +240,16 @@ void PCB_BASE_EDIT_FRAME::unitsChangeRefresh()
|
|||
return INSPECT_RESULT::CONTINUE;
|
||||
};
|
||||
|
||||
board->Visit( inspector, nullptr, GENERAL_COLLECTOR::Dimensions );
|
||||
board->Visit( inspector, nullptr, { PCB_DIM_ALIGNED_T,
|
||||
PCB_DIM_LEADER_T,
|
||||
PCB_DIM_ORTHOGONAL_T,
|
||||
PCB_DIM_CENTER_T,
|
||||
PCB_DIM_RADIAL_T,
|
||||
PCB_FP_DIM_ALIGNED_T,
|
||||
PCB_FP_DIM_LEADER_T,
|
||||
PCB_FP_DIM_ORTHOGONAL_T,
|
||||
PCB_FP_DIM_CENTER_T,
|
||||
PCB_FP_DIM_RADIAL_T } );
|
||||
|
||||
if( selectedItemModified )
|
||||
m_toolManager->PostEvent( EVENTS::SelectedItemsModified );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
|
||||
|
@ -97,14 +97,14 @@ class PCB_DIMENSION_BASE : public BOARD_ITEM
|
|||
public:
|
||||
PCB_DIMENSION_BASE( BOARD_ITEM* aParent, KICAD_T aType = PCB_DIMENSION_T );
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( BOARD_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == PCB_LOCATE_GRAPHIC_T )
|
||||
if( scanType == PCB_LOCATE_GRAPHIC_T )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -773,18 +773,18 @@ void PCB_EDIT_FRAME::setupUIConditions()
|
|||
mgr->SetConditions( PCB_ACTIONS::highlightNetSelection, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
|
||||
mgr->SetConditions( PCB_ACTIONS::selectNet,
|
||||
ENABLE( SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ) );
|
||||
ENABLE( SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::deselectNet,
|
||||
ENABLE( SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ) );
|
||||
ENABLE( SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::selectSameSheet,
|
||||
ENABLE( SELECTION_CONDITIONS::OnlyType( PCB_FOOTPRINT_T ) ) );
|
||||
ENABLE( SELECTION_CONDITIONS::OnlyTypes( { PCB_FOOTPRINT_T } ) ) );
|
||||
|
||||
|
||||
SELECTION_CONDITION singleZoneCond = SELECTION_CONDITIONS::Count( 1 )
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Zones );
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_ZONE_T, PCB_FP_ZONE_T } );
|
||||
|
||||
SELECTION_CONDITION zoneMergeCond = SELECTION_CONDITIONS::MoreThan( 1 )
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Zones );
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_ZONE_T, PCB_FP_ZONE_T } );
|
||||
|
||||
mgr->SetConditions( PCB_ACTIONS::zoneDuplicate, ENABLE( singleZoneCond ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::drawZoneCutout, ENABLE( singleZoneCond ) );
|
||||
|
|
|
@ -233,12 +233,12 @@ const EDA_RECT PCB_GROUP::GetBoundingBox() const
|
|||
}
|
||||
|
||||
|
||||
INSPECT_RESULT PCB_GROUP::Visit( INSPECTOR aInspector, void* aTestData, const KICAD_T aScanTypes[] )
|
||||
INSPECT_RESULT PCB_GROUP::Visit( INSPECTOR aInspector, void* aTestData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes )
|
||||
{
|
||||
for( const KICAD_T* stype = aScanTypes; *stype != EOT; ++stype )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
// If caller wants to inspect my type
|
||||
if( *stype == Type() )
|
||||
if( scanType == Type() )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
|
|
|
@ -57,16 +57,16 @@ public:
|
|||
return wxT( "PCB_SHAPE" );
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( BOARD_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == PCB_LOCATE_GRAPHIC_T )
|
||||
if( scanType == PCB_LOCATE_GRAPHIC_T )
|
||||
return true;
|
||||
else if( *p == PCB_LOCATE_BOARD_EDGE_T )
|
||||
else if( scanType == PCB_LOCATE_BOARD_EDGE_T )
|
||||
return m_layer == Edge_Cuts;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,14 +48,14 @@ public:
|
|||
return aItem && PCB_TEXT_T == aItem->Type();
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( BOARD_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == PCB_LOCATE_TEXT_T )
|
||||
if( scanType == PCB_LOCATE_TEXT_T )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,14 +48,14 @@ public:
|
|||
return aItem && PCB_TEXTBOX_T == aItem->Type();
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( BOARD_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == PCB_LOCATE_TEXT_T )
|
||||
if( scanType == PCB_LOCATE_TEXT_T )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -369,16 +369,17 @@ void PCB_VIA::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
|
|||
|
||||
|
||||
// see class_track.h
|
||||
INSPECT_RESULT PCB_TRACK::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||
INSPECT_RESULT PCB_TRACK::Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes )
|
||||
{
|
||||
KICAD_T stype = *scanTypes;
|
||||
|
||||
// If caller wants to inspect my type
|
||||
if( stype == Type() )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( scanType == Type() )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == inspector( this, testData ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
}
|
||||
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
|
|
@ -173,7 +173,8 @@ public:
|
|||
|
||||
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
||||
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
||||
const std::initializer_list<KICAD_T>& aScanTypes ) override;
|
||||
|
||||
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
||||
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
||||
|
@ -335,18 +336,18 @@ public:
|
|||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
|
||||
{
|
||||
if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( *p == PCB_LOCATE_STDVIA_T && m_viaType == VIATYPE::THROUGH )
|
||||
if( scanType == PCB_LOCATE_STDVIA_T && m_viaType == VIATYPE::THROUGH )
|
||||
return true;
|
||||
else if( *p == PCB_LOCATE_UVIA_T && m_viaType == VIATYPE::MICROVIA )
|
||||
else if( scanType == PCB_LOCATE_UVIA_T && m_viaType == VIATYPE::MICROVIA )
|
||||
return true;
|
||||
else if( *p == PCB_LOCATE_BBVIA_T && m_viaType == VIATYPE::BLIND_BURIED )
|
||||
else if( scanType == PCB_LOCATE_BBVIA_T && m_viaType == VIATYPE::BLIND_BURIED )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,12 +143,6 @@ HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints)
|
|||
except:
|
||||
self.this = this
|
||||
|
||||
# Convert these to lists to keep users from using them to delete
|
||||
# items in the iterable while looping over it
|
||||
def GetFootprints(self): return list(self.Footprints())
|
||||
def GetDrawings(self): return list(self.Drawings())
|
||||
def GetTracks(self): return list(self.Tracks())
|
||||
|
||||
def Save(self,filename):
|
||||
return SaveBoard(filename,self)
|
||||
|
||||
|
|
|
@ -58,9 +58,7 @@ bool ITEM::collideSimple( const ITEM* aOther, const NODE* aNode, bool aDifferent
|
|||
auto checkKeepout =
|
||||
[]( const ZONE* aKeepout, const BOARD_ITEM* aOther )
|
||||
{
|
||||
constexpr KICAD_T TRACK_TYPES[] = { PCB_ARC_T, PCB_TRACE_T, EOT };
|
||||
|
||||
if( aKeepout->GetDoNotAllowTracks() && aOther->IsType( TRACK_TYPES ) )
|
||||
if( aKeepout->GetDoNotAllowTracks() && aOther->IsType( { PCB_ARC_T, PCB_TRACE_T } ) )
|
||||
return true;
|
||||
|
||||
if( aKeepout->GetDoNotAllowVias() && aOther->Type() == PCB_VIA_T )
|
||||
|
|
|
@ -1782,10 +1782,8 @@ bool ROUTER_TOOL::CanInlineDrag( int aDragMode )
|
|||
// DragArcTrack(), so PCB_ARC_T should never occur here.
|
||||
if( item->IsType( GENERAL_COLLECTOR::DraggableItems ) )
|
||||
{
|
||||
static const KICAD_T footprints[] = { PCB_FOOTPRINT_T, EOT };
|
||||
|
||||
// Footprints cannot be dragged freely.
|
||||
if( item->IsType( footprints ) )
|
||||
if( item->IsType( { PCB_FOOTPRINT_T } ) )
|
||||
return !( aDragMode & PNS::DM_FREE_ANGLE );
|
||||
else
|
||||
return true;
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <pcb_edit_frame.h>
|
||||
#include <confirm.h> // DisplayError()
|
||||
#include <gestfich.h> // EDA_FileSelector()
|
||||
#include <trigo.h> // RotatePoint()
|
||||
#include <locale_io.h>
|
||||
#include <macros.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
|
@ -63,23 +62,19 @@
|
|||
using namespace DSN;
|
||||
|
||||
// comment the line #define EXPORT_CUSTOM_PADS_CONVEX_HULL to export CUSTOM pads exact shapes.
|
||||
// Keep in mind shapes can be non convex polygons with holes (linked to outline)
|
||||
// that can create issues.
|
||||
// Shapes can be non convex polygons with holes (linked to outline) that can create issues.
|
||||
// Especially Freerouter does not handle them very well:
|
||||
// - too complex shapes are not accepted, especially shapes with holes (dsn files are not loaded).
|
||||
// - and Freerouter actually uses something like a convex hull of the shape (that works not very
|
||||
// well).
|
||||
// - and Freerouter actually uses something like a convex hull of the shape (that works poorly).
|
||||
// I am guessing non convex polygons with holes linked could create issues with any Router.
|
||||
#define EXPORT_CUSTOM_PADS_CONVEX_HULL
|
||||
|
||||
// Add .1 mil to the requested clearances as a safety margin.
|
||||
// There has been disagreement about interpretation of clearance in the past
|
||||
// between KiCad and Freerouter, so keep this safetyMargin until the
|
||||
// disagreement is resolved and stable. Freerouter seems to be moving
|
||||
// (protected) traces upon loading the DSN file, and even though it seems to sometimes
|
||||
// add its own 0.1 to the clearances, I believe this is happening after
|
||||
// the load process (and moving traces) so I am of the opinion this is
|
||||
// still needed.
|
||||
// Add .1 mil to the requested clearances as a safety margin. There has been disagreement about
|
||||
// interpretation of clearance in the past between KiCad and Freerouter, so keep this safetyMargin
|
||||
// until the disagreement is resolved and stable. Freerouter seems to be moving (protected)
|
||||
// traces upon loading the DSN file, and even though it seems to sometimes add its own 0.1 to the
|
||||
// clearances, I believe this is happening after the load process (and moving traces) so I am of
|
||||
// the opinion this is still needed.
|
||||
static const double safetyMargin = 0.1;
|
||||
|
||||
|
||||
|
@ -102,20 +97,15 @@ bool PCB_EDIT_FRAME::ExportSpecctraFile( const wxString& aFullFilename )
|
|||
errorText = ioe.What();
|
||||
}
|
||||
|
||||
// The two calls to FOOTPRINT::Flip() in ExportBoardToSpecctraFile both set the
|
||||
// modified flag, yet their actions cancel each other out, so it should
|
||||
// be ok to clear the modify flag.
|
||||
// The two calls to FOOTPRINT::Flip() in ExportBoardToSpecctraFile both set the modified flag,
|
||||
// yet their actions cancel each other out, so it should be ok to clear the flag.
|
||||
if( !wasModified )
|
||||
screen->SetContentModified( false );
|
||||
|
||||
if( ok )
|
||||
{
|
||||
SetStatusText( wxString( _( "BOARD exported OK." ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayErrorMessage( this, _( "Unable to export, please fix and try again" ), errorText );
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -145,8 +135,8 @@ void ExportBoardToSpecctraFile( BOARD* aBoard, const wxString& aFullFilename )
|
|||
db.ExportPCB( aFullFilename, true );
|
||||
db.RevertFOOTPRINTs( aBoard );
|
||||
|
||||
// if an exception is thrown by FromBOARD or ExportPCB(), then
|
||||
// ~SPECCTRA_DB() will close the file.
|
||||
// if an exception is thrown by FromBOARD() or ExportPCB(), then ~SPECCTRA_DB() will
|
||||
// close the file.
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
|
@ -158,15 +148,11 @@ void ExportBoardToSpecctraFile( BOARD* aBoard, const wxString& aFullFilename )
|
|||
|
||||
namespace DSN {
|
||||
|
||||
const KICAD_T SPECCTRA_DB::scanPADs[] = { PCB_PAD_T, EOT };
|
||||
|
||||
// "specctra reported units" are what we tell the external router that our
|
||||
// exported lengths are in.
|
||||
|
||||
// "specctra reported units" are what we tell the external router that our exported lengths are in
|
||||
|
||||
/**
|
||||
* Convert a distance from Pcbnew internal units to the reported Specctra DSN units
|
||||
* in floating point format.
|
||||
* Convert a distance from Pcbnew internal units to the reported Specctra DSN units in floating
|
||||
* point format.
|
||||
*/
|
||||
static inline double scale( int kicadDist )
|
||||
{
|
||||
|
@ -305,8 +291,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, PAD* aPad )
|
|||
|
||||
dsnOffset = mapPt( offset );
|
||||
|
||||
// using '(' or ')' would cause padstack name to be quote wrapped,
|
||||
// so use other brackets, and {} locks freerouter.
|
||||
// using () would cause padstack name to be quoted, and {} locks freerouter, so use [].
|
||||
sprintf( offsetTxt, "[%.6g,%.6g]", dsnOffset.x, dsnOffset.y );
|
||||
|
||||
uniqifier += offsetTxt;
|
||||
|
@ -619,7 +604,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
|
|||
PCB_TYPE_COLLECTOR fpItems;
|
||||
|
||||
// get all the FOOTPRINT's pads.
|
||||
fpItems.Collect( aFootprint, scanPADs );
|
||||
fpItems.Collect( aFootprint, { PCB_PAD_T } );
|
||||
|
||||
IMAGE* image = new IMAGE( 0 );
|
||||
|
||||
|
@ -710,10 +695,8 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
|
|||
}
|
||||
}
|
||||
|
||||
static const KICAD_T scanEDGEs[] = { PCB_FP_SHAPE_T, EOT };
|
||||
|
||||
// get all the FOOTPRINT's FP_SHAPEs and convert those to DSN outlines.
|
||||
fpItems.Collect( aFootprint, scanEDGEs );
|
||||
fpItems.Collect( aFootprint, { PCB_FP_SHAPE_T } );
|
||||
|
||||
for( int i = 0; i < fpItems.GetCount(); ++i )
|
||||
{
|
||||
|
@ -1097,28 +1080,19 @@ typedef std::pair<STRINGSET::iterator, bool> STRINGSET_PAIR;
|
|||
|
||||
void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
||||
{
|
||||
PCB_TYPE_COLLECTOR items;
|
||||
|
||||
static const KICAD_T scanMODULEs[] = { PCB_FOOTPRINT_T, EOT };
|
||||
|
||||
std::shared_ptr<NET_SETTINGS>& netSettings = aBoard->GetDesignSettings().m_NetSettings;
|
||||
|
||||
// Not all boards are exportable. Check that all reference Ids are unique.
|
||||
// Unless they are unique, we cannot import the session file which comes
|
||||
// back to us later from the router.
|
||||
// Not all boards are exportable. Check that all reference Ids are unique, or we won't be
|
||||
// able to import the session file which comes back to us later from the router.
|
||||
{
|
||||
items.Collect( aBoard, scanMODULEs );
|
||||
|
||||
STRINGSET refs; // holds footprint reference designators
|
||||
|
||||
for( int i=0; i<items.GetCount(); ++i )
|
||||
for( FOOTPRINT* footprint : aBoard->Footprints() )
|
||||
{
|
||||
FOOTPRINT* footprint = (FOOTPRINT*) items[i];
|
||||
|
||||
if( footprint->GetReference() == wxEmptyString )
|
||||
{
|
||||
THROW_IO_ERROR( wxString::Format(
|
||||
_( "Symbol with value of '%s' has empty reference id." ),
|
||||
THROW_IO_ERROR( wxString::Format( _( "Footprint with value of '%s' has an empty "
|
||||
"reference designator." ),
|
||||
footprint->GetValue() ) );
|
||||
}
|
||||
|
||||
|
@ -1127,8 +1101,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
|
||||
if( !refpair.second ) // insert failed
|
||||
{
|
||||
THROW_IO_ERROR( wxString::Format(
|
||||
_( "Multiple symbols have identical reference IDs of '%s'." ),
|
||||
THROW_IO_ERROR( wxString::Format( _( "Multiple footprints have the reference "
|
||||
"designator '%s'." ),
|
||||
footprint->GetReference() ) );
|
||||
}
|
||||
}
|
||||
|
@ -1139,9 +1113,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
|
||||
//-----<layer_descriptor>-----------------------------------------------
|
||||
{
|
||||
// specctra wants top physical layer first, then going down to the
|
||||
// bottom most physical layer in physical sequence.
|
||||
// @question : why does KiCad not display layers in that order?
|
||||
// Specctra wants top physical layer first, then going down to the bottom most physical
|
||||
// layer in physical sequence.
|
||||
|
||||
buildLayerMaps( aBoard );
|
||||
|
||||
|
@ -1185,9 +1158,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
|
||||
//-----<unit_descriptor> & <resolution_descriptor>--------------------
|
||||
{
|
||||
// tell freerouter to use "tenths of micrometers",
|
||||
// which is 100 nm resolution. Possibly more resolution is possible
|
||||
// in freerouter, but it would need testing.
|
||||
// Tell freerouter to use "tenths of micrometers", which is 100 nm resolution. Possibly
|
||||
// more resolution is possible in freerouter, but it would need testing.
|
||||
|
||||
m_pcb->unit->units = T_um;
|
||||
m_pcb->resolution->units = T_um;
|
||||
|
@ -1196,9 +1168,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
|
||||
//-----<boundary_descriptor>------------------------------------------
|
||||
{
|
||||
// Because fillBOUNDARY() can throw an exception, we link in an
|
||||
// empty boundary so the BOUNDARY does not get lost in the event of
|
||||
// of an exception.
|
||||
// Because fillBOUNDARY() can throw an exception, we link in an empty boundary so the
|
||||
// BOUNDARY does not get lost in the event of of an exception.
|
||||
BOUNDARY* boundary = new BOUNDARY( 0 );
|
||||
|
||||
m_pcb->structure->SetBOUNDARY( boundary );
|
||||
|
@ -1220,14 +1191,12 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
sprintf( rule, "(clearance %.6g)", clearance + safetyMargin );
|
||||
rules.push_back( rule );
|
||||
|
||||
// On a high density board (a board with 4 mil tracks, 4 mil spacing)
|
||||
// a typical solder mask clearance will be 2-3 mils.
|
||||
// This exposes 2 to 3 mils of bare board around each pad, and would
|
||||
// leave only 1 to 2 mils of solder mask between the solder mask's boundary
|
||||
// to the edge of any trace within "clearance" of the pad. So we need at least
|
||||
// 2 mils *extra* clearance for traces which would come near a pad on
|
||||
// a different net. So if the baseline trace to trace clearance was say 4 mils, then
|
||||
// the SMD to trace clearance should be at least 6 mils.
|
||||
// On a high density board (4 mil tracks, 4 mil spacing) a typical solder mask clearance
|
||||
// will be 2-3 mils. This exposes 2 to 3 mils of bare board around each pad, and would
|
||||
// leave only 1 to 2 mils of solder mask between the solder mask's boundary and the edge of
|
||||
// any trace within "clearance" of the pad. So we need at least 2 mils *extra* clearance
|
||||
// for traces which would come near a pad on a different net. So if the baseline trace to
|
||||
// trace clearance was 4 mils, then the SMD to trace clearance should be at least 6 mils.
|
||||
double default_smd = clearance + safetyMargin;
|
||||
|
||||
if( default_smd <= 6.0 )
|
||||
|
@ -1237,9 +1206,9 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
|
||||
rules.push_back( rule );
|
||||
|
||||
// Pad to pad spacing on a single SMT part can be closer than our
|
||||
// clearance, we don't want freerouter complaining about that, so
|
||||
// output a significantly smaller pad to pad clearance to freerouter.
|
||||
// Pad to pad spacing on a single SMT part can be closer than our clearance. We don't want
|
||||
// freerouter complaining about that, so output a significantly smaller pad to pad
|
||||
// clearance to freerouter.
|
||||
clearance = scale( defaultClearance ) / 4;
|
||||
|
||||
sprintf( rule, "(clearance %.6g (type smd_smd))", clearance );
|
||||
|
@ -1251,18 +1220,13 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
{
|
||||
int netlessZones = 0;
|
||||
|
||||
static const KICAD_T scanZONEs[] = { PCB_ZONE_T, EOT };
|
||||
items.Collect( aBoard, scanZONEs );
|
||||
|
||||
for( int i = 0; i < items.GetCount(); ++i )
|
||||
for( ZONE* zone : aBoard->Zones() )
|
||||
{
|
||||
ZONE* item = (ZONE*) items[i];
|
||||
|
||||
if( item->GetIsRuleArea() )
|
||||
if( zone->GetIsRuleArea() )
|
||||
continue;
|
||||
|
||||
// Currently, we export only copper layers
|
||||
if( ! IsCopperLayer( item->GetLayer() ) )
|
||||
if( ! IsCopperLayer( zone->GetLayer() ) )
|
||||
continue;
|
||||
|
||||
COPPER_PLANE* plane = new COPPER_PLANE( m_pcb->structure );
|
||||
|
@ -1272,8 +1236,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
PATH* mainPolygon = new PATH( plane, T_polygon );
|
||||
|
||||
plane->SetShape( mainPolygon );
|
||||
|
||||
plane->name = TO_UTF8( item->GetNetname() );
|
||||
plane->name = TO_UTF8( zone->GetNetname() );
|
||||
|
||||
if( plane->name.size() == 0 )
|
||||
{
|
||||
|
@ -1293,14 +1256,14 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
plane->name = no_net->net_id;
|
||||
}
|
||||
|
||||
mainPolygon->layer_id = m_layerIds[ m_kicadLayer2pcb[ item->GetLayer() ] ];
|
||||
mainPolygon->layer_id = m_layerIds[ m_kicadLayer2pcb[ zone->GetLayer() ] ];
|
||||
|
||||
// Handle the main outlines
|
||||
SHAPE_POLY_SET::ITERATOR iterator;
|
||||
wxPoint startpoint;
|
||||
bool is_first_point = true;
|
||||
|
||||
for( iterator = item->IterateWithHoles(); iterator; iterator++ )
|
||||
for( iterator = zone->IterateWithHoles(); iterator; iterator++ )
|
||||
{
|
||||
wxPoint point( iterator->x, iterator->y );
|
||||
|
||||
|
@ -1333,14 +1296,11 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
{
|
||||
is_first_point = true;
|
||||
window = new WINDOW( plane );
|
||||
|
||||
plane->AddWindow( window );
|
||||
|
||||
cutout = new PATH( window, T_polygon );
|
||||
|
||||
window->SetShape( cutout );
|
||||
|
||||
cutout->layer_id = m_layerIds[ m_kicadLayer2pcb[ item->GetLayer() ] ];
|
||||
cutout->layer_id = m_layerIds[ m_kicadLayer2pcb[ zone->GetLayer() ] ];
|
||||
}
|
||||
|
||||
// If the point in this iteration is the last of the contour, the next iteration
|
||||
|
@ -1369,32 +1329,26 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
|
||||
//-----<zones flagged keepout areas become keepout>--------------------------------
|
||||
{
|
||||
static const KICAD_T scanZONEs[] = { PCB_ZONE_T, EOT };
|
||||
items.Collect( aBoard, scanZONEs );
|
||||
|
||||
for( int i = 0; i < items.GetCount(); ++i )
|
||||
for( ZONE* zone : aBoard->Zones() )
|
||||
{
|
||||
ZONE* item = (ZONE*) items[i];
|
||||
|
||||
if( !item->GetIsRuleArea() )
|
||||
if( !zone->GetIsRuleArea() )
|
||||
continue;
|
||||
|
||||
// keepout areas have a type. types are
|
||||
// T_place_keepout, T_via_keepout, T_wire_keepout,
|
||||
// Keepout areas have a type: T_place_keepout, T_via_keepout, T_wire_keepout,
|
||||
// T_bend_keepout, T_elongate_keepout, T_keepout.
|
||||
// Pcbnew knows only T_keepout, T_via_keepout and T_wire_keepout
|
||||
DSN_T keepout_type;
|
||||
|
||||
if( item->GetDoNotAllowVias() && item->GetDoNotAllowTracks() )
|
||||
if( zone->GetDoNotAllowVias() && zone->GetDoNotAllowTracks() )
|
||||
keepout_type = T_keepout;
|
||||
else if( item->GetDoNotAllowVias() )
|
||||
else if( zone->GetDoNotAllowVias() )
|
||||
keepout_type = T_via_keepout;
|
||||
else if( item->GetDoNotAllowTracks() )
|
||||
else if( zone->GetDoNotAllowTracks() )
|
||||
keepout_type = T_wire_keepout;
|
||||
else
|
||||
keepout_type = T_keepout;
|
||||
|
||||
// Now, build keepout polygon on each copper layer where the item
|
||||
// Now, build keepout polygon on each copper layer where the zone
|
||||
// keepout is living (keepout zones can live on many copper layers)
|
||||
const int copperCount = aBoard->GetCopperLayerCount();
|
||||
|
||||
|
@ -1403,7 +1357,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
if( layer == copperCount - 1 )
|
||||
layer = B_Cu;
|
||||
|
||||
if( !item->IsOnLayer( PCB_LAYER_ID( layer ) ) )
|
||||
if( !zone->IsOnLayer( PCB_LAYER_ID( layer ) ) )
|
||||
continue;
|
||||
|
||||
KEEPOUT* keepout = new KEEPOUT( m_pcb->structure, keepout_type );
|
||||
|
@ -1419,7 +1373,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
bool is_first_point = true;
|
||||
wxPoint startpoint;
|
||||
|
||||
for( iterator = item->IterateWithHoles(); iterator; iterator++ )
|
||||
for( iterator = zone->IterateWithHoles(); iterator; iterator++ )
|
||||
{
|
||||
wxPoint point( iterator->x, iterator->y );
|
||||
|
||||
|
@ -1454,10 +1408,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
keepout->AddWindow( window );
|
||||
|
||||
cutout = new PATH( window, T_polygon );
|
||||
|
||||
window->SetShape( cutout );
|
||||
|
||||
cutout->layer_id = m_layerIds[ m_kicadLayer2pcb[ item->GetLayer() ] ];
|
||||
cutout->layer_id = m_layerIds[ m_kicadLayer2pcb[ zone->GetLayer() ] ];
|
||||
}
|
||||
|
||||
isStartContour = iterator.IsEndContour();
|
||||
|
@ -1486,13 +1438,11 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
//-----<build the images, components, and netlist>-----------------------
|
||||
{
|
||||
PIN_REF empty( m_pcb->network );
|
||||
|
||||
std::string componentId;
|
||||
|
||||
// find the highest numbered netCode within the board.
|
||||
int highestNetCode = 0;
|
||||
NETINFO_LIST& netInfo = aBoard->GetNetInfo();
|
||||
|
||||
// find the highest numbered netCode within the board.
|
||||
for( NETINFO_LIST::iterator i = netInfo.begin(); i != netInfo.end(); ++i )
|
||||
highestNetCode = std::max( highestNetCode, i->GetNetCode() );
|
||||
|
||||
|
@ -1510,30 +1460,23 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
m_nets[i->GetNetCode()]->net_id = TO_UTF8( i->GetNetname() );
|
||||
}
|
||||
|
||||
items.Collect( aBoard, scanMODULEs );
|
||||
|
||||
m_padstackset.clear();
|
||||
|
||||
for( int m = 0; m < items.GetCount(); ++m )
|
||||
for( FOOTPRINT* footprint : aBoard->Footprints() )
|
||||
{
|
||||
FOOTPRINT* footprint = (FOOTPRINT*) items[m];
|
||||
|
||||
IMAGE* image = makeIMAGE( aBoard, footprint );
|
||||
|
||||
componentId = TO_UTF8( footprint->GetReference() );
|
||||
|
||||
// create a net list entry for all the actual pins in the image
|
||||
// for the current footprint. location of this code is critical
|
||||
// because we fabricated some pin names to ensure unique-ness
|
||||
// of pin names within a footprint, do not move this code because
|
||||
// the life of this 'IMAGE* image' is not necessarily long. The
|
||||
// exported netlist will have some fabricated pin names in it.
|
||||
// If you don't like fabricated pin names, then make sure all pads
|
||||
// within your FOOTPRINTs are uniquely named!
|
||||
// Create a net list entry for all the actual pins in the current footprint.
|
||||
// Location of this code is critical because we fabricated some pin names to ensure
|
||||
// unique-ness within a footprint, and the life of this 'IMAGE* image' is not
|
||||
// necessarily long. The exported netlist will have some fabricated pin names in it.
|
||||
// If you don't like fabricated pin names, then make sure all pads within your
|
||||
// FOOTPRINTs are uniquely named!
|
||||
for( unsigned p = 0; p < image->pins.size(); ++p )
|
||||
{
|
||||
PIN* pin = &image->pins[p];
|
||||
|
||||
int netcode = pin->kiNetCode;
|
||||
|
||||
if( netcode > 0 )
|
||||
|
@ -1560,7 +1503,6 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
}
|
||||
|
||||
COMPONENT* comp = m_pcb->placement->LookupCOMPONENT( image->GetImageId() );
|
||||
|
||||
PLACE* place = new PLACE( comp );
|
||||
|
||||
comp->places.push_back( place );
|
||||
|
@ -1611,7 +1553,6 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
// This is in lieu of either having each netclass via have its own layer pair in
|
||||
// the netclass dialog, or such control in the specctra export dialog.
|
||||
|
||||
|
||||
m_top_via_layer = 0; // first specctra cu layer is number zero.
|
||||
m_bot_via_layer = aBoard->GetCopperLayerCount()-1;
|
||||
|
||||
|
@ -1647,12 +1588,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
|
||||
//-----<create the wires from tracks>-----------------------------------
|
||||
{
|
||||
// export all of them for now, later we'll decide what controls we need
|
||||
// on this.
|
||||
static const KICAD_T scanTRACKs[] = { PCB_TRACE_T, PCB_ARC_T, EOT };
|
||||
|
||||
items.Collect( aBoard, scanTRACKs );
|
||||
|
||||
// export all of them for now, later we'll decide what controls we need on this.
|
||||
std::string netname;
|
||||
WIRING* wiring = m_pcb->wiring;
|
||||
PATH* path = 0;
|
||||
|
@ -1661,17 +1597,20 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
int old_width = -1;
|
||||
int old_layer = UNDEFINED_LAYER;
|
||||
|
||||
for( int i = 0; i < items.GetCount(); ++i )
|
||||
for( PCB_TRACK* track : aBoard->Tracks() )
|
||||
{
|
||||
PCB_TRACK* track = static_cast<PCB_TRACK*>( items[i] );
|
||||
if( !track->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
|
||||
continue;
|
||||
|
||||
int netcode = track->GetNetCode();
|
||||
|
||||
if( netcode == 0 )
|
||||
continue;
|
||||
|
||||
if( old_netcode != netcode || old_width != track->GetWidth() ||
|
||||
old_layer != track->GetLayer() ||
|
||||
( path && path->points.back() != mapPt(track->GetStart() ) ) )
|
||||
if( old_netcode != netcode
|
||||
|| old_width != track->GetWidth()
|
||||
|| old_layer != track->GetLayer()
|
||||
|| ( path && path->points.back() != mapPt( track->GetStart() ) ) )
|
||||
{
|
||||
old_width = track->GetWidth();
|
||||
old_layer = track->GetLayer();
|
||||
|
@ -1698,12 +1637,9 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
int pcbLayer = m_kicadLayer2pcb[kiLayer];
|
||||
|
||||
path = new PATH( wire );
|
||||
|
||||
wire->SetShape( path );
|
||||
|
||||
path->layer_id = m_layerIds[pcbLayer];
|
||||
path->aperture_width = scale( old_width );
|
||||
|
||||
path->AppendPoint( mapPt( track->GetStart() ) );
|
||||
}
|
||||
|
||||
|
@ -1715,15 +1651,12 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
//-----<export the existing real BOARD instantiated vias>-----------------
|
||||
{
|
||||
// Export all vias, once per unique size and drill diameter combo.
|
||||
static const KICAD_T scanVIAs[] = { PCB_VIA_T, EOT };
|
||||
|
||||
items.Collect( aBoard, scanVIAs );
|
||||
|
||||
for( int i = 0; i<items.GetCount(); ++i )
|
||||
for( PCB_TRACK* track : aBoard->Tracks() )
|
||||
{
|
||||
PCB_VIA* via = static_cast<PCB_VIA*>( items[i] );
|
||||
wxASSERT( via->Type() == PCB_VIA_T );
|
||||
if( track->Type() != PCB_VIA_T )
|
||||
continue;
|
||||
|
||||
PCB_VIA* via = static_cast<PCB_VIA*>( track );
|
||||
int netcode = via->GetNetCode();
|
||||
|
||||
if( netcode == 0 )
|
||||
|
@ -1735,9 +1668,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
// if the one looked up is not our padstack, then delete our padstack
|
||||
// since it was a duplicate of one already registered.
|
||||
if( padstack != registered )
|
||||
{
|
||||
delete padstack;
|
||||
}
|
||||
|
||||
WIRE_VIA* dsnVia = new WIRE_VIA( m_pcb->wiring );
|
||||
|
||||
|
@ -1760,19 +1691,17 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
|
||||
//-----<via_descriptor>-------------------------------------------------
|
||||
{
|
||||
// The pcb->library will output <padstack_descriptors> which is a combined
|
||||
// list of part padstacks and via padstacks. specctra dsn uses the
|
||||
// <via_descriptors> to say which of those padstacks are vias.
|
||||
// The pcb->library will output <padstack_descriptors> which is a combined list of part
|
||||
// padstacks and via padstacks. specctra dsn uses the <via_descriptors> to say which of
|
||||
// those padstacks are vias.
|
||||
|
||||
// Output the vias in the padstack list here, by name only. This must
|
||||
// be done after exporting existing vias as WIRE_VIAs.
|
||||
// Output the vias in the padstack list here, by name only. This must be done after
|
||||
// exporting existing vias as WIRE_VIAs.
|
||||
VIA* vias = m_pcb->structure->via;
|
||||
|
||||
for( unsigned viaNdx = 0; viaNdx < m_pcb->library->vias.size(); ++viaNdx )
|
||||
{
|
||||
vias->AppendVia( m_pcb->library->vias[viaNdx].padstack_id.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
//-----<output NETCLASSs>----------------------------------------------------
|
||||
|
||||
|
|
|
@ -52,13 +52,11 @@ using namespace DSN;
|
|||
|
||||
bool PCB_EDIT_FRAME::ImportSpecctraSession( const wxString& fullFileName )
|
||||
{
|
||||
// To avoid issues with undo/redo lists (dangling pointers)
|
||||
// clear the lists
|
||||
// To avoid issues with undo/redo lists (dangling pointers) clear the lists
|
||||
// todo: use undo/redo feature
|
||||
ClearUndoRedoList();
|
||||
|
||||
// Remove existing tracks from view. They will be readded later after loading
|
||||
// new tracks.
|
||||
// Remove existing tracks from view. They will be readded later after loading new tracks.
|
||||
if( GetCanvas() ) // clear view:
|
||||
{
|
||||
for( PCB_TRACK* track : GetBoard()->Tracks() )
|
||||
|
@ -113,8 +111,7 @@ namespace DSN {
|
|||
* Function scale
|
||||
* converts a session file distance to KiCad units of deci-mils.
|
||||
* @param distance The session file length to convert.
|
||||
* @param aResolution The session UNIT_RES which holds the engineering unit
|
||||
* specifier
|
||||
* @param aResolution The session UNIT_RES which holds the engineering unit specifier
|
||||
* @return int - The KiCad length in internal unit
|
||||
*/
|
||||
static int scale( double distance, UNIT_RES* aResolution )
|
||||
|
@ -125,26 +122,14 @@ static int scale( double distance, UNIT_RES* aResolution )
|
|||
switch( aResolution->GetEngUnits() )
|
||||
{
|
||||
default:
|
||||
case T_inch:
|
||||
factor = 25.4e6; // nanometers per inch
|
||||
break;
|
||||
case T_mil:
|
||||
factor = 25.4e3; // nanometers per mil
|
||||
break;
|
||||
case T_cm:
|
||||
factor = 1e7; // nanometers per cm
|
||||
break;
|
||||
case T_mm:
|
||||
factor = 1e6; // nanometers per mm
|
||||
break;
|
||||
case T_um:
|
||||
factor = 1e3; // nanometers per um
|
||||
break;
|
||||
case T_inch: factor = 25.4e6; break; // nanometers per inch
|
||||
case T_mil: factor = 25.4e3; break; // nanometers per mil
|
||||
case T_cm: factor = 1e7; break; // nanometers per cm
|
||||
case T_mm: factor = 1e6; break; // nanometers per mm
|
||||
case T_um: factor = 1e3; break; // nanometers per um
|
||||
}
|
||||
|
||||
int ret = KiROUND( factor * distance / resValue );
|
||||
|
||||
return ret;
|
||||
return KiROUND( factor * distance / resValue );
|
||||
}
|
||||
|
||||
|
||||
|
@ -257,9 +242,12 @@ PCB_VIA* SPECCTRA_DB::makeVIA( WIRE_VIA*aVia, PADSTACK* aPadstack, const POINT&
|
|||
{
|
||||
shape = (SHAPE*) (*aPadstack)[0];
|
||||
DSN_T type = shape->shape->Type();
|
||||
|
||||
if( type != T_circle )
|
||||
THROW_IO_ERROR(
|
||||
wxString::Format( _( "Unsupported via shape: %s" ), GetTokenString( type ) ) );
|
||||
{
|
||||
THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s" ),
|
||||
GetTokenString( type ) ) );
|
||||
}
|
||||
|
||||
CIRCLE* circle = (CIRCLE*) shape->shape;
|
||||
int viaDiam = scale( circle->diameter, m_routeResolution );
|
||||
|
@ -282,9 +270,12 @@ PCB_VIA* SPECCTRA_DB::makeVIA( WIRE_VIA*aVia, PADSTACK* aPadstack, const POINT&
|
|||
{
|
||||
shape = (SHAPE*) (*aPadstack)[i];
|
||||
DSN_T type = shape->shape->Type();
|
||||
|
||||
if( type != T_circle )
|
||||
THROW_IO_ERROR( wxString::Format(
|
||||
_( "Unsupported via shape: %s" ), GetTokenString( type ) ) );
|
||||
{
|
||||
THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s" ),
|
||||
GetTokenString( type ) ) );
|
||||
}
|
||||
|
||||
CIRCLE* circle = (CIRCLE*) shape->shape;
|
||||
|
||||
|
@ -292,8 +283,8 @@ PCB_VIA* SPECCTRA_DB::makeVIA( WIRE_VIA*aVia, PADSTACK* aPadstack, const POINT&
|
|||
if( layerNdx == -1 )
|
||||
{
|
||||
wxString layerName = FROM_UTF8( circle->layer_id.c_str() );
|
||||
THROW_IO_ERROR( wxString::Format(
|
||||
_( "Session file uses invalid layer id \"%s\"" ), layerName ) );
|
||||
THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'" ),
|
||||
layerName ) );
|
||||
}
|
||||
|
||||
if( layerNdx > topLayerNdx )
|
||||
|
@ -312,16 +303,16 @@ PCB_VIA* SPECCTRA_DB::makeVIA( WIRE_VIA*aVia, PADSTACK* aPadstack, const POINT&
|
|||
|
||||
if( ( topLayerNdx == 0 && botLayerNdx == 1 )
|
||||
|| ( topLayerNdx == copperLayerCount-2 && botLayerNdx == copperLayerCount-1 ) )
|
||||
{
|
||||
via->SetViaType( VIATYPE::MICROVIA );
|
||||
}
|
||||
else
|
||||
{
|
||||
via->SetViaType( VIATYPE::BLIND_BURIED );
|
||||
}
|
||||
|
||||
via->SetWidth( viaDiam );
|
||||
|
||||
PCB_LAYER_ID topLayer = m_pcbLayer2kicad[topLayerNdx];
|
||||
PCB_LAYER_ID botLayer = m_pcbLayer2kicad[botLayerNdx];
|
||||
|
||||
via->SetLayerPair( topLayer, botLayer );
|
||||
via->SetLayerPair( m_pcbLayer2kicad[ topLayerNdx ], m_pcbLayer2kicad[ botLayerNdx ] );
|
||||
}
|
||||
|
||||
wxASSERT( via );
|
||||
|
@ -356,8 +347,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
|
|||
if( !m_session->route->library )
|
||||
THROW_IO_ERROR( _("Session file is missing the \"library_out\" section") );
|
||||
|
||||
// delete all the old tracks and vias but save locked tracks/vias
|
||||
// they will be re-added later
|
||||
// delete the old tracks and vias but save locked tracks/vias; they will be re-added later
|
||||
std::vector<PCB_TRACK*> locked;
|
||||
|
||||
while( !aBoard->Tracks().empty() )
|
||||
|
@ -378,9 +368,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
|
|||
// Add locked tracks: because they are exported as Fix tracks, they are not
|
||||
// in .ses file.
|
||||
for( PCB_TRACK* track: locked )
|
||||
{
|
||||
aBoard->Add( track );
|
||||
}
|
||||
|
||||
if( m_session->placement )
|
||||
{
|
||||
|
@ -388,6 +376,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
|
|||
// each COMPONENT, reposition and re-orient each component and put on
|
||||
// correct side of the board.
|
||||
COMPONENTS& components = m_session->placement->components;
|
||||
|
||||
for( COMPONENTS::iterator comp=components.begin(); comp!=components.end(); ++comp )
|
||||
{
|
||||
PLACES& places = comp->places;
|
||||
|
@ -462,14 +451,8 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
|
|||
NETINFO_ITEM* netinfo = aBoard->FindNet( netName );
|
||||
|
||||
if( netinfo )
|
||||
{
|
||||
netoutCode = netinfo->GetNetCode();
|
||||
}
|
||||
else // else netCode remains 0
|
||||
{
|
||||
// int breakhere = 1;
|
||||
}
|
||||
}
|
||||
|
||||
WIRES& wires = net->wires;
|
||||
for( unsigned i = 0; i<wires.size(); ++i )
|
||||
|
@ -479,17 +462,16 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
|
|||
|
||||
if( shape != T_path )
|
||||
{
|
||||
/* shape == T_polygon is expected from freerouter if you have
|
||||
a zone on a non "power" type layer, i.e. a T_signal layer
|
||||
and the design does a round trip back in as session here.
|
||||
We kept our own zones in the BOARD, so ignore this so called
|
||||
'wire'.
|
||||
/*
|
||||
* shape == T_polygon is expected from freerouter if you have a zone on a non-
|
||||
* "power" type layer, i.e. a T_signal layer and the design does a round-trip
|
||||
* back in as session here. We kept our own zones in the BOARD, so ignore this
|
||||
* so called 'wire'.
|
||||
|
||||
wxString netId = FROM_UTF8( wire->net_id.c_str() );
|
||||
THROW_IO_ERROR( wxString::Format( _( "Unsupported wire shape: '%s' for net: '%s'" ),
|
||||
DLEX::GetTokenString(shape).GetData(),
|
||||
netId.GetData()
|
||||
) );
|
||||
netId.GetData() ) );
|
||||
*/
|
||||
}
|
||||
else
|
||||
|
@ -506,6 +488,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
|
|||
|
||||
WIRE_VIAS& wire_vias = net->wire_vias;
|
||||
LIBRARY& library = *m_session->route->library;
|
||||
|
||||
for( unsigned i=0; i<wire_vias.size(); ++i )
|
||||
{
|
||||
int netCode = 0;
|
||||
|
@ -518,8 +501,6 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
|
|||
|
||||
if( netvia )
|
||||
netCode = netvia->GetNetCode();
|
||||
|
||||
// else netCode remains 0
|
||||
}
|
||||
|
||||
WIRE_VIA* wire_via = &wire_vias[i];
|
||||
|
@ -530,16 +511,11 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
|
|||
if( !padstack )
|
||||
{
|
||||
// Dick Feb 29, 2008:
|
||||
// Freerouter has a bug where it will not round trip all vias.
|
||||
// Vias which have a (use_via) element will be round tripped.
|
||||
// Vias which do not, don't come back in in the session library,
|
||||
// even though they may be actually used in the pre-routed,
|
||||
// protected wire_vias. So until that is fixed, create the
|
||||
// padstack from its name as a work around.
|
||||
|
||||
|
||||
// Could use a STRING_FORMATTER here and convert the entire
|
||||
// wire_via to text and put that text into the exception.
|
||||
// Freerouter has a bug where it will not round trip all vias. Vias which have
|
||||
// a (use_via) element will be round tripped. Vias which do not, don't come back
|
||||
// in in the session library, even though they may be actually used in the
|
||||
// pre-routed, protected wire_vias. So until that is fixed, create the padstack
|
||||
// from its name as a work around.
|
||||
wxString psid( FROM_UTF8( wire_via->GetPadstackId().c_str() ) );
|
||||
|
||||
THROW_IO_ERROR( wxString::Format( _( "A wire_via refers to missing padstack '%s'." ),
|
||||
|
|
|
@ -211,7 +211,7 @@ bool BOARD_EDITOR_CONTROL::Init()
|
|||
|
||||
menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
|
||||
|
||||
menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyType( PCB_ZONE_T ), 200 );
|
||||
menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyTypes( { PCB_ZONE_T } ), 200 );
|
||||
}
|
||||
|
||||
DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
|
||||
|
@ -680,16 +680,16 @@ int BOARD_EDITOR_CONTROL::TogglePythonConsole( const TOOL_EVENT& aEvent )
|
|||
int BOARD_EDITOR_CONTROL::TrackWidthInc( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
|
||||
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
|
||||
PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
||||
|
||||
if( m_frame->ToolStackIsEmpty() && SELECTION_CONDITIONS::OnlyTypes( types )( selection ) )
|
||||
if( m_frame->ToolStackIsEmpty()
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
|
||||
{
|
||||
BOARD_COMMIT commit( this );
|
||||
|
||||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
if( item->Type() == PCB_TRACE_T )
|
||||
if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
|
||||
{
|
||||
PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
|
||||
|
||||
|
@ -760,16 +760,16 @@ int BOARD_EDITOR_CONTROL::TrackWidthInc( const TOOL_EVENT& aEvent )
|
|||
int BOARD_EDITOR_CONTROL::TrackWidthDec( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
|
||||
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
|
||||
PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
||||
|
||||
if( m_frame->ToolStackIsEmpty() && SELECTION_CONDITIONS::OnlyTypes( types )( selection ) )
|
||||
if( m_frame->ToolStackIsEmpty()
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
|
||||
{
|
||||
BOARD_COMMIT commit( this );
|
||||
|
||||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
if( item->Type() == PCB_TRACE_T )
|
||||
if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
|
||||
{
|
||||
PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
|
||||
|
||||
|
@ -840,10 +840,10 @@ int BOARD_EDITOR_CONTROL::TrackWidthDec( const TOOL_EVENT& aEvent )
|
|||
int BOARD_EDITOR_CONTROL::ViaSizeInc( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
|
||||
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
|
||||
PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
||||
|
||||
if( m_frame->ToolStackIsEmpty() && SELECTION_CONDITIONS::OnlyTypes( types )( selection ) )
|
||||
if( m_frame->ToolStackIsEmpty()
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
|
||||
{
|
||||
BOARD_COMMIT commit( this );
|
||||
|
||||
|
@ -889,10 +889,10 @@ int BOARD_EDITOR_CONTROL::ViaSizeInc( const TOOL_EVENT& aEvent )
|
|||
int BOARD_EDITOR_CONTROL::ViaSizeDec( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
|
||||
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
|
||||
PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
||||
|
||||
if( m_frame->ToolStackIsEmpty() && SELECTION_CONDITIONS::OnlyTypes( types )( selection ) )
|
||||
if( m_frame->ToolStackIsEmpty()
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
|
||||
{
|
||||
BOARD_COMMIT commit( this );
|
||||
|
||||
|
|
|
@ -79,8 +79,11 @@ bool BOARD_INSPECTION_TOOL::Init()
|
|||
auto netSubMenu = std::make_shared<NET_CONTEXT_MENU>();
|
||||
netSubMenu->SetTool( this );
|
||||
|
||||
static KICAD_T connectedTypes[] = { PCB_TRACE_T, PCB_VIA_T, PCB_ARC_T, PCB_PAD_T, PCB_ZONE_T,
|
||||
EOT };
|
||||
static std::initializer_list<KICAD_T> connectedTypes = { PCB_TRACE_T,
|
||||
PCB_VIA_T,
|
||||
PCB_ARC_T,
|
||||
PCB_PAD_T,
|
||||
PCB_ZONE_T };
|
||||
|
||||
CONDITIONAL_MENU& menu = selectionTool->GetToolMenu().GetMenu();
|
||||
|
||||
|
@ -1342,10 +1345,11 @@ int BOARD_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent )
|
|||
guide.SetPreferredLayer( activeLayer );
|
||||
|
||||
GENERAL_COLLECTOR collector;
|
||||
collector.Collect( board, GENERAL_COLLECTOR::PadsOrTracks, aPosition, guide );
|
||||
collector.Collect( board, { PCB_PAD_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T }, aPosition,
|
||||
guide );
|
||||
|
||||
if( collector.GetCount() == 0 )
|
||||
collector.Collect( board, GENERAL_COLLECTOR::Zones, aPosition, guide );
|
||||
collector.Collect( board, { PCB_ZONE_T, PCB_FP_ZONE_T }, aPosition, guide );
|
||||
|
||||
// Apply the active selection filter, except we want to allow picking locked items for
|
||||
// highlighting even if the user has disabled them for selection
|
||||
|
|
|
@ -150,27 +150,22 @@ bool CONVERT_TOOL::Init()
|
|||
m_menu->SetIcon( BITMAPS::convert );
|
||||
m_menu->SetTitle( _( "Create from Selection" ) );
|
||||
|
||||
static KICAD_T convertibleTracks[] = { PCB_TRACE_T, PCB_ARC_T, EOT };
|
||||
static KICAD_T zones[] = { PCB_ZONE_T, PCB_FP_ZONE_T, EOT };
|
||||
|
||||
auto graphicLines = P_S_C::OnlyGraphicShapeTypes( { SHAPE_T::SEGMENT,
|
||||
SHAPE_T::RECT,
|
||||
SHAPE_T::CIRCLE,
|
||||
SHAPE_T::ARC } )
|
||||
auto graphicLines = P_S_C::OnlyGraphicShapeTypes( { SHAPE_T::SEGMENT, SHAPE_T::RECT,
|
||||
SHAPE_T::CIRCLE, SHAPE_T::ARC } )
|
||||
&& P_S_C::SameLayer();
|
||||
|
||||
auto graphicToTrack = P_S_C::OnlyGraphicShapeTypes( { SHAPE_T::SEGMENT, SHAPE_T::ARC } );
|
||||
|
||||
auto trackLines = S_C::MoreThan( 1 ) && S_C::OnlyTypes( convertibleTracks )
|
||||
auto trackLines = S_C::MoreThan( 1 ) && S_C::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T } )
|
||||
&& P_S_C::SameLayer();
|
||||
|
||||
auto anyLines = graphicLines || trackLines;
|
||||
auto anyPolys = S_C::OnlyTypes( zones )
|
||||
auto anyPolys = S_C::OnlyTypes( { PCB_ZONE_T, PCB_FP_ZONE_T } )
|
||||
|| P_S_C::OnlyGraphicShapeTypes( { SHAPE_T::POLY, SHAPE_T::RECT } );
|
||||
|
||||
auto lineToArc = S_C::Count( 1 )
|
||||
&& ( P_S_C::OnlyGraphicShapeTypes( { SHAPE_T::SEGMENT } )
|
||||
|| S_C::OnlyType( PCB_TRACE_T ) );
|
||||
|| S_C::OnlyTypes( { PCB_TRACE_T } ) );
|
||||
|
||||
auto showConvert = anyPolys || anyLines || lineToArc;
|
||||
auto canCreatePolyType = anyLines || anyPolys;
|
||||
|
|
|
@ -100,7 +100,6 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
|
|||
|
||||
for( const PCB_TEXT* cell : col )
|
||||
{
|
||||
|
||||
if( j >= nbRows )
|
||||
break;
|
||||
|
||||
|
@ -109,7 +108,6 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
|
|||
rowHeight[j] = rowHeight[j] > height ? rowHeight[j] : height;
|
||||
colWidth[i] = colWidth[i] > width ? colWidth[i] : width;
|
||||
j++;
|
||||
|
||||
}
|
||||
|
||||
i++;
|
||||
|
@ -132,20 +130,16 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
|
|||
{
|
||||
line = new PCB_SHAPE;
|
||||
line->SetLayer( aLayer );
|
||||
line->SetStartX( origin.x );
|
||||
line->SetStartY( y );
|
||||
line->SetEndX( origin.x + width );
|
||||
line->SetEndY( y );
|
||||
line->SetStart( VECTOR2I( origin.x, y ) );
|
||||
line->SetEnd( VECTOR2I( origin.x + width, y ) );
|
||||
y += rowHeight[i];
|
||||
table.push_back( line );
|
||||
}
|
||||
|
||||
line = new PCB_SHAPE;
|
||||
line->SetLayer( aLayer );
|
||||
line->SetStartX( origin.x );
|
||||
line->SetStartY( y );
|
||||
line->SetEndX( origin.x + width );
|
||||
line->SetEndY( y );
|
||||
line->SetStart( VECTOR2I( origin.x, y ) );
|
||||
line->SetEnd( VECTOR2I( origin.x + width, y ) );
|
||||
table.push_back( line );
|
||||
int x = origin.x;
|
||||
|
||||
|
@ -153,20 +147,16 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
|
|||
{
|
||||
line = new PCB_SHAPE;
|
||||
line->SetLayer( aLayer );
|
||||
line->SetStartX( x );
|
||||
line->SetStartY( origin.y );
|
||||
line->SetEndX( x );
|
||||
line->SetEndY( origin.y + height );
|
||||
line->SetStart( VECTOR2I( x, origin.y ) );
|
||||
line->SetEnd( VECTOR2I( x, origin.y + height ) );
|
||||
x += colWidth[i];
|
||||
table.push_back( line );
|
||||
}
|
||||
|
||||
line = new PCB_SHAPE;
|
||||
line->SetLayer( aLayer );
|
||||
line->SetStartX( x );
|
||||
line->SetStartY( origin.y );
|
||||
line->SetEndX( x );
|
||||
line->SetEndY( origin.y + height );
|
||||
line->SetStart( VECTOR2I( x, origin.y ) );
|
||||
line->SetEnd( VECTOR2I( x, origin.y + height ) );
|
||||
table.push_back( line );
|
||||
}
|
||||
|
||||
|
@ -198,6 +188,7 @@ static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*
|
|||
pos.x = pos.x + colWidth[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
|
@ -536,7 +527,7 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics( const VECTOR2I&
|
|||
|
||||
if( aDrawNow )
|
||||
{
|
||||
for( auto item : objects )
|
||||
for( BOARD_ITEM* item : objects )
|
||||
commit.Add( item );
|
||||
|
||||
commit.Push( wxT( "Board Characteristics" ) );
|
||||
|
@ -700,17 +691,16 @@ int DRAWING_TOOL::PlaceCharacteristics( const TOOL_EVENT& aEvent )
|
|||
VECTOR2I tableSize;
|
||||
|
||||
LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() );
|
||||
layerSet = static_cast<LSET>( layerSet.set( Edge_Cuts ).set( Margin ) );
|
||||
layerSet = static_cast<LSET>( layerSet.reset( F_Fab ).reset( B_Fab ) );
|
||||
layerSet = layerSet.set( Edge_Cuts ).set( Margin );
|
||||
layerSet = layerSet.reset( F_Fab ).reset( B_Fab );
|
||||
|
||||
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
|
||||
|
||||
if( ( layerSet & LSET( layer ) ).count() ) // if layer is a forbidden layer
|
||||
m_frame->SetActiveLayer( Cmts_User );
|
||||
|
||||
std::vector<BOARD_ITEM*> table = DrawBoardCharacteristics( wxPoint( 0, 0 ),
|
||||
m_frame->GetActiveLayer(), false,
|
||||
&tableSize );
|
||||
std::vector<BOARD_ITEM*> table = DrawBoardCharacteristics( { 0, 0 }, m_frame->GetActiveLayer(),
|
||||
false, &tableSize );
|
||||
std::vector<BOARD_ITEM*> preview;
|
||||
std::vector<BOARD_ITEM*> items;
|
||||
|
||||
|
@ -719,25 +709,17 @@ int DRAWING_TOOL::PlaceCharacteristics( const TOOL_EVENT& aEvent )
|
|||
PCB_SHAPE* line3 = new PCB_SHAPE;
|
||||
PCB_SHAPE* line4 = new PCB_SHAPE;
|
||||
|
||||
line1->SetStartX( 0 );
|
||||
line1->SetStartY( 0 );
|
||||
line1->SetEndX( tableSize.x );
|
||||
line1->SetEndY( 0 );
|
||||
line1->SetStart( VECTOR2I( 0, 0 ) );
|
||||
line1->SetEnd( VECTOR2I( tableSize.x, 0 ) );
|
||||
|
||||
line2->SetStartX( 0 );
|
||||
line2->SetStartY( 0 );
|
||||
line2->SetEndX( 0 );
|
||||
line2->SetEndY( tableSize.y );
|
||||
line2->SetStart( VECTOR2I( 0, 0 ) );
|
||||
line2->SetEnd( VECTOR2I( 0, tableSize.y ) );
|
||||
|
||||
line3->SetStartX( tableSize.x );
|
||||
line3->SetStartY( 0 );
|
||||
line3->SetEndX( tableSize.x );
|
||||
line3->SetEndY( tableSize.y );
|
||||
line3->SetStart( VECTOR2I( tableSize.x, 0 ) );
|
||||
line3->SetEnd( tableSize );
|
||||
|
||||
line4->SetStartX( 0 );
|
||||
line4->SetStartY( tableSize.y );
|
||||
line4->SetEndX( tableSize.x );
|
||||
line4->SetEndY( tableSize.y );
|
||||
line4->SetStart( VECTOR2I( 0, tableSize.y ) );
|
||||
line4->SetEnd( tableSize );
|
||||
|
||||
line1->SetLayer( m_frame->GetActiveLayer() );
|
||||
line2->SetLayer( m_frame->GetActiveLayer() );
|
||||
|
@ -771,8 +753,8 @@ int DRAWING_TOOL::PlaceStackup( const TOOL_EVENT& aEvent )
|
|||
VECTOR2I tableSize;
|
||||
|
||||
LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() );
|
||||
layerSet = static_cast<LSET>( layerSet.set( Edge_Cuts ).set( Margin ) );
|
||||
layerSet = static_cast<LSET>( layerSet.reset( F_Fab ).reset( B_Fab ) );
|
||||
layerSet = layerSet.set( Edge_Cuts ).set( Margin );
|
||||
layerSet = layerSet.reset( F_Fab ).reset( B_Fab );
|
||||
|
||||
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
|
||||
PCB_LAYER_ID savedLayer = layer;
|
||||
|
@ -794,25 +776,17 @@ int DRAWING_TOOL::PlaceStackup( const TOOL_EVENT& aEvent )
|
|||
PCB_SHAPE* line3 = new PCB_SHAPE;
|
||||
PCB_SHAPE* line4 = new PCB_SHAPE;
|
||||
|
||||
line1->SetStartX( 0 );
|
||||
line1->SetStartY( 0 );
|
||||
line1->SetEndX( tableSize.x );
|
||||
line1->SetEndY( 0 );
|
||||
line1->SetStart( VECTOR2I( 0, 0 ) );
|
||||
line1->SetEnd( VECTOR2I( tableSize.x, 0 ) );
|
||||
|
||||
line2->SetStartX( 0 );
|
||||
line2->SetStartY( 0 );
|
||||
line2->SetEndX( 0 );
|
||||
line2->SetEndY( tableSize.y );
|
||||
line2->SetStart( VECTOR2I( 0, 0 ) );
|
||||
line2->SetEnd( VECTOR2I( 0, tableSize.y ) );
|
||||
|
||||
line3->SetStartX( tableSize.x );
|
||||
line3->SetStartY( 0 );
|
||||
line3->SetEndX( tableSize.x );
|
||||
line3->SetEndY( tableSize.y );
|
||||
line3->SetStart( VECTOR2I( tableSize.x, 0 ) );
|
||||
line3->SetEnd( tableSize );
|
||||
|
||||
line4->SetStartX( 0 );
|
||||
line4->SetStartY( tableSize.y );
|
||||
line4->SetEndX( tableSize.x );
|
||||
line4->SetEndY( tableSize.y );
|
||||
line4->SetStart( VECTOR2I( 0, tableSize.y ) );
|
||||
line4->SetEnd( tableSize );
|
||||
|
||||
line1->SetLayer( m_frame->GetActiveLayer() );
|
||||
line2->SetLayer( m_frame->GetActiveLayer() );
|
||||
|
|
|
@ -139,7 +139,7 @@ bool EDIT_TOOL::Init()
|
|||
return m_isFootprintEditor;
|
||||
};
|
||||
|
||||
auto singleFootprintCondition = SELECTION_CONDITIONS::OnlyType( PCB_FOOTPRINT_T )
|
||||
auto singleFootprintCondition = SELECTION_CONDITIONS::OnlyTypes( { PCB_FOOTPRINT_T } )
|
||||
&& SELECTION_CONDITIONS::Count( 1 );
|
||||
|
||||
auto noActiveToolCondition =
|
||||
|
@ -167,13 +167,13 @@ bool EDIT_TOOL::Init()
|
|||
menu.AddItem( PCB_ACTIONS::move, SELECTION_CONDITIONS::NotEmpty
|
||||
&& notMovingCondition );
|
||||
menu.AddItem( PCB_ACTIONS::breakTrack, SELECTION_CONDITIONS::Count( 1 )
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) );
|
||||
menu.AddItem( PCB_ACTIONS::drag45Degree, SELECTION_CONDITIONS::Count( 1 )
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::DraggableItems ) );
|
||||
menu.AddItem( PCB_ACTIONS::dragFreeAngle, SELECTION_CONDITIONS::Count( 1 )
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::DraggableItems )
|
||||
&& !SELECTION_CONDITIONS::OnlyType( PCB_FOOTPRINT_T ) );
|
||||
menu.AddItem( PCB_ACTIONS::filletTracks, SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
||||
&& !SELECTION_CONDITIONS::OnlyTypes( { PCB_FOOTPRINT_T } ) );
|
||||
menu.AddItem( PCB_ACTIONS::filletTracks, SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) );
|
||||
menu.AddItem( PCB_ACTIONS::rotateCcw, SELECTION_CONDITIONS::NotEmpty );
|
||||
menu.AddItem( PCB_ACTIONS::rotateCw, SELECTION_CONDITIONS::NotEmpty );
|
||||
menu.AddItem( PCB_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty );
|
||||
|
@ -295,14 +295,16 @@ int EDIT_TOOL::Drag( const TOOL_EVENT& aEvent )
|
|||
// drop a knee between two segments to a single segment
|
||||
if( aCollector.GetCount() == 2 && dynamic_cast<PCB_TRACK*>( aCollector[0] ) )
|
||||
{
|
||||
static KICAD_T types[] = { PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, EOT };
|
||||
|
||||
PCB_TRACK* a = static_cast<PCB_TRACK*>( aCollector[0] );
|
||||
PCB_TRACK* b = static_cast<PCB_TRACK*>( aCollector[1] );
|
||||
const auto& c = aCollector[0]->GetBoard()->GetConnectivity();
|
||||
|
||||
int dist = a->GetWidth() / 2;
|
||||
auto connectedItems = c->GetConnectedItemsAtAnchor( a, aPt, types, dist );
|
||||
auto connectedItems = c->GetConnectedItemsAtAnchor( a, aPt,
|
||||
{ PCB_VIA_T,
|
||||
PCB_TRACE_T,
|
||||
PCB_ARC_T },
|
||||
dist );
|
||||
|
||||
if( alg::contains( connectedItems, b ) )
|
||||
aCollector.Remove( b );
|
||||
|
@ -366,12 +368,10 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
|
|||
tanEnd.A = tanIntersect;
|
||||
tanEnd.B = theArc->GetEnd();
|
||||
|
||||
KICAD_T track_types[] = { PCB_PAD_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, EOT };
|
||||
|
||||
auto getUniqueTrackAtAnchorCollinear =
|
||||
[&]( const VECTOR2I& aAnchor, const SEG& aCollinearSeg ) -> PCB_TRACK*
|
||||
{
|
||||
auto conn = board()->GetConnectivity();
|
||||
std::shared_ptr<CONNECTIVITY_DATA> conn = board()->GetConnectivity();
|
||||
|
||||
// Allow items at a distance within the width of the arc track
|
||||
int allowedDeviation = theArc->GetWidth();
|
||||
|
@ -380,7 +380,9 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
itemsOnAnchor = conn->GetConnectedItemsAtAnchor( theArc, aAnchor, track_types,
|
||||
itemsOnAnchor = conn->GetConnectedItemsAtAnchor( theArc, aAnchor,
|
||||
{ PCB_PAD_T, PCB_VIA_T,
|
||||
PCB_TRACE_T, PCB_ARC_T },
|
||||
allowedDeviation );
|
||||
allowedDeviation /= 2;
|
||||
|
||||
|
@ -797,14 +799,13 @@ int EDIT_TOOL::FilletTracks( const TOOL_EVENT& aEvent )
|
|||
};
|
||||
|
||||
std::vector<FILLET_OP> filletOperations;
|
||||
KICAD_T track_types[] = { PCB_PAD_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, EOT };
|
||||
bool operationPerformedOnAtLeastOne = false;
|
||||
bool didOneAttemptFail = false;
|
||||
std::set<PCB_TRACK*> processedTracks;
|
||||
|
||||
for( auto it = selection.begin(); it != selection.end(); it++ )
|
||||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
PCB_TRACK* track = dyn_cast<PCB_TRACK*>( *it );
|
||||
PCB_TRACK* track = dyn_cast<PCB_TRACK*>( item );
|
||||
|
||||
if( !track || track->Type() != PCB_TRACE_T || track->GetLength() == 0 )
|
||||
{
|
||||
|
@ -814,10 +815,14 @@ int EDIT_TOOL::FilletTracks( const TOOL_EVENT& aEvent )
|
|||
auto processFilletOp =
|
||||
[&]( bool aStartPoint )
|
||||
{
|
||||
std::shared_ptr<CONNECTIVITY_DATA> connectivity = board()->GetConnectivity();
|
||||
VECTOR2I anchor = ( aStartPoint ) ? track->GetStart() : track->GetEnd();
|
||||
auto itemsOnAnchor = connectivity->GetConnectedItemsAtAnchor( track, anchor,
|
||||
track_types );
|
||||
std::shared_ptr<CONNECTIVITY_DATA> c = board()->GetConnectivity();
|
||||
VECTOR2I anchor = aStartPoint ? track->GetStart()
|
||||
: track->GetEnd();
|
||||
std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
|
||||
|
||||
itemsOnAnchor = c->GetConnectedItemsAtAnchor( track, anchor,
|
||||
{ PCB_PAD_T, PCB_VIA_T,
|
||||
PCB_TRACE_T, PCB_ARC_T } );
|
||||
|
||||
if( itemsOnAnchor.size() > 0
|
||||
&& selection.Contains( itemsOnAnchor.at( 0 ) )
|
||||
|
@ -958,7 +963,7 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
|||
} );
|
||||
|
||||
// Tracks & vias are treated in a special way:
|
||||
if( ( SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) )( selection ) )
|
||||
if( ( SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )( selection ) )
|
||||
{
|
||||
DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection, *m_commit );
|
||||
dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR
|
||||
|
|
|
@ -85,7 +85,7 @@ bool PAD_TOOL::Init()
|
|||
|
||||
SELECTION_CONDITION padSel = SELECTION_CONDITIONS::HasType( PCB_PAD_T );
|
||||
SELECTION_CONDITION singlePadSel = SELECTION_CONDITIONS::Count( 1 ) &&
|
||||
SELECTION_CONDITIONS::OnlyType( PCB_PAD_T );
|
||||
SELECTION_CONDITIONS::OnlyTypes( { PCB_PAD_T } );
|
||||
|
||||
auto explodeCondition =
|
||||
[&]( const SELECTION& aSel )
|
||||
|
@ -280,8 +280,6 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
return 0;
|
||||
|
||||
GENERAL_COLLECTOR collector;
|
||||
const KICAD_T types[] = { PCB_PAD_T, EOT };
|
||||
|
||||
GENERAL_COLLECTORS_GUIDE guide = frame()->GetCollectorsGuide();
|
||||
guide.SetIgnoreMTextsMarkedNoShow( true );
|
||||
guide.SetIgnoreMTextsOnBack( true );
|
||||
|
@ -384,7 +382,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
for( int j = 0; j < segments; ++j )
|
||||
{
|
||||
wxPoint testpoint( cursorPos.x - j * line_step.x, cursorPos.y - j * line_step.y );
|
||||
collector.Collect( board(), types, testpoint, guide );
|
||||
collector.Collect( board(), { PCB_PAD_T }, testpoint, guide );
|
||||
|
||||
for( int i = 0; i < collector.GetCount(); ++i )
|
||||
selectedPads.push_back( static_cast<PAD*>( collector[i] ) );
|
||||
|
|
|
@ -1344,10 +1344,9 @@ void PCB_SELECTION_TOOL::selectAllConnectedTracks(
|
|||
|
||||
void PCB_SELECTION_TOOL::selectAllItemsOnNet( int aNetCode, bool aSelect )
|
||||
{
|
||||
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, EOT };
|
||||
auto connectivity = board()->GetConnectivity();
|
||||
std::shared_ptr<CONNECTIVITY_DATA> conn = board()->GetConnectivity();
|
||||
|
||||
for( BOARD_CONNECTED_ITEM* item : connectivity->GetNetItems( aNetCode, types ) )
|
||||
for( BOARD_ITEM* item : conn->GetNetItems( aNetCode, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )
|
||||
{
|
||||
if( itemPassesFilter( item, true ) )
|
||||
aSelect ? select( item ) : unselect( item );
|
||||
|
@ -1470,19 +1469,16 @@ void PCB_SELECTION_TOOL::selectConnections( const std::vector<BOARD_ITEM*>& aIte
|
|||
// now we need to find all footprints that are connected to each of these nets then we need
|
||||
// to determine if these footprints are in the list of footprints
|
||||
std::vector<int> removeCodeList;
|
||||
constexpr KICAD_T padType[] = { PCB_PAD_T, EOT };
|
||||
std::shared_ptr<CONNECTIVITY_DATA> conn = board()->GetConnectivity();
|
||||
|
||||
for( int netCode : netcodeList )
|
||||
{
|
||||
for( BOARD_CONNECTED_ITEM* mitem :
|
||||
board()->GetConnectivity()->GetNetItems( netCode, padType ) )
|
||||
for( BOARD_CONNECTED_ITEM* pad : conn->GetNetItems( netCode, { PCB_PAD_T } ) )
|
||||
{
|
||||
if( mitem->Type() == PCB_PAD_T
|
||||
&& !std::binary_search( padList.begin(), padList.end(), mitem ) )
|
||||
if( !std::binary_search( padList.begin(), padList.end(), pad ) )
|
||||
{
|
||||
// if we cannot find the pad in the padList then we can
|
||||
// assume that that pad should not be used, therefore
|
||||
// invalidate this netcode.
|
||||
// if we cannot find the pad in the padList then we can assume that that pad
|
||||
// should not be used, therefore invalidate this netcode.
|
||||
removeCodeList.push_back( netCode );
|
||||
break;
|
||||
}
|
||||
|
@ -1490,25 +1486,18 @@ void PCB_SELECTION_TOOL::selectConnections( const std::vector<BOARD_ITEM*>& aIte
|
|||
}
|
||||
|
||||
for( int removeCode : removeCodeList )
|
||||
{
|
||||
netcodeList.remove( removeCode );
|
||||
}
|
||||
|
||||
std::vector<BOARD_CONNECTED_ITEM*> localConnectionList;
|
||||
constexpr KICAD_T trackViaType[] = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, EOT };
|
||||
std::unordered_set<BOARD_ITEM*> localConnectionList;
|
||||
|
||||
for( int netCode : netcodeList )
|
||||
{
|
||||
for( BOARD_CONNECTED_ITEM* item :
|
||||
board()->GetConnectivity()->GetNetItems( netCode, trackViaType ) )
|
||||
localConnectionList.push_back( item );
|
||||
for( BOARD_ITEM* item : conn->GetNetItems( netCode, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )
|
||||
localConnectionList.insert( item );
|
||||
}
|
||||
|
||||
for( BOARD_CONNECTED_ITEM* i : localConnectionList )
|
||||
{
|
||||
if( i != nullptr )
|
||||
select( i );
|
||||
}
|
||||
for( BOARD_ITEM* item : localConnectionList )
|
||||
select( item );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue