2011-07-12 06:57:11 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2011-07-12 06:57:11 +00:00
|
|
|
*
|
2018-04-13 13:58:25 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-08-20 09:27:35 +00:00
|
|
|
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
2011-07-12 06:57:11 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <macros.h>
|
2018-04-13 13:58:25 +00:00
|
|
|
#include <trace_helpers.h>
|
2019-05-10 19:22:26 +00:00
|
|
|
#include <ee_collectors.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <sch_bus_entry.h>
|
2021-02-24 13:48:02 +00:00
|
|
|
#include <sch_symbol.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_line.h>
|
2020-04-26 20:53:29 +00:00
|
|
|
#include <sch_screen.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <sch_sheet_path.h>
|
|
|
|
#include <transform.h>
|
2020-03-30 13:14:44 +00:00
|
|
|
#include "sch_reference_list.h"
|
2011-07-12 06:57:11 +00:00
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> EE_COLLECTOR::EditableItems = {
|
2021-07-17 19:56:18 +00:00
|
|
|
SCH_SHAPE_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_TEXT_T,
|
2022-01-25 22:33:37 +00:00
|
|
|
SCH_TEXTBOX_T,
|
2023-11-25 12:38:24 +00:00
|
|
|
SCH_TABLECELL_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
2019-04-15 23:56:41 +00:00
|
|
|
SCH_HIER_LABEL_T,
|
2022-01-24 13:40:39 +00:00
|
|
|
SCH_DIRECTIVE_LABEL_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_FIELD_T,
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_SHEET_PIN_T,
|
|
|
|
SCH_SHEET_T,
|
2011-08-31 14:59:20 +00:00
|
|
|
SCH_BITMAP_T,
|
2017-10-31 16:33:37 +00:00
|
|
|
SCH_LINE_T,
|
2020-06-19 11:48:00 +00:00
|
|
|
SCH_BUS_WIRE_ENTRY_T,
|
2024-04-25 14:24:46 +00:00
|
|
|
SCH_JUNCTION_T,
|
|
|
|
SCH_RULE_AREA_T
|
2011-07-12 06:57:11 +00:00
|
|
|
};
|
|
|
|
|
2019-05-17 16:45:27 +00:00
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> EE_COLLECTOR::MovableItems =
|
2021-02-13 01:15:45 +00:00
|
|
|
{
|
|
|
|
SCH_MARKER_T,
|
|
|
|
SCH_JUNCTION_T,
|
|
|
|
SCH_NO_CONNECT_T,
|
|
|
|
SCH_BUS_BUS_ENTRY_T,
|
|
|
|
SCH_BUS_WIRE_ENTRY_T,
|
|
|
|
SCH_LINE_T,
|
|
|
|
SCH_BITMAP_T,
|
2021-07-17 19:56:18 +00:00
|
|
|
SCH_SHAPE_T,
|
2021-02-13 01:15:45 +00:00
|
|
|
SCH_TEXT_T,
|
2022-01-25 22:33:37 +00:00
|
|
|
SCH_TEXTBOX_T,
|
2023-11-25 12:38:24 +00:00
|
|
|
SCH_TABLE_T,
|
|
|
|
SCH_TABLECELL_T, // will be promoted to parent table(s)
|
2021-02-13 01:15:45 +00:00
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
|
|
|
SCH_HIER_LABEL_T,
|
2022-01-24 13:40:39 +00:00
|
|
|
SCH_DIRECTIVE_LABEL_T,
|
2021-02-13 01:15:45 +00:00
|
|
|
SCH_FIELD_T,
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL_T,
|
2021-02-13 01:15:45 +00:00
|
|
|
SCH_SHEET_PIN_T,
|
2024-04-25 14:24:46 +00:00
|
|
|
SCH_SHEET_T,
|
|
|
|
SCH_RULE_AREA_T
|
2021-02-13 01:15:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> EE_COLLECTOR::FieldOwners = {
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL_T,
|
2020-10-28 22:32:08 +00:00
|
|
|
SCH_SHEET_T,
|
2022-08-20 09:27:35 +00:00
|
|
|
SCH_LABEL_LOCATE_ANY_T
|
2020-10-28 22:32:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
INSPECT_RESULT EE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
|
2011-07-12 06:57:11 +00:00
|
|
|
{
|
2024-01-26 16:16:13 +00:00
|
|
|
if( m_Unit || m_BodyStyle )
|
2019-05-06 02:32:01 +00:00
|
|
|
{
|
2024-04-06 13:14:44 +00:00
|
|
|
SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( aItem );
|
2019-05-06 02:32:01 +00:00
|
|
|
|
2022-07-23 22:26:03 +00:00
|
|
|
// Special selection rules apply to pins of different units when edited in synchronized
|
|
|
|
// pins mode. Leave it to EE_SELECTION_TOOL::Selectable() to decide what to do with them.
|
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
if( schItem && schItem->Type() != SCH_PIN_T )
|
2022-07-23 22:26:03 +00:00
|
|
|
{
|
2024-04-06 13:14:44 +00:00
|
|
|
if( m_Unit && schItem->GetUnit() && schItem->GetUnit() != m_Unit )
|
2022-07-30 00:00:39 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2019-05-06 02:32:01 +00:00
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
if( m_BodyStyle && schItem->GetBodyStyle() && schItem->GetBodyStyle() != m_BodyStyle )
|
2022-07-30 00:00:39 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2022-07-23 22:26:03 +00:00
|
|
|
}
|
2019-05-06 02:32:01 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 22:26:03 +00:00
|
|
|
if( m_ShowPinElectricalTypes )
|
|
|
|
aItem->SetFlags( SHOW_ELEC_TYPE );
|
|
|
|
|
2020-10-02 20:25:14 +00:00
|
|
|
if( aItem->HitTest( m_refPos, m_Threshold ) )
|
2019-04-21 23:45:34 +00:00
|
|
|
Append( aItem );
|
2011-07-12 06:57:11 +00:00
|
|
|
|
2022-07-23 22:26:03 +00:00
|
|
|
aItem->ClearFlags( SHOW_ELEC_TYPE );
|
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2011-07-12 06:57:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
void EE_COLLECTOR::Collect( SCH_SCREEN* aScreen, const std::vector<KICAD_T>& aFilterList,
|
2022-08-20 09:27:35 +00:00
|
|
|
const VECTOR2I& aPos, int aUnit, int aConvert )
|
2019-06-25 23:39:58 +00:00
|
|
|
{
|
|
|
|
Empty(); // empty the collection just in case
|
|
|
|
|
|
|
|
SetScanTypes( aFilterList );
|
2024-01-26 16:16:13 +00:00
|
|
|
m_Unit = aUnit;
|
|
|
|
m_BodyStyle = aConvert;
|
2019-06-25 23:39:58 +00:00
|
|
|
|
|
|
|
// remember where the snapshot was taken from and pass refPos to the Inspect() function.
|
|
|
|
SetRefPos( aPos );
|
|
|
|
|
|
|
|
if( aScreen )
|
|
|
|
{
|
2021-10-12 20:05:37 +00:00
|
|
|
for( SCH_ITEM *item : aScreen->Items().Overlapping( SCH_LOCATE_ANY_T, aPos, m_Threshold ) )
|
|
|
|
item->Visit( m_inspector, nullptr, m_scanTypes );
|
2019-06-25 23:39:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
void EE_COLLECTOR::Collect( LIB_ITEMS_CONTAINER& aItems, const std::vector<KICAD_T>& aFilterList,
|
2022-01-01 06:04:08 +00:00
|
|
|
const VECTOR2I& aPos, int aUnit, int aConvert )
|
2011-07-12 06:57:11 +00:00
|
|
|
{
|
|
|
|
Empty(); // empty the collection just in case
|
|
|
|
|
|
|
|
SetScanTypes( aFilterList );
|
2019-05-06 02:32:01 +00:00
|
|
|
m_Unit = aUnit;
|
2024-01-26 16:16:13 +00:00
|
|
|
m_BodyStyle = aConvert;
|
2011-07-12 06:57:11 +00:00
|
|
|
|
|
|
|
// remember where the snapshot was taken from and pass refPos to the Inspect() function.
|
2019-04-21 23:45:34 +00:00
|
|
|
SetRefPos( aPos );
|
2011-07-12 06:57:11 +00:00
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
for( SCH_ITEM& item : aItems )
|
2019-06-25 23:39:58 +00:00
|
|
|
{
|
2022-07-30 00:00:39 +00:00
|
|
|
if( item.Visit( m_inspector, nullptr, m_scanTypes ) == INSPECT_RESULT::QUIT )
|
2019-06-25 23:39:58 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-07-12 06:57:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
bool EE_COLLECTOR::IsCorner() const
|
2011-07-12 06:57:11 +00:00
|
|
|
{
|
|
|
|
if( GetCount() != 2 )
|
|
|
|
return false;
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
bool is_busentry0 = ( dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_list[0] ) != nullptr );
|
|
|
|
bool is_busentry1 = ( dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_list[1] ) != nullptr );
|
2013-04-01 10:35:20 +00:00
|
|
|
|
2020-10-02 20:25:14 +00:00
|
|
|
if(( m_list[0]->Type() == SCH_LINE_T) && ( m_list[1]->Type() == SCH_LINE_T) )
|
|
|
|
return ( ( SCH_LINE* ) m_list[0])->GetLayer() == ( ( SCH_LINE* ) m_list[1])->GetLayer();
|
2011-07-12 06:57:11 +00:00
|
|
|
|
2020-10-02 20:25:14 +00:00
|
|
|
if(( m_list[0]->Type() == SCH_LINE_T) && is_busentry1 )
|
2011-07-12 06:57:11 +00:00
|
|
|
return true;
|
|
|
|
|
2020-10-02 20:25:14 +00:00
|
|
|
if( is_busentry0 && ( m_list[1]->Type() == SCH_LINE_T) )
|
2011-07-12 06:57:11 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-06 11:13:08 +00:00
|
|
|
void CollectOtherUnits( const wxString& aRef, int aUnit, const LIB_ID& aLibId,
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SHEET_PATH& aSheet, std::vector<SCH_SYMBOL*>* otherUnits )
|
2020-03-30 13:14:44 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
SCH_REFERENCE_LIST symbols;
|
|
|
|
aSheet.GetSymbols( symbols );
|
2020-03-30 13:14:44 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
for( unsigned i = 0; i < symbols.GetCount(); i++ )
|
2020-10-24 20:55:32 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
SCH_REFERENCE symbol = symbols[i];
|
2020-03-30 13:14:44 +00:00
|
|
|
|
2021-10-12 20:05:37 +00:00
|
|
|
if( symbol.GetRef() == aRef
|
|
|
|
&& symbol.GetSymbol()->GetLibId() == aLibId
|
|
|
|
&& symbol.GetUnit() != aUnit )
|
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
otherUnits->push_back( symbol.GetSymbol() );
|
2021-10-12 20:05:37 +00:00
|
|
|
}
|
2020-03-30 13:14:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|