2011-10-11 13:38:13 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-30 09:45:35 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-10-06 18:07:43 +00:00
|
|
|
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
|
2018-01-30 09:45:35 +00:00
|
|
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-11 13:38:13 +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
|
|
|
|
*/
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
/**
|
2018-01-30 09:45:35 +00:00
|
|
|
* @file eeschema/netlist_object_list.cpp
|
2011-10-07 14:41:30 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <netlist.h>
|
2018-01-30 08:56:43 +00:00
|
|
|
#include <netlist_object.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_library.h>
|
|
|
|
#include <lib_pin.h>
|
|
|
|
#include <sch_junction.h>
|
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_line.h>
|
|
|
|
#include <sch_no_connect.h>
|
|
|
|
#include <sch_text.h>
|
|
|
|
#include <sch_sheet.h>
|
2018-01-30 09:45:35 +00:00
|
|
|
#include <sch_screen.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <algorithm>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
#define IS_WIRE false
|
|
|
|
#define IS_BUS true
|
2013-04-01 05:47:44 +00:00
|
|
|
|
2010-08-03 05:11:05 +00:00
|
|
|
//#define NETLIST_DEBUG
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST()
|
|
|
|
{
|
2015-06-07 18:18:45 +00:00
|
|
|
Clear();
|
2013-09-25 19:09:57 +00:00
|
|
|
}
|
2007-09-21 04:40:12 +00:00
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2015-06-07 18:18:45 +00:00
|
|
|
void NETLIST_OBJECT_LIST::Clear()
|
2007-09-21 04:40:12 +00:00
|
|
|
{
|
2015-06-07 18:18:45 +00:00
|
|
|
NETLIST_OBJECTS::iterator iter;
|
2013-09-25 19:09:57 +00:00
|
|
|
|
|
|
|
for( iter = begin(); iter != end(); iter++ )
|
2007-09-21 04:40:12 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
NETLIST_OBJECT* item = *iter;
|
|
|
|
delete item;
|
2007-09-21 04:40:12 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
clear();
|
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
|
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
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
void NETLIST_OBJECT_LIST::SortListbyNetcode()
|
2011-12-12 14:02:37 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsbyNetcode );
|
2011-12-12 14:02:37 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
void NETLIST_OBJECT_LIST::SortListbySheet()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsBySheet );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|
|
|
{
|
|
|
|
SCH_SHEET_PATH* sheet;
|
|
|
|
|
|
|
|
// Fill list with connected items from the flattened sheet list
|
2016-03-06 21:22:01 +00:00
|
|
|
for( unsigned i = 0; i < aSheets.size(); i++ )
|
2013-09-25 19:09:57 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
sheet = &aSheets[i];
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
for( SCH_ITEM* item = sheet->LastScreen()->GetDrawItems(); item; item = item->Next() )
|
|
|
|
{
|
|
|
|
item->GetNetListItem( *this, sheet );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( size() == 0 )
|
|
|
|
return false;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
// Sort objects by Sheet
|
|
|
|
SortListbySheet();
|
|
|
|
|
2013-09-29 18:24:38 +00:00
|
|
|
sheet = &(GetItem( 0 )->m_SheetPath);
|
2013-09-27 12:30:35 +00:00
|
|
|
m_lastNetCode = m_lastBusNetCode = 1;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned ii = 0, istart = 0; ii < size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
NETLIST_OBJECT* net_item = GetItem( ii );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-29 18:24:38 +00:00
|
|
|
if( net_item->m_SheetPath != *sheet ) // Sheet change
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-29 18:24:38 +00:00
|
|
|
sheet = &(net_item->m_SheetPath);
|
2009-07-15 07:10:07 +00:00
|
|
|
istart = ii;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
switch( net_item->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
2016-02-18 07:40:45 +00:00
|
|
|
wxMessageBox( wxT( "BuildNetListInfo() error" ) );
|
2009-07-12 15:29:42 +00:00
|
|
|
break;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_PIN:
|
|
|
|
case NET_PINLABEL:
|
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_NOCONNECT:
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->GetNet() != 0 )
|
2009-11-04 20:46:53 +00:00
|
|
|
break;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
case NET_SEGMENT:
|
2013-09-25 19:09:57 +00:00
|
|
|
// Test connections point to point type without bus.
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-27 12:30:35 +00:00
|
|
|
net_item->SetNet( m_lastNetCode );
|
|
|
|
m_lastNetCode++;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
pointToPointConnect( net_item, IS_WIRE, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
case NET_JUNCTION:
|
2013-09-25 19:09:57 +00:00
|
|
|
// Control of the junction outside BUS.
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-27 12:30:35 +00:00
|
|
|
net_item->SetNet( m_lastNetCode );
|
|
|
|
m_lastNetCode++;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
segmentToPointConnect( net_item, IS_WIRE, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
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
|
|
|
// Control of the junction, on BUS.
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->m_BusNetCode == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-27 12:30:35 +00:00
|
|
|
net_item->m_BusNetCode = m_lastBusNetCode;
|
|
|
|
m_lastBusNetCode++;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
segmentToPointConnect( net_item, IS_BUS, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_LABEL:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERLABEL:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBLABEL:
|
2013-09-25 19:09:57 +00:00
|
|
|
// Test connections type junction without bus.
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-27 12:30:35 +00:00
|
|
|
net_item->SetNet( m_lastNetCode );
|
|
|
|
m_lastNetCode++;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
segmentToPointConnect( net_item, IS_WIRE, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->m_BusNetCode != 0 )
|
2009-11-04 20:46:53 +00:00
|
|
|
break;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
case NET_BUS:
|
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
|
|
|
// Control type connections point to point mode bus
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->m_BusNetCode == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-27 12:30:35 +00:00
|
|
|
net_item->m_BusNetCode = m_lastBusNetCode;
|
|
|
|
m_lastBusNetCode++;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
pointToPointConnect( net_item, IS_BUS, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_BUSLABELMEMBER:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
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
|
|
|
// Control connections similar has on BUS
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-27 12:30:35 +00:00
|
|
|
net_item->m_BusNetCode = m_lastBusNetCode;
|
|
|
|
m_lastBusNetCode++;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
segmentToPointConnect( net_item, IS_BUS, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
#if defined(NETLIST_DEBUG) && defined(DEBUG)
|
2008-02-12 21:12:46 +00:00
|
|
|
std::cout << "\n\nafter sheet local\n\n";
|
2013-09-25 19:09:57 +00:00
|
|
|
DumpNetTable();
|
2008-03-20 01:50:21 +00:00
|
|
|
#endif
|
2007-09-21 04:40:12 +00:00
|
|
|
|
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
|
|
|
// Updating the Bus Labels Netcode connected by Bus
|
2013-09-27 12:30:35 +00:00
|
|
|
connectBusLabels();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
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
|
|
|
// Group objects by label.
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned ii = 0; ii < size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
switch( GetItem( ii )->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
|
|
|
case NET_PIN:
|
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_SEGMENT:
|
2011-10-07 14:41:30 +00:00
|
|
|
case NET_JUNCTION:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_BUS:
|
|
|
|
case NET_NOCONNECT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_LABEL:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBLABEL:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_PINLABEL:
|
|
|
|
case NET_BUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2013-09-25 19:09:57 +00:00
|
|
|
labelConnect( GetItem( ii ) );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_HIERLABEL:
|
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
|
|
|
break;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
#if defined(NETLIST_DEBUG) && defined(DEBUG)
|
2008-02-12 21:12:46 +00:00
|
|
|
std::cout << "\n\nafter sheet global\n\n";
|
2013-09-25 19:09:57 +00:00
|
|
|
DumpNetTable();
|
2008-03-20 01:50:21 +00:00
|
|
|
#endif
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
// Connection between hierarchy sheets
|
2013-09-27 12:30:35 +00:00
|
|
|
for( unsigned ii = 0; ii < size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
if( GetItem( ii )->m_Type == NET_SHEETLABEL
|
|
|
|
|| GetItem( ii )->m_Type == NET_SHEETBUSLABELMEMBER )
|
2013-09-27 12:30:35 +00:00
|
|
|
sheetLabelConnect( GetItem( ii ) );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
// Sort objects by NetCode
|
|
|
|
SortListbyNetcode();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
#if defined(NETLIST_DEBUG) && defined(DEBUG)
|
2010-08-03 05:11:05 +00:00
|
|
|
std::cout << "\n\nafter qsort()\n";
|
2013-09-25 19:09:57 +00:00
|
|
|
DumpNetTable();
|
2008-03-20 01:50:21 +00:00
|
|
|
#endif
|
|
|
|
|
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
|
|
|
// Compress numbers of Netcode having consecutive values.
|
2013-09-25 19:09:57 +00:00
|
|
|
int NetCode = 0;
|
2013-09-27 12:30:35 +00:00
|
|
|
m_lastNetCode = 0;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned ii = 0; ii < size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-27 12:30:35 +00:00
|
|
|
if( GetItem( ii )->GetNet() != m_lastNetCode )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
NetCode++;
|
2013-09-27 12:30:35 +00:00
|
|
|
m_lastNetCode = GetItem( ii )->GetNet();
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
GetItem( ii )->SetNet( NetCode );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
// Set the minimal connection info:
|
2013-09-27 12:30:35 +00:00
|
|
|
setUnconnectedFlag();
|
2010-06-23 17:00:12 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
// find the best label object to give the best net name to each net
|
2013-09-27 12:30:35 +00:00
|
|
|
findBestNetNameForEachNet();
|
2013-09-25 19:09:57 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helper function to give a priority to sort labels:
|
2016-02-18 07:40:45 +00:00
|
|
|
// NET_PINLABEL, NET_GLOBBUSLABELMEMBER and NET_GLOBLABEL are global labels
|
|
|
|
// and the priority is high
|
2013-09-25 19:09:57 +00:00
|
|
|
static int getPriority( const NETLIST_OBJECT* Objet )
|
|
|
|
{
|
|
|
|
switch( Objet->m_Type )
|
|
|
|
{
|
|
|
|
case NET_PIN: return 1;
|
|
|
|
case NET_LABEL: return 2;
|
|
|
|
case NET_HIERLABEL: return 3;
|
|
|
|
case NET_PINLABEL: return 4;
|
2016-02-18 07:40:45 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER: return 5;
|
|
|
|
case NET_GLOBLABEL: return 6;
|
2013-09-25 19:09:57 +00:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
/* function evalLabelsPriority used by findBestNetNameForEachNet()
|
2013-09-25 19:09:57 +00:00
|
|
|
* evalLabelsPriority calculates the priority of alabel1 and aLabel2
|
2016-02-18 07:40:45 +00:00
|
|
|
* return true if alabel1 has a higher priority than aLabel2
|
2013-09-25 19:09:57 +00:00
|
|
|
*/
|
2016-03-06 21:22:01 +00:00
|
|
|
static bool evalLabelsPriority( const NETLIST_OBJECT* aLabel1, const NETLIST_OBJECT* aLabel2 )
|
2013-09-25 19:09:57 +00:00
|
|
|
{
|
2016-02-18 07:40:45 +00:00
|
|
|
// Global labels have the highest prioriy.
|
|
|
|
// For local labels: names are prefixed by their sheetpath
|
|
|
|
// use name defined in the more top level hierarchical sheet
|
|
|
|
// (i.e. shorter timestamp path because paths are /<timestamp1>/<timestamp2>/...
|
|
|
|
// and timestamp = 8 letters.
|
|
|
|
// Note: the final net name uses human sheetpath name, not timestamp sheetpath name
|
|
|
|
// They are equivalent, but not for human readers.
|
|
|
|
if( ! aLabel1->IsLabelGlobal() && ! aLabel2->IsLabelGlobal() )
|
|
|
|
{
|
|
|
|
if( aLabel1->m_SheetPath.Path().Length() != aLabel2->m_SheetPath.Path().Length() )
|
|
|
|
return aLabel1->m_SheetPath.Path().Length() < aLabel2->m_SheetPath.Path().Length();
|
|
|
|
}
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
int priority1 = getPriority( aLabel1 );
|
|
|
|
int priority2 = getPriority( aLabel2 );
|
|
|
|
|
|
|
|
if( priority1 != priority2 )
|
2013-09-27 12:30:35 +00:00
|
|
|
return priority1 > priority2;
|
2013-09-25 19:09:57 +00:00
|
|
|
|
|
|
|
// Objects have here the same priority, therefore they have the same type.
|
|
|
|
// for global labels, we select the best candidate by alphabetic order
|
|
|
|
// because they have no sheetpath as prefix name
|
|
|
|
// for other labels, we select them before by sheet deep order
|
|
|
|
// because the actual name is /sheetpath/label
|
|
|
|
// and for a given path length, by alphabetic order
|
2016-02-18 07:40:45 +00:00
|
|
|
if( aLabel1->IsLabelGlobal() )
|
2015-08-31 08:44:27 +00:00
|
|
|
return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
|
2013-09-25 19:09:57 +00:00
|
|
|
|
2016-02-18 07:40:45 +00:00
|
|
|
// Sheet paths have here the same length: use alphabetic label name order
|
2013-09-25 19:09:57 +00:00
|
|
|
// For labels on sheets having an equivalent deep in hierarchy, use
|
|
|
|
// alphabetic label name order:
|
|
|
|
if( aLabel1->m_Label.Cmp( aLabel2->m_Label ) != 0 )
|
2013-09-27 12:30:35 +00:00
|
|
|
return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
|
2013-09-25 19:09:57 +00:00
|
|
|
|
2016-02-18 07:40:45 +00:00
|
|
|
// For identical labels having the same priority: choose the
|
|
|
|
// alphabetic label full name order
|
2013-09-29 18:24:38 +00:00
|
|
|
return aLabel1->m_SheetPath.PathHumanReadable().Cmp(
|
|
|
|
aLabel2->m_SheetPath.PathHumanReadable() ) < 0;
|
2010-06-23 17:00:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
|
2010-06-23 17:00:12 +00:00
|
|
|
{
|
2016-02-18 07:40:45 +00:00
|
|
|
// Important note: NET_SHEETLABEL items of sheet items should *NOT* be considered,
|
|
|
|
// because they live in a sheet but their names are actually used in the subsheet.
|
|
|
|
// Moreover, in the parent sheet, the name of NET_SHEETLABEL can be not unique,
|
|
|
|
// ( for instance when 2 different sheets share the same schematic in complex hierarchies
|
|
|
|
// and 2 identical NET_SHEETLABEL labels can be connected to 2 different nets
|
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
int netcode = 0; // current netcode for tested items
|
2013-09-25 19:09:57 +00:00
|
|
|
unsigned idxstart = 0; // index of the first item of this net
|
|
|
|
NETLIST_OBJECT* item;
|
|
|
|
NETLIST_OBJECT* candidate;
|
|
|
|
|
|
|
|
// Pass 1: find the best name for labelled nets:
|
|
|
|
candidate = NULL;
|
|
|
|
for( unsigned ii = 0; ii <= size(); ii++ )
|
2010-06-23 17:00:12 +00:00
|
|
|
{
|
2015-04-12 17:44:46 +00:00
|
|
|
if( ii == size() ) // last item already tested
|
|
|
|
item = NULL;
|
2010-06-23 17:00:12 +00:00
|
|
|
else
|
2013-09-25 19:09:57 +00:00
|
|
|
item = GetItem( ii );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2015-04-12 17:44:46 +00:00
|
|
|
if( !item || netcode != item->GetNet() ) // End of net found
|
2010-06-23 17:00:12 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
if( candidate ) // One or more labels exists, find the best
|
2010-06-23 17:00:12 +00:00
|
|
|
{
|
|
|
|
for (unsigned jj = idxstart; jj < ii; jj++ )
|
2013-09-25 19:09:57 +00:00
|
|
|
GetItem( jj )->SetNetNameCandidate( candidate );
|
2010-06-23 17:00:12 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2016-02-18 07:40:45 +00:00
|
|
|
if( item == NULL ) // End of list
|
2010-06-23 17:00:12 +00:00
|
|
|
break;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2016-02-18 07:40:45 +00:00
|
|
|
// Prepare next net analysis:
|
2010-06-23 17:00:12 +00:00
|
|
|
netcode = item->GetNet();
|
2013-09-25 19:09:57 +00:00
|
|
|
candidate = NULL;
|
2010-06-23 17:00:12 +00:00
|
|
|
idxstart = ii;
|
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
switch( item->m_Type )
|
|
|
|
{
|
|
|
|
case NET_HIERLABEL:
|
|
|
|
case NET_LABEL:
|
|
|
|
case NET_PINLABEL:
|
2010-07-14 13:24:36 +00:00
|
|
|
case NET_GLOBLABEL:
|
2016-02-18 07:40:45 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2013-09-25 19:09:57 +00:00
|
|
|
// A candidate is found: select the better between the previous
|
|
|
|
// and this one
|
|
|
|
if( candidate == NULL )
|
|
|
|
candidate = item;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( evalLabelsPriority( item, candidate ) )
|
2013-09-27 12:30:35 +00:00
|
|
|
// item has a highter priority than candidate
|
|
|
|
// so update the best candidate
|
2013-09-25 19:09:57 +00:00
|
|
|
candidate = item;
|
|
|
|
}
|
2010-06-23 17:00:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
// Pass 2: find the best name for not labelled nets:
|
|
|
|
// The "default" net name is Net-<<Ref cmp>_Pad<num pad>>
|
|
|
|
// (see NETLIST_OBJECT::GetShortNetName())
|
|
|
|
// therefore the "best" is the short net name alphabetically classed first
|
|
|
|
// (to avoid net names changes when the net is not modified,
|
|
|
|
// even if components are moved or deleted and undelete or replaced, as long
|
|
|
|
// the reference is kept)
|
2013-09-27 17:58:58 +00:00
|
|
|
|
2015-06-07 18:18:45 +00:00
|
|
|
// Build a list of items with no net names
|
|
|
|
NETLIST_OBJECTS list; // no ownership of elements being pointed at
|
|
|
|
|
2013-09-27 17:58:58 +00:00
|
|
|
for( unsigned ii = 0; ii < size(); ii++ )
|
|
|
|
{
|
|
|
|
item = GetItem( ii );
|
2016-03-06 21:22:01 +00:00
|
|
|
|
2013-09-27 17:58:58 +00:00
|
|
|
if( !item->HasNetNameCandidate() )
|
|
|
|
list.push_back( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( list.size() == 0 )
|
|
|
|
return;
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
idxstart = 0;
|
|
|
|
candidate = NULL;
|
2015-06-07 18:18:45 +00:00
|
|
|
netcode = list[0]->GetNet();
|
2013-09-27 17:58:58 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 0; ii <= list.size(); ii++ )
|
2010-07-14 13:24:36 +00:00
|
|
|
{
|
2013-09-27 17:58:58 +00:00
|
|
|
if( ii < list.size() )
|
2015-06-07 18:18:45 +00:00
|
|
|
item = list[ii];
|
2015-04-12 17:44:46 +00:00
|
|
|
else
|
|
|
|
item = NULL;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2015-04-12 17:44:46 +00:00
|
|
|
if( !item || netcode != item->GetNet() ) // End of net found
|
2010-06-23 17:00:12 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
if( candidate )
|
2010-07-14 13:24:36 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
for (unsigned jj = idxstart; jj < ii; jj++ )
|
2013-09-27 17:58:58 +00:00
|
|
|
{
|
2015-06-07 18:18:45 +00:00
|
|
|
NETLIST_OBJECT* obj = list[jj];
|
2013-09-27 17:58:58 +00:00
|
|
|
obj->SetNetNameCandidate( candidate );
|
|
|
|
}
|
2010-07-14 13:24:36 +00:00
|
|
|
}
|
2013-09-25 19:09:57 +00:00
|
|
|
|
2015-04-12 17:44:46 +00:00
|
|
|
if( !item )
|
2013-09-25 19:09:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
netcode = item->GetNet();
|
|
|
|
candidate = NULL;
|
|
|
|
idxstart = ii;
|
2010-07-14 13:24:36 +00:00
|
|
|
}
|
2013-09-25 19:09:57 +00:00
|
|
|
|
2013-09-30 06:36:40 +00:00
|
|
|
// Examine all pins of the net to find the best candidate,
|
|
|
|
// i.e. the first net name candidate, by alphabetic order
|
2016-02-18 07:40:45 +00:00
|
|
|
// the net names are built by GetShortNetName
|
2013-09-30 06:36:40 +00:00
|
|
|
// (Net-<{reference}-Pad{pad number}> like Net-<U3-Pad5>
|
|
|
|
// Not named nets do not have usually a lot of members.
|
|
|
|
// Many have only 2 members(a pad and a non connection symbol)
|
2013-09-27 17:58:58 +00:00
|
|
|
if( item->m_Type == NET_PIN )
|
2010-07-14 13:24:36 +00:00
|
|
|
{
|
2013-09-27 17:58:58 +00:00
|
|
|
// A candidate is found, however components which are not in
|
|
|
|
// netlist are not candidate because some have their reference
|
2013-09-30 06:36:40 +00:00
|
|
|
// changed each time the netlist is built (power components)
|
|
|
|
// and anyway obviously they are not a good candidate
|
|
|
|
SCH_COMPONENT* link = item->GetComponentParent();
|
2016-03-06 21:22:01 +00:00
|
|
|
|
2013-09-30 06:36:40 +00:00
|
|
|
if( link && link->IsInNetlist() )
|
2010-11-08 14:27:02 +00:00
|
|
|
{
|
2013-09-27 17:58:58 +00:00
|
|
|
// select the better between the previous and this one
|
|
|
|
item->SetNetNameCandidate( item ); // Needed to calculate GetShortNetName
|
2013-09-30 06:36:40 +00:00
|
|
|
|
2013-09-27 17:58:58 +00:00
|
|
|
if( candidate == NULL )
|
2013-09-25 19:09:57 +00:00
|
|
|
candidate = item;
|
2013-09-27 17:58:58 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if( item->GetShortNetName().Cmp( candidate->GetShortNetName() ) < 0 )
|
|
|
|
candidate = item;
|
|
|
|
}
|
2010-11-08 14:27:02 +00:00
|
|
|
}
|
2010-07-14 13:24:36 +00:00
|
|
|
}
|
2010-06-23 17:00:12 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2011-10-11 13:38:13 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
void NETLIST_OBJECT_LIST::sheetLabelConnect( NETLIST_OBJECT* SheetLabel )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
if( SheetLabel->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned ii = 0; ii < size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
NETLIST_OBJECT* ObjetNet = GetItem( ii );
|
2011-10-11 13:38:13 +00:00
|
|
|
|
2013-09-29 18:24:38 +00:00
|
|
|
if( ObjetNet->m_SheetPath != SheetLabel->m_SheetPathInclude )
|
2009-11-04 20:46:53 +00:00
|
|
|
continue; //use SheetInclude, not the sheet!!
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2011-10-11 13:38:13 +00:00
|
|
|
if( (ObjetNet->m_Type != NET_HIERLABEL ) && (ObjetNet->m_Type != NET_HIERBUSLABELMEMBER ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
if( ObjetNet->GetNet() == SheetLabel->GetNet() )
|
2009-11-04 20:46:53 +00:00
|
|
|
continue; //already connected.
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2016-06-11 03:15:02 +00:00
|
|
|
if( ObjetNet->m_Label != SheetLabel->m_Label )
|
2009-11-04 20:46:53 +00:00
|
|
|
continue; //different names.
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
// Propagate Netcode having all the objects of the same Netcode.
|
2009-07-12 15:29:42 +00:00
|
|
|
if( ObjetNet->GetNet() )
|
2016-06-08 01:07:49 +00:00
|
|
|
propagateNetCode( ObjetNet->GetNet(), SheetLabel->GetNet(), IS_WIRE );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2009-07-12 15:29:42 +00:00
|
|
|
ObjetNet->SetNet( SheetLabel->GetNet() );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
void NETLIST_OBJECT_LIST::connectBusLabels()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2016-02-18 07:40:45 +00:00
|
|
|
// Propagate the net code between all bus label member objects connected by they name.
|
|
|
|
// If the net code is not yet existing, a new one is created
|
|
|
|
// Search is done in the entire list
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned ii = 0; ii < size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
NETLIST_OBJECT* Label = GetItem( ii );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2016-02-18 07:40:45 +00:00
|
|
|
if( Label->IsLabelBusMemberType() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
if( Label->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2016-02-18 07:40:45 +00:00
|
|
|
// Not yet existiing net code: create a new one.
|
2013-09-27 12:30:35 +00:00
|
|
|
Label->SetNet( m_lastNetCode );
|
|
|
|
m_lastNetCode++;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned jj = ii + 1; jj < size(); jj++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
NETLIST_OBJECT* LabelInTst = GetItem( jj );
|
2016-02-18 07:40:45 +00:00
|
|
|
|
|
|
|
if( LabelInTst->IsLabelBusMemberType() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
|
|
|
if( LabelInTst->m_BusNetCode != Label->m_BusNetCode )
|
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
if( LabelInTst->m_Member != Label->m_Member )
|
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
if( LabelInTst->GetNet() == 0 )
|
2016-02-18 07:40:45 +00:00
|
|
|
// Append this object to the current net
|
2007-10-13 06:18:44 +00:00
|
|
|
LabelInTst->SetNet( Label->GetNet() );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2016-02-18 07:40:45 +00:00
|
|
|
// Merge the 2 net codes, they are connected.
|
2016-06-08 01:07:49 +00:00
|
|
|
propagateNetCode( LabelInTst->GetNet(), Label->GetNet(), IS_WIRE );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2008-08-22 14:48:30 +00:00
|
|
|
|
|
|
|
|
2016-06-08 01:07:49 +00:00
|
|
|
void NETLIST_OBJECT_LIST::propagateNetCode( int aOldNetCode, int aNewNetCode, bool aIsBus )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
if( aOldNetCode == aNewNetCode )
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
if( aIsBus == false ) // Propagate NetCode
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned jj = 0; jj < size(); jj++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
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
|
|
|
NETLIST_OBJECT* object = GetItem( jj );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
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
|
|
|
if( object->GetNet() == aOldNetCode )
|
|
|
|
object->SetNet( aNewNetCode );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-25 19:09:57 +00:00
|
|
|
else // Propagate BusNetCode
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned jj = 0; jj < size(); jj++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
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
|
|
|
NETLIST_OBJECT* object = GetItem( jj );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
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
|
|
|
if( object->m_BusNetCode == aOldNetCode )
|
|
|
|
object->m_BusNetCode = aNewNetCode;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
void NETLIST_OBJECT_LIST::pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus, int start )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
int netCode;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
if( aIsBus == false ) // Objects other than BUS and BUSLABELS
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
netCode = aRef->GetNet();
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned i = start; i < size(); i++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
NETLIST_OBJECT* item = GetItem( i );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-29 18:24:38 +00:00
|
|
|
if( item->m_SheetPath != aRef->m_SheetPath ) //used to be > (why?)
|
2008-02-12 21:12:46 +00:00
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
switch( item->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
|
|
|
case NET_SEGMENT:
|
|
|
|
case NET_PIN:
|
|
|
|
case NET_LABEL:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERLABEL:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBLABEL:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_PINLABEL:
|
2011-10-07 14:41:30 +00:00
|
|
|
case NET_JUNCTION:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_NOCONNECT:
|
2013-09-25 19:09:57 +00:00
|
|
|
if( aRef->m_Start == item->m_Start
|
|
|
|
|| aRef->m_Start == item->m_End
|
|
|
|
|| aRef->m_End == item->m_Start
|
|
|
|
|| aRef->m_End == item->m_End )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( item->GetNet() == 0 )
|
|
|
|
item->SetNet( netCode );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2016-06-08 01:07:49 +00:00
|
|
|
propagateNetCode( item->GetNet(), netCode, IS_WIRE );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_BUS:
|
|
|
|
case NET_BUSLABELMEMBER:
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
else // Object type BUS, BUSLABELS, and junctions.
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
netCode = aRef->m_BusNetCode;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned i = start; i < size(); i++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
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
|
|
|
NETLIST_OBJECT* item = GetItem( i );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-29 18:24:38 +00:00
|
|
|
if( item->m_SheetPath != aRef->m_SheetPath )
|
2008-02-12 21:12:46 +00:00
|
|
|
continue;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
switch( item->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SEGMENT:
|
|
|
|
case NET_PIN:
|
|
|
|
case NET_LABEL:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERLABEL:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBLABEL:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_PINLABEL:
|
|
|
|
case NET_NOCONNECT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_BUS:
|
|
|
|
case NET_BUSLABELMEMBER:
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2011-10-07 14:41:30 +00:00
|
|
|
case NET_JUNCTION:
|
2013-09-25 19:09:57 +00:00
|
|
|
if( aRef->m_Start == item->m_Start
|
|
|
|
|| aRef->m_Start == item->m_End
|
|
|
|
|| aRef->m_End == item->m_Start
|
|
|
|
|| aRef->m_End == item->m_End )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( item->m_BusNetCode == 0 )
|
|
|
|
item->m_BusNetCode = netCode;
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2016-06-08 01:07:49 +00:00
|
|
|
propagateNetCode( item->m_BusNetCode, netCode, IS_BUS );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
void NETLIST_OBJECT_LIST::segmentToPointConnect( NETLIST_OBJECT* aJonction,
|
2016-03-06 21:22:01 +00:00
|
|
|
bool aIsBus, int aIdxStart )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned i = aIdxStart; i < size(); i++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
NETLIST_OBJECT* segment = GetItem( i );
|
2009-07-12 15:29:42 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
// if different sheets, obviously no physical connection between elements.
|
2013-09-29 18:24:38 +00:00
|
|
|
if( segment->m_SheetPath != aJonction->m_SheetPath )
|
2008-02-12 21:12:46 +00:00
|
|
|
continue;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2013-04-01 05:47:44 +00:00
|
|
|
if( aIsBus == IS_WIRE )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
if( segment->m_Type != NET_SEGMENT )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
if( segment->m_Type != NET_BUS )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
if( IsPointOnSegment( segment->m_Start, segment->m_End, aJonction->m_Start ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
// Propagation Netcode has all the objects of the same Netcode.
|
2013-04-01 05:47:44 +00:00
|
|
|
if( aIsBus == IS_WIRE )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
if( segment->GetNet() )
|
2016-06-08 01:07:49 +00:00
|
|
|
propagateNetCode( segment->GetNet(), aJonction->GetNet(), aIsBus );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2013-09-25 19:09:57 +00:00
|
|
|
segment->SetNet( aJonction->GetNet() );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
if( segment->m_BusNetCode )
|
2016-06-08 01:07:49 +00:00
|
|
|
propagateNetCode( segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2013-09-25 19:09:57 +00:00
|
|
|
segment->m_BusNetCode = aJonction->m_BusNetCode;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
void NETLIST_OBJECT_LIST::labelConnect( NETLIST_OBJECT* aLabelRef )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
if( aLabelRef->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned i = 0; i < size(); i++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
NETLIST_OBJECT* item = GetItem( i );
|
|
|
|
|
|
|
|
if( item->GetNet() == aLabelRef->GetNet() )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-29 18:24:38 +00:00
|
|
|
if( item->m_SheetPath != aLabelRef->m_SheetPath )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
if( item->m_Type != NET_PINLABEL && item->m_Type != NET_GLOBLABEL
|
|
|
|
&& item->m_Type != NET_GLOBBUSLABELMEMBER )
|
2008-03-20 01:50:21 +00:00
|
|
|
continue;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
if( (item->m_Type == NET_GLOBLABEL
|
|
|
|
|| item->m_Type == NET_GLOBBUSLABELMEMBER)
|
|
|
|
&& item->m_Type != aLabelRef->m_Type )
|
2008-03-20 01:50:21 +00:00
|
|
|
//global labels only connect other global labels.
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
2008-08-22 14:48:30 +00:00
|
|
|
|
2010-11-08 14:27:02 +00:00
|
|
|
// NET_HIERLABEL are used to connect sheets.
|
2013-09-25 19:09:57 +00:00
|
|
|
// NET_LABEL are local to a sheet
|
|
|
|
// NET_GLOBLABEL are global.
|
2010-11-08 14:27:02 +00:00
|
|
|
// NET_PINLABEL is a kind of global label (generated by a power pin invisible)
|
2013-09-25 19:09:57 +00:00
|
|
|
if( item->IsLabelType() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2016-06-11 03:15:02 +00:00
|
|
|
if( item->m_Label != aLabelRef->m_Label )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2008-08-22 14:48:30 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
if( item->GetNet() )
|
2016-06-08 01:07:49 +00:00
|
|
|
propagateNetCode( item->GetNet(), aLabelRef->GetNet(), IS_WIRE );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2013-09-25 19:09:57 +00:00
|
|
|
item->SetNet( aLabelRef->GetNet() );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-08-22 14:48:30 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
void NETLIST_OBJECT_LIST::setUnconnectedFlag()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT* NetItemRef;
|
|
|
|
unsigned NetStart, NetEnd;
|
2011-10-12 15:34:52 +00:00
|
|
|
NET_CONNECTION_T StateFlag;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
NetStart = NetEnd = 0;
|
2008-12-10 16:49:53 +00:00
|
|
|
StateFlag = UNCONNECTED;
|
2013-09-25 19:09:57 +00:00
|
|
|
for( unsigned ii = 0; ii < size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
NetItemRef = GetItem( ii );
|
2009-07-12 15:29:42 +00:00
|
|
|
if( NetItemRef->m_Type == NET_NOCONNECT && StateFlag != PAD_CONNECT )
|
|
|
|
StateFlag = NOCONNECT_SYMBOL_PRESENT;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
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
|
|
|
// Analysis of current net.
|
2009-07-12 15:29:42 +00:00
|
|
|
unsigned idxtoTest = ii + 1;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
if( ( idxtoTest >= size() )
|
|
|
|
|| ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
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
|
|
|
// Net analysis to update m_ConnectionType
|
2009-07-12 15:29:42 +00:00
|
|
|
NetEnd = idxtoTest;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
/* set m_ConnectionType member to StateFlag for all items of
|
2009-11-04 20:46:53 +00:00
|
|
|
* this net: */
|
2009-07-12 15:29:42 +00:00
|
|
|
for( unsigned kk = NetStart; kk < NetEnd; kk++ )
|
2013-09-27 12:30:35 +00:00
|
|
|
GetItem( kk )->m_ConnectionType = StateFlag;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
if( idxtoTest >= size() )
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
|
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
|
|
|
// Start Analysis next Net
|
2008-12-10 16:49:53 +00:00
|
|
|
StateFlag = UNCONNECTED;
|
2009-07-12 15:29:42 +00:00
|
|
|
NetStart = idxtoTest;
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* test the current item: if this is a pin and if the reference item
|
|
|
|
* is also a pin, then 2 pins are connected, so set StateFlag to
|
|
|
|
* PAD_CONNECT (can be already done) Of course, if the current
|
|
|
|
* item is a no connect symbol, set StateFlag to
|
|
|
|
* NOCONNECT_SYMBOL_PRESENT to inhibit error diags. However if
|
|
|
|
* StateFlag is already set to PAD_CONNECT this state is kept (the
|
|
|
|
* no connect symbol was surely an error and an ERC will report this)
|
2009-07-12 15:29:42 +00:00
|
|
|
*/
|
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
|
|
|
for( ; ; idxtoTest++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
if( ( idxtoTest >= size() )
|
|
|
|
|| ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
switch( GetItem( idxtoTest )->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
2009-11-04 20:46:53 +00:00
|
|
|
wxMessageBox( wxT( "BuildNetListBase() error" ) );
|
2009-07-12 15:29:42 +00:00
|
|
|
break;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SEGMENT:
|
|
|
|
case NET_LABEL:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERLABEL:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBLABEL:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_PINLABEL:
|
|
|
|
case NET_BUS:
|
|
|
|
case NET_BUSLABELMEMBER:
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2011-10-07 14:41:30 +00:00
|
|
|
case NET_JUNCTION:
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_PIN:
|
|
|
|
if( NetItemRef->m_Type == NET_PIN )
|
2008-01-05 17:30:56 +00:00
|
|
|
StateFlag = PAD_CONNECT;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_NOCONNECT:
|
2008-01-05 17:30:56 +00:00
|
|
|
if( StateFlag != PAD_CONNECT )
|
2009-07-12 15:29:42 +00:00
|
|
|
StateFlag = NOCONNECT_SYMBOL_PRESENT;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|