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>
|
2019-04-04 22:49:49 +00:00
|
|
|
* Copyright (C) 2004-2019 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>
|
2011-12-13 15:37:33 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
#include <sch_sheet_path.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <transform.h>
|
2019-05-10 19:22:26 +00:00
|
|
|
#include <ee_collectors.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_line.h>
|
2013-04-01 10:35:20 +00:00
|
|
|
#include <sch_bus_entry.h>
|
2011-07-12 06:57:11 +00:00
|
|
|
|
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
const KICAD_T EE_COLLECTOR::AllItems[] = {
|
2019-05-08 18:56:03 +00:00
|
|
|
SCH_LOCATE_ANY_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
const KICAD_T EE_COLLECTOR::EditableItems[] = {
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_TEXT_T,
|
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
2019-04-15 23:56:41 +00:00
|
|
|
SCH_HIER_LABEL_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_FIELD_T,
|
|
|
|
SCH_COMPONENT_T,
|
|
|
|
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,
|
2011-07-12 06:57:11 +00:00
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
2019-05-17 16:45:27 +00:00
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
const KICAD_T EE_COLLECTOR::ComponentsOnly[] = {
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_COMPONENT_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
const KICAD_T EE_COLLECTOR::SheetsOnly[] = {
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_SHEET_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
SEARCH_RESULT EE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
|
2011-07-12 06:57:11 +00:00
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
if( aItem->Type() == LIB_PIN_T )
|
|
|
|
{
|
|
|
|
// Special selection rules apply to pins of different units when edited in
|
2019-05-10 17:19:48 +00:00
|
|
|
// synchronized pins mode. Leave it to EE_SELECTION_TOOL::isSelectable() to
|
2019-05-08 18:56:03 +00:00
|
|
|
// decide what to do with them.
|
|
|
|
}
|
|
|
|
else if( m_Unit || m_Convert )
|
2019-05-06 02:32:01 +00:00
|
|
|
{
|
|
|
|
LIB_ITEM* lib_item = dynamic_cast<LIB_ITEM*>( aItem );
|
|
|
|
|
|
|
|
if( m_Unit && lib_item && lib_item->GetUnit() && lib_item->GetUnit() != m_Unit )
|
2019-12-28 00:55:11 +00:00
|
|
|
return SEARCH_RESULT::CONTINUE;
|
2019-05-06 02:32:01 +00:00
|
|
|
|
2019-05-06 15:01:39 +00:00
|
|
|
if( m_Convert && lib_item && lib_item->GetConvert() && lib_item->GetConvert() != m_Convert )
|
2019-12-28 00:55:11 +00:00
|
|
|
return SEARCH_RESULT::CONTINUE;
|
2019-05-06 02:32:01 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 19:28:16 +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
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
return SEARCH_RESULT::CONTINUE;
|
2011-07-12 06:57:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
void EE_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aFilterList[], const wxPoint& 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;
|
|
|
|
m_Convert = 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
|
|
|
|
2019-06-25 06:31:22 +00:00
|
|
|
// aItem can be null for empty schematics
|
|
|
|
if( aItem && aItem->Type() == LIB_PART_T )
|
2019-05-06 02:32:01 +00:00
|
|
|
static_cast<LIB_PART*>( aItem )->Visit( m_inspector, nullptr, m_ScanTypes );
|
|
|
|
else
|
|
|
|
EDA_ITEM::IterateForward( aItem, m_inspector, nullptr, m_ScanTypes );
|
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;
|
|
|
|
|
2015-11-03 19:44:05 +00:00
|
|
|
bool is_busentry0 = (dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_List[0] ) != NULL);
|
|
|
|
bool is_busentry1 = (dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_List[1] ) != NULL);
|
2013-04-01 10:35:20 +00:00
|
|
|
|
2011-07-12 06:57:11 +00:00
|
|
|
if( (m_List[0]->Type() == SCH_LINE_T) && (m_List[1]->Type() == SCH_LINE_T) )
|
2017-11-27 22:44:41 +00:00
|
|
|
return ( ( SCH_LINE* ) m_List[0])->GetLayer() == ( ( SCH_LINE* ) m_List[1])->GetLayer();
|
2011-07-12 06:57:11 +00:00
|
|
|
|
2013-04-01 10:35:20 +00:00
|
|
|
if( (m_List[0]->Type() == SCH_LINE_T) && is_busentry1 )
|
2011-07-12 06:57:11 +00:00
|
|
|
return true;
|
|
|
|
|
2013-04-01 10:35:20 +00:00
|
|
|
if( is_busentry0 && (m_List[1]->Type() == SCH_LINE_T) )
|
2011-07-12 06:57:11 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
bool EE_COLLECTOR::IsDraggableJunction() const
|
2011-07-12 06:57:11 +00:00
|
|
|
{
|
|
|
|
for( size_t i = 0; i < m_List.size(); i++ )
|
2017-12-13 05:12:06 +00:00
|
|
|
if( ( (SCH_ITEM*) m_List[ i ] )->Type() == SCH_JUNCTION_T )
|
|
|
|
return true;
|
2011-07-12 06:57:11 +00:00
|
|
|
|
2017-12-13 05:12:06 +00:00
|
|
|
return false;
|
2011-07-12 06:57:11 +00:00
|
|
|
}
|
2011-12-01 16:49:28 +00:00
|
|
|
|
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
SEARCH_RESULT EE_TYPE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* testData )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
{
|
|
|
|
// The Vist() function only visits the testItem if its type was in the
|
|
|
|
// the scanList, so therefore we can collect anything given to us here.
|
|
|
|
Append( aItem );
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
return SEARCH_RESULT::CONTINUE;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-10 19:28:16 +00:00
|
|
|
void EE_TYPE_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aFilterList[] )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
{
|
|
|
|
Empty(); // empty the collection
|
|
|
|
|
|
|
|
SetScanTypes( aFilterList );
|
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
EDA_ITEM::IterateForward( aItem, m_inspector, NULL, m_ScanTypes );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|