2011-10-07 14:41:30 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-05-18 09:38:23 +00:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2017-11-18 13:10:32 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2017-09-01 20:42:20 +00:00
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-07 14:41:30 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file sch_screen.cpp
|
|
|
|
* @brief Implementation of SCH_SCREEN and SCH_SCREENS classes.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
2012-04-01 20:51:56 +00:00
|
|
|
#include <common.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <eeschema_id.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2015-04-09 19:37:48 +00:00
|
|
|
#include <kiway.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_item_struct.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2018-01-28 18:12:26 +00:00
|
|
|
#include <plotter.h>
|
2009-09-25 18:49:04 +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 <sch_junction.h>
|
|
|
|
#include <sch_bus_entry.h>
|
|
|
|
#include <sch_line.h>
|
|
|
|
#include <sch_marker.h>
|
|
|
|
#include <sch_no_connect.h>
|
|
|
|
#include <sch_sheet.h>
|
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_text.h>
|
2013-09-25 19:09:57 +00:00
|
|
|
#include <lib_pin.h>
|
2017-09-01 20:42:20 +00:00
|
|
|
#include <symbol_lib_table.h>
|
2018-09-03 13:58:47 +00:00
|
|
|
#include <tool/common_tools.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
#define EESCHEMA_FILE_STAMP "EESchema"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2015-01-06 07:38:58 +00:00
|
|
|
/* Default zoom values. Limited to these values to keep a decent size
|
2009-12-02 21:44:03 +00:00
|
|
|
* to menus
|
|
|
|
*/
|
2011-07-05 12:46:14 +00:00
|
|
|
static double SchematicZoomList[] =
|
2009-02-06 11:45:35 +00:00
|
|
|
{
|
2015-01-06 07:38:58 +00:00
|
|
|
0.5, 0.7, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 8.0, 11.0,
|
|
|
|
13.0, 16.0, 20.0, 26.0, 32.0, 48.0, 64.0, 80.0, 128.0
|
2009-02-06 11:45:35 +00:00
|
|
|
};
|
2009-01-29 14:26:20 +00:00
|
|
|
|
2010-01-29 20:36:12 +00:00
|
|
|
/* Default grid sizes for the schematic editor.
|
2015-07-20 14:11:34 +00:00
|
|
|
* Do NOT add others values (mainly grid values in mm), because they
|
|
|
|
* can break the schematic: Because wires and pins are considered as
|
|
|
|
* connected when the are to the same coordinate we cannot mix
|
|
|
|
* coordinates in mils (internal units) and mm (that cannot exactly
|
|
|
|
* converted in mils in many cases). In fact schematic must only use
|
|
|
|
* 50 and 25 mils to place labels, wires and components others values
|
|
|
|
* are useful only for graphic items (mainly in library editor) so use
|
|
|
|
* integer values in mils only. The 100 mil grid is added to help
|
|
|
|
* conform to the KiCad Library Convention. Which states: "Using a
|
|
|
|
* 100mil grid, pin ends and origin must lie on grid nodes IEC-60617"
|
2010-01-29 20:36:12 +00:00
|
|
|
*/
|
2008-12-05 16:03:05 +00:00
|
|
|
static GRID_TYPE SchematicGridList[] = {
|
2015-07-20 14:11:34 +00:00
|
|
|
{ ID_POPUP_GRID_LEVEL_100, wxRealPoint( 100, 100 ) },
|
2009-02-07 08:33:25 +00:00
|
|
|
{ ID_POPUP_GRID_LEVEL_50, wxRealPoint( 50, 50 ) },
|
|
|
|
{ ID_POPUP_GRID_LEVEL_25, wxRealPoint( 25, 25 ) },
|
|
|
|
{ ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) },
|
|
|
|
{ ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) },
|
|
|
|
{ ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) },
|
2009-10-14 19:43:31 +00:00
|
|
|
{ ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) },
|
2008-12-05 16:03:05 +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
|
|
|
SCH_SCREEN::SCH_SCREEN( KIWAY* aKiway ) :
|
|
|
|
BASE_SCREEN( SCH_SCREEN_T ),
|
|
|
|
KIWAY_HOLDER( aKiway ),
|
2013-10-11 16:24:43 +00:00
|
|
|
m_paper( wxT( "A4" ) )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2015-02-28 20:50:35 +00:00
|
|
|
m_modification_sync = 0;
|
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
SetZoom( 32 );
|
2009-01-29 14:26:20 +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( unsigned i = 0; i < DIM( SchematicZoomList ); i++ )
|
2012-05-06 20:10:43 +00:00
|
|
|
m_ZoomList.push_back( SchematicZoomList[i] );
|
2008-12-05 16:03:05 +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( unsigned i = 0; i < DIM( SchematicGridList ); i++ )
|
2008-12-05 16:03:05 +00:00
|
|
|
AddGrid( SchematicGridList[i] );
|
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
SetGrid( wxRealPoint( 50, 50 ) ); // Default grid size.
|
2011-01-12 21:47:54 +00:00
|
|
|
m_refCount = 0;
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
// Suitable for schematic only. For libedit and viewlib, must be set to true
|
|
|
|
m_Center = false;
|
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
InitDataPoints( m_paper.GetSizeIU() );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
SCH_SCREEN::~SCH_SCREEN()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
ClearUndoRedoList();
|
2018-08-22 15:10:25 +00:00
|
|
|
|
|
|
|
// Now delete items in draw list. We do that only if the list is not empty,
|
|
|
|
// because if the list was appended to another list (see SCH_SCREEN::Append( SCH_SCREEN* aScreen )
|
|
|
|
// it is empty but as no longer the ownership (m_drawList.meOwner == false) of items, and calling
|
|
|
|
// FreeDrawList() with m_drawList.meOwner == false will generate a debug alert in debug mode
|
|
|
|
if( GetDrawItems() )
|
|
|
|
FreeDrawList();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
void SCH_SCREEN::IncRefCount()
|
|
|
|
{
|
|
|
|
m_refCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-12 21:47:54 +00:00
|
|
|
void SCH_SCREEN::DecRefCount()
|
|
|
|
{
|
|
|
|
wxCHECK_RET( m_refCount != 0,
|
|
|
|
wxT( "Screen reference count already zero. Bad programmer!" ) );
|
|
|
|
m_refCount--;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 17:00:04 +00:00
|
|
|
void SCH_SCREEN::Append( SCH_SCREEN* aScreen )
|
|
|
|
{
|
|
|
|
wxCHECK_RET( aScreen, "Invalid screen object." );
|
|
|
|
|
|
|
|
// No need to decend the hierarchy. Once the top level screen is copied, all of it's
|
|
|
|
// children are copied as well.
|
|
|
|
m_drawList.Append( aScreen->m_drawList );
|
|
|
|
|
|
|
|
// This screen owns the objects now. This prevents the object from being delete when
|
|
|
|
// aSheet is deleted.
|
|
|
|
aScreen->m_drawList.SetOwnership( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-15 18:44:24 +00:00
|
|
|
void SCH_SCREEN::Clear()
|
|
|
|
{
|
|
|
|
FreeDrawList();
|
|
|
|
|
2012-05-27 00:19:12 +00:00
|
|
|
// Clear the project settings
|
|
|
|
m_ScreenNumber = m_NumberOfScreens = 1;
|
2012-01-09 08:35:06 +00:00
|
|
|
|
|
|
|
m_titles.Clear();
|
2011-06-15 18:44:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
void SCH_SCREEN::FreeDrawList()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-02-26 18:39:39 +00:00
|
|
|
m_drawList.DeleteAll();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-26 18:39:39 +00:00
|
|
|
void SCH_SCREEN::Remove( SCH_ITEM* aItem )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-02-26 18:39:39 +00:00
|
|
|
m_drawList.Remove( aItem );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2011-03-10 19:36:30 +00:00
|
|
|
void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem )
|
|
|
|
{
|
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
|
|
|
wxCHECK_RET( aItem, wxT( "Cannot delete invalid item from screen." ) );
|
2011-03-10 19:36:30 +00:00
|
|
|
|
|
|
|
SetModify();
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
if( aItem->Type() == SCH_SHEET_PIN_T )
|
2011-03-10 19:36:30 +00:00
|
|
|
{
|
|
|
|
// This structure is attached to a sheet, get the parent sheet object.
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_SHEET_PIN* sheetPin = (SCH_SHEET_PIN*) aItem;
|
|
|
|
SCH_SHEET* sheet = sheetPin->GetParent();
|
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
|
|
|
wxCHECK_RET( sheet,
|
2011-03-10 19:36:30 +00:00
|
|
|
wxT( "Sheet label parent not properly set, bad programmer!" ) );
|
2011-03-30 19:26:05 +00:00
|
|
|
sheet->RemovePin( sheetPin );
|
2011-03-10 19:36:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-26 18:39:39 +00:00
|
|
|
delete m_drawList.Remove( aItem );
|
2011-03-10 19:36:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-05 14:46:51 +00:00
|
|
|
bool SCH_SCREEN::CheckIfOnDrawList( SCH_ITEM* aItem )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-02-26 18:39:39 +00:00
|
|
|
SCH_ITEM* itemList = m_drawList.begin();
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2011-03-10 19:36:30 +00:00
|
|
|
while( itemList )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2011-04-05 14:46:51 +00:00
|
|
|
if( itemList == aItem )
|
2008-02-26 19:19:54 +00:00
|
|
|
return true;
|
2011-03-10 19:36:30 +00:00
|
|
|
|
|
|
|
itemList = itemList->Next();
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T aType ) const
|
2011-01-11 20:34:29 +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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-01-11 20:34:29 +00:00
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
if( (aType == SCH_FIELD_T) && (item->Type() == SCH_COMPONENT_T) )
|
2011-03-10 19:36:30 +00:00
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
2011-03-10 19:36:30 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
for( int i = REFERENCE; i < component->GetFieldCount(); i++ )
|
2011-03-10 19:36:30 +00:00
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
SCH_FIELD* field = component->GetField( i );
|
2011-03-10 19:36:30 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
if( field->HitTest( aPosition, aAccuracy ) )
|
|
|
|
return (SCH_ITEM*) field;
|
2011-03-10 19:36:30 +00:00
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
2011-03-30 19:26:05 +00:00
|
|
|
else if( (aType == SCH_SHEET_PIN_T) && (item->Type() == SCH_SHEET_T) )
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*)item;
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_SHEET_PIN* label = sheet->GetPin( aPosition );
|
2011-03-10 19:36:30 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
if( label )
|
|
|
|
return (SCH_ITEM*) label;
|
|
|
|
}
|
2017-10-26 16:53:17 +00:00
|
|
|
else if( ( ( item->Type() == aType ) || ( aType == NOT_USED ) )
|
|
|
|
&& item->HitTest( aPosition, aAccuracy ) )
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
2011-03-10 19:36:30 +00:00
|
|
|
return item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-26 18:39:39 +00:00
|
|
|
void SCH_SCREEN::ReplaceWires( DLIST< SCH_ITEM >& aWireList )
|
2011-02-05 02:21:11 +00:00
|
|
|
{
|
|
|
|
SCH_ITEM* item;
|
|
|
|
SCH_ITEM* next_item;
|
|
|
|
|
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( item = m_drawList.begin(); item; item = next_item )
|
2011-02-05 02:21:11 +00:00
|
|
|
{
|
|
|
|
next_item = item->Next();
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_LINE_T:
|
2012-02-26 18:39:39 +00:00
|
|
|
Remove( item );
|
2011-02-05 02:21:11 +00:00
|
|
|
delete item;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-26 18:39:39 +00:00
|
|
|
m_drawList.Append( aWireList );
|
2011-02-05 02:21:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-10 19:36:30 +00:00
|
|
|
void SCH_SCREEN::MarkConnections( SCH_LINE* aSegment )
|
|
|
|
{
|
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
|
|
|
wxCHECK_RET( (aSegment) && (aSegment->Type() == SCH_LINE_T),
|
2011-03-10 19:36:30 +00:00
|
|
|
wxT( "Invalid object pointer." ) );
|
|
|
|
|
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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-03-10 19:36:30 +00:00
|
|
|
{
|
|
|
|
if( item->GetFlags() & CANDIDATE )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( item->Type() == SCH_JUNCTION_T )
|
|
|
|
{
|
|
|
|
SCH_JUNCTION* junction = (SCH_JUNCTION*) item;
|
|
|
|
|
2011-10-19 20:32:21 +00:00
|
|
|
if( aSegment->IsEndPoint( junction->GetPosition() ) )
|
2011-03-10 19:36:30 +00:00
|
|
|
item->SetFlags( CANDIDATE );
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item->Type() != SCH_LINE_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
SCH_LINE* segment = (SCH_LINE*) item;
|
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
if( aSegment->IsEndPoint( segment->GetStartPoint() )
|
|
|
|
&& !GetPin( segment->GetStartPoint(), NULL, true ) )
|
2011-03-10 19:36:30 +00:00
|
|
|
{
|
|
|
|
item->SetFlags( CANDIDATE );
|
|
|
|
MarkConnections( segment );
|
|
|
|
}
|
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
if( aSegment->IsEndPoint( segment->GetEndPoint() )
|
|
|
|
&& !GetPin( segment->GetEndPoint(), NULL, true ) )
|
2011-03-10 19:36:30 +00:00
|
|
|
{
|
|
|
|
item->SetFlags( CANDIDATE );
|
|
|
|
MarkConnections( segment );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-27 19:27:24 +00:00
|
|
|
bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew )
|
2011-03-10 19:36:30 +00:00
|
|
|
{
|
2017-12-13 05:12:06 +00:00
|
|
|
bool has_nonparallel[2] = { false };
|
|
|
|
int end_count[2] = { 0 };
|
|
|
|
int pin_count = 0;
|
|
|
|
|
|
|
|
std::vector<SCH_LINE*> lines[2];
|
2017-11-27 19:27:24 +00:00
|
|
|
|
|
|
|
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-03-10 19:36:30 +00:00
|
|
|
{
|
2017-11-27 19:27:24 +00:00
|
|
|
if( item->GetFlags() & STRUCT_DELETED )
|
|
|
|
continue;
|
2017-12-07 20:19:53 +00:00
|
|
|
|
2017-11-27 19:27:24 +00:00
|
|
|
if( aNew && ( item->Type() == SCH_JUNCTION_T ) && ( item->HitTest( aPosition ) ) )
|
|
|
|
return false;
|
2011-03-10 19:36:30 +00:00
|
|
|
|
2017-12-07 20:19:53 +00:00
|
|
|
if( ( item->Type() == SCH_LINE_T )
|
2017-12-13 05:12:06 +00:00
|
|
|
&& ( item->HitTest( aPosition, 0 ) ) )
|
|
|
|
{
|
|
|
|
if( item->GetLayer() == LAYER_WIRE )
|
|
|
|
lines[0].push_back( (SCH_LINE*) item );
|
|
|
|
else if( item->GetLayer() == LAYER_BUS )
|
|
|
|
lines[1].push_back( (SCH_LINE*) item );
|
|
|
|
}
|
2017-12-07 20:19:53 +00:00
|
|
|
|
|
|
|
if( ( item->Type() == SCH_COMPONENT_T )
|
|
|
|
&& ( item->IsConnected( aPosition ) ) )
|
|
|
|
pin_count++;
|
2011-03-10 19:36:30 +00:00
|
|
|
}
|
|
|
|
|
2017-12-13 05:12:06 +00:00
|
|
|
for( int i = 0; i < 2; i++ )
|
2017-11-27 19:27:24 +00:00
|
|
|
{
|
2017-12-13 05:12:06 +00:00
|
|
|
bool removed_overlapping = false;
|
|
|
|
end_count[i] = lines[i].size();
|
|
|
|
|
|
|
|
for( auto line = lines[i].begin(); line < lines[i].end(); line++ )
|
2017-11-27 19:27:24 +00:00
|
|
|
{
|
2017-12-13 05:12:06 +00:00
|
|
|
// Consider ending on a line to be equivalent to two endpoints because
|
|
|
|
// we will want to split the line if anything else connects
|
|
|
|
if( !(*line)->IsEndPoint( aPosition ) )
|
|
|
|
end_count[i]++;
|
|
|
|
|
|
|
|
for( auto second_line = lines[i].end() - 1; second_line > line; second_line-- )
|
|
|
|
{
|
|
|
|
if( !(*line)->IsParallel( *second_line ) )
|
|
|
|
has_nonparallel[i] = true;
|
|
|
|
else if( !removed_overlapping
|
|
|
|
&& (*line)->IsSameQuadrant( *second_line, aPosition ) )
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Overlapping lines that point in the same direction should not be counted
|
|
|
|
* as extra end_points. We remove the overlapping lines, being careful to only
|
|
|
|
* remove them once.
|
|
|
|
*/
|
|
|
|
removed_overlapping = true;
|
|
|
|
end_count[i]--;
|
|
|
|
}
|
|
|
|
}
|
2017-11-27 19:27:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-13 05:12:06 +00:00
|
|
|
//
|
2017-11-27 19:27:24 +00:00
|
|
|
|
2017-12-07 20:19:53 +00:00
|
|
|
// If there are three or more endpoints
|
2017-12-13 05:12:06 +00:00
|
|
|
if( pin_count + end_count[0] > 2 )
|
2017-11-27 19:27:24 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
// If there is at least one segment that ends on a non-parallel line or
|
|
|
|
// junction of two other lines
|
2017-12-13 05:12:06 +00:00
|
|
|
if( has_nonparallel[0] && end_count[0] > 2 )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Check for bus - bus junction requirements
|
|
|
|
if( has_nonparallel[1] && end_count[1] > 2 )
|
2017-11-27 19:27:24 +00:00
|
|
|
return true;
|
|
|
|
|
2011-03-10 19:36:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer )
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( aLayer == LAYER_NOTES || aLayer == LAYER_BUS || aLayer == LAYER_WIRE, false,
|
|
|
|
wxT( "Invalid layer type passed to SCH_SCREEN::IsTerminalPoint()." ) );
|
|
|
|
|
|
|
|
SCH_SHEET_PIN* label;
|
|
|
|
SCH_TEXT* text;
|
|
|
|
|
|
|
|
switch( aLayer )
|
|
|
|
{
|
|
|
|
case LAYER_BUS:
|
|
|
|
|
|
|
|
if( GetBus( aPosition ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
label = GetSheetLabel( aPosition );
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( label && IsBusLabel( label->GetText() ) && label->IsConnected( aPosition ) )
|
2011-03-25 19:16:05 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
text = GetLabel( aPosition );
|
|
|
|
|
|
|
|
if( text && IsBusLabel( text->GetText() ) && text->IsConnected( aPosition )
|
|
|
|
&& (text->Type() != SCH_LABEL_T) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAYER_NOTES:
|
|
|
|
|
|
|
|
if( GetLine( aPosition ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAYER_WIRE:
|
2013-04-01 10:35:20 +00:00
|
|
|
if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_WIRE_ENTRY_T) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_BUS_ENTRY_T) )
|
2011-03-25 19:16:05 +00:00
|
|
|
return true;
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_JUNCTION_T ) )
|
2011-03-25 19:16:05 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
if( GetPin( aPosition, NULL, true ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( GetWire( aPosition ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
text = GetLabel( aPosition );
|
|
|
|
|
|
|
|
if( text && text->IsConnected( aPosition ) && !IsBusLabel( text->GetText() ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
label = GetSheetLabel( aPosition );
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( label && label->IsConnected( aPosition ) && !IsBusLabel( label->GetText() ) )
|
2011-03-25 19:16:05 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-22 00:48:25 +00:00
|
|
|
void SCH_SCREEN::UpdateSymbolLinks( bool aForce )
|
2011-01-11 20:34:29 +00:00
|
|
|
{
|
2014-08-18 16:39:51 +00:00
|
|
|
// Initialize or reinitialize the pointer to the LIB_PART for each component
|
|
|
|
// found in m_drawList, but only if needed (change in lib or schematic)
|
|
|
|
// therefore the calculation time is usually very low.
|
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( m_drawList.GetCount() )
|
|
|
|
{
|
2017-09-01 20:42:20 +00:00
|
|
|
SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable();
|
|
|
|
int mod_hash = libs->GetModifyHash();
|
2017-12-11 03:28:34 +00:00
|
|
|
SCH_TYPE_COLLECTOR c;
|
|
|
|
|
|
|
|
c.Collect( GetDrawItems(), SCH_COLLECTOR::ComponentsOnly );
|
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
|
|
|
|
|
|
|
// Must we resolve?
|
2017-10-22 00:48:25 +00:00
|
|
|
if( (m_modification_sync != mod_hash) || aForce )
|
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
|
|
|
{
|
2017-09-01 20:42:20 +00:00
|
|
|
SCH_COMPONENT::ResolveAll( c, *libs, Prj().SchLibs()->GetCacheLibrary() );
|
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
|
|
|
|
|
|
|
m_modification_sync = mod_hash; // note the last mod_hash
|
|
|
|
}
|
2017-12-11 03:28:34 +00:00
|
|
|
// Resolving will update the pin caches but we must ensure that this happens
|
|
|
|
// even if the libraries don't change.
|
|
|
|
else
|
|
|
|
SCH_COMPONENT::UpdateAllPinCaches( c );
|
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
|
|
|
}
|
2014-08-18 16:39:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, COLOR4D aColor )
|
2014-08-18 16:39:51 +00:00
|
|
|
{
|
|
|
|
/* note: SCH_SCREEN::Draw is useful only for schematic.
|
|
|
|
* library editor and library viewer do not use m_drawList, and therefore
|
|
|
|
* their SCH_SCREEN::Draw() draws nothing
|
|
|
|
*/
|
2017-11-03 17:56:59 +00:00
|
|
|
std::vector< SCH_ITEM* > junctions;
|
2014-08-18 16:39:51 +00:00
|
|
|
|
2017-07-12 09:55:51 +00:00
|
|
|
// Ensure links are up to date, even if a library was reloaded for some reason:
|
2017-10-22 00:48:25 +00:00
|
|
|
UpdateSymbolLinks();
|
2017-07-12 09:55:51 +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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-01-11 20:34:29 +00:00
|
|
|
{
|
2011-07-08 19:55:41 +00:00
|
|
|
if( item->IsMoving() || item->IsResized() )
|
2011-01-11 20:34:29 +00:00
|
|
|
continue;
|
|
|
|
|
2017-11-03 17:56:59 +00:00
|
|
|
if( item->Type() == SCH_JUNCTION_T )
|
|
|
|
junctions.push_back( item );
|
|
|
|
else
|
|
|
|
// uncomment line below when there is a virtual EDA_ITEM::GetBoundingBox()
|
|
|
|
// if( panel->GetClipBox().Intersects( item->GetBoundingBox() ) )
|
|
|
|
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
|
2011-01-11 20:34:29 +00:00
|
|
|
}
|
2017-11-03 17:56:59 +00:00
|
|
|
|
|
|
|
for( auto item : junctions )
|
|
|
|
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
|
2011-01-11 20:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
void SCH_SCREEN::Plot( PLOTTER* aPlotter )
|
|
|
|
{
|
2017-07-12 09:55:51 +00:00
|
|
|
// Ensure links are up to date, even if a library was reloaded for some reason:
|
2017-10-22 00:48:25 +00:00
|
|
|
UpdateSymbolLinks();
|
2017-07-12 09:55:51 +00:00
|
|
|
|
2012-02-26 18:39:39 +00:00
|
|
|
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->SetCurrentLineWidth( item->GetPenSize() );
|
2011-06-17 13:24:22 +00:00
|
|
|
item->Plot( aPlotter );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-26 20:25:48 +00:00
|
|
|
void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
|
|
|
|
{
|
|
|
|
if( aItemCount == 0 )
|
|
|
|
return;
|
|
|
|
|
2017-11-08 16:32:56 +00:00
|
|
|
for( auto& command : aList.m_CommandsList )
|
2010-10-26 20:25:48 +00:00
|
|
|
{
|
2017-11-08 16:32:56 +00:00
|
|
|
command->ClearListAndDeleteItems();
|
|
|
|
delete command;
|
2010-10-26 20:25:48 +00:00
|
|
|
}
|
2017-11-08 16:32:56 +00:00
|
|
|
|
|
|
|
aList.m_CommandsList.clear();
|
2010-10-26 20:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
void SCH_SCREEN::ClearDrawingState()
|
|
|
|
{
|
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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-03-10 19:36:30 +00:00
|
|
|
item->ClearFlags();
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-10 20:35:24 +00:00
|
|
|
LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent,
|
2011-03-10 19:36:30 +00:00
|
|
|
bool aEndPointOnly ) const
|
2010-12-13 15:59:00 +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
|
|
|
SCH_ITEM* item;
|
|
|
|
SCH_COMPONENT* component = NULL;
|
|
|
|
LIB_PIN* pin = NULL;
|
2010-12-13 15:59:00 +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( item = m_drawList.begin(); item; item = item->Next() )
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
component = (SCH_COMPONENT*) item;
|
|
|
|
|
2011-05-05 17:45:35 +00:00
|
|
|
if( aEndPointOnly )
|
|
|
|
{
|
|
|
|
pin = NULL;
|
2011-12-07 20:19:29 +00:00
|
|
|
|
2017-03-04 00:04:43 +00:00
|
|
|
auto part = component->GetPartRef().lock();
|
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( !part )
|
2011-05-05 17:45:35 +00:00
|
|
|
continue;
|
2011-12-07 20:19:29 +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( pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
2011-05-05 17:45:35 +00:00
|
|
|
{
|
|
|
|
// Skip items not used for this part.
|
|
|
|
if( component->GetUnit() && pin->GetUnit() &&
|
|
|
|
( pin->GetUnit() != component->GetUnit() ) )
|
|
|
|
continue;
|
2011-12-07 20:19:29 +00:00
|
|
|
|
2011-05-05 17:45:35 +00:00
|
|
|
if( component->GetConvert() && pin->GetConvert() &&
|
|
|
|
( pin->GetConvert() != component->GetConvert() ) )
|
|
|
|
continue;
|
2011-12-07 20:19:29 +00:00
|
|
|
|
2011-05-05 17:45:35 +00:00
|
|
|
if(component->GetPinPhysicalPosition( pin ) == aPosition )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( pin )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T );
|
2011-12-07 20:19:29 +00:00
|
|
|
|
2011-05-05 17:45:35 +00:00
|
|
|
if( pin )
|
|
|
|
break;
|
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
2011-01-10 20:35:24 +00:00
|
|
|
|
2011-05-05 17:45:35 +00:00
|
|
|
if( pin && aComponent )
|
2010-12-13 15:59:00 +00:00
|
|
|
*aComponent = component;
|
|
|
|
|
|
|
|
return pin;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-31 13:27:05 +00:00
|
|
|
SCH_SHEET* SCH_SCREEN::GetSheet( const wxString& aName )
|
|
|
|
{
|
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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-08-31 13:27:05 +00:00
|
|
|
{
|
|
|
|
if( item->Type() != SCH_SHEET_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
if( aName.CmpNoCase( sheet->GetName() ) == 0 )
|
2011-08-31 13:27:05 +00:00
|
|
|
return sheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-11 20:34:29 +00:00
|
|
|
SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition )
|
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_SHEET_PIN* sheetPin = NULL;
|
2011-01-11 20:34:29 +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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-01-11 20:34:29 +00:00
|
|
|
{
|
|
|
|
if( item->Type() != SCH_SHEET_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
2011-03-30 19:26:05 +00:00
|
|
|
sheetPin = sheet->GetPin( aPosition );
|
2011-01-11 20:34:29 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
if( sheetPin )
|
2011-01-11 20:34:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
return sheetPin;
|
2011-01-11 20:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
int SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions ) const
|
|
|
|
{
|
|
|
|
SCH_ITEM* item;
|
|
|
|
int count = 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
|
|
|
for( item = m_drawList.begin(); item; item = item->Next() )
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
|
|
|
if( item->Type() == SCH_JUNCTION_T && !aTestJunctions )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( item->IsConnected( aPos ) )
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:22:45 +00:00
|
|
|
void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
|
2010-12-31 19:47:39 +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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2010-12-31 19:47:39 +00:00
|
|
|
{
|
|
|
|
if( item->Type() == SCH_COMPONENT_T )
|
|
|
|
{
|
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
|
|
|
|
2016-02-15 20:22:45 +00:00
|
|
|
component->ClearAnnotation( aSheetPath );
|
2013-07-03 07:27:52 +00:00
|
|
|
|
|
|
|
// Clear the modified component flag set by component->ClearAnnotation
|
|
|
|
// because we do not use it here and we should not leave this flag set,
|
2018-06-22 13:05:11 +00:00
|
|
|
// when an editing is finished:
|
2013-07-03 07:27:52 +00:00
|
|
|
component->ClearFlags();
|
2010-12-31 19:47:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-03 10:11:39 +00:00
|
|
|
void SCH_SCREEN::EnsureAlternateReferencesExist()
|
|
|
|
{
|
|
|
|
if( GetClientSheetPathsCount() <= 1 ) // No need for alternate reference
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
|
|
|
{
|
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Add (when not existing) all sheet path entries
|
|
|
|
for( unsigned int ii = 0; ii < m_clientSheetPathList.GetCount(); ii++ )
|
2018-09-04 16:46:03 +00:00
|
|
|
((SCH_COMPONENT*)item)->AddSheetPathReferenceEntryIfMissing( m_clientSheetPathList[ii] );
|
2018-09-03 10:11:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
void SCH_SCREEN::GetHierarchicalItems( EDA_ITEMS& aItems )
|
2010-12-31 19:47:39 +00:00
|
|
|
{
|
2012-02-26 18:39:39 +00:00
|
|
|
SCH_ITEM* item = m_drawList.begin();
|
2010-12-31 19:47:39 +00:00
|
|
|
|
|
|
|
while( item )
|
|
|
|
{
|
|
|
|
if( ( item->Type() == SCH_SHEET_T ) || ( item->Type() == SCH_COMPONENT_T ) )
|
|
|
|
aItems.push_back( item );
|
|
|
|
|
|
|
|
item = item->Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-07 19:24:24 +00:00
|
|
|
void SCH_SCREEN::SelectBlockItems()
|
|
|
|
{
|
2017-11-15 22:51:18 +00:00
|
|
|
auto addConnections = [ this ]( SCH_ITEM* item ) -> void
|
|
|
|
{
|
|
|
|
std::vector< wxPoint > connections;
|
|
|
|
item->GetConnectionPoints( connections );
|
|
|
|
for( auto conn : connections )
|
2017-12-01 01:21:23 +00:00
|
|
|
addConnectedItemsToBlock( item, conn );
|
2017-11-15 22:51:18 +00:00
|
|
|
};
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
PICKED_ITEMS_LIST* pickedlist = &m_BlockLocate.GetItems();
|
2011-01-07 19:24:24 +00:00
|
|
|
|
|
|
|
if( pickedlist->GetCount() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ClearDrawingState();
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
|
|
|
|
{
|
2014-07-29 16:38:27 +00:00
|
|
|
SCH_ITEM* item = (SCH_ITEM*) pickedlist->GetPickedItem( ii );
|
2011-03-10 19:36:30 +00:00
|
|
|
item->SetFlags( SELECTED );
|
2011-01-07 19:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !m_BlockLocate.IsDragging() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Select all the items in the screen connected to the items in the block.
|
2011-01-20 11:26:10 +00:00
|
|
|
// be sure end lines that are on the block limits are seen inside this block
|
2012-03-26 23:47:08 +00:00
|
|
|
m_BlockLocate.Inflate( 1 );
|
2011-01-20 11:26:10 +00:00
|
|
|
unsigned last_select_id = pickedlist->GetCount();
|
2011-03-10 19:36:30 +00:00
|
|
|
|
2014-07-29 16:38:27 +00:00
|
|
|
for( unsigned ii = 0; ii < last_select_id; ii++ )
|
2011-01-07 19:24:24 +00:00
|
|
|
{
|
2014-07-29 16:38:27 +00:00
|
|
|
SCH_ITEM* item = (SCH_ITEM*)pickedlist->GetPickedItem( ii );
|
2012-12-29 12:55:36 +00:00
|
|
|
item->SetFlags( IS_DRAGGED );
|
2011-01-07 19:24:24 +00:00
|
|
|
|
|
|
|
if( item->Type() == SCH_LINE_T )
|
|
|
|
{
|
|
|
|
item->IsSelectStateChanged( m_BlockLocate );
|
2011-03-10 19:36:30 +00:00
|
|
|
|
2014-07-29 16:38:27 +00:00
|
|
|
if( !item->IsSelected() )
|
2011-01-20 11:26:10 +00:00
|
|
|
{ // This is a special case:
|
|
|
|
// this selected wire has no ends in block.
|
|
|
|
// But it was selected (because it intersects the selecting area),
|
|
|
|
// so we must keep it selected and select items connected to it
|
2018-04-08 10:28:59 +00:00
|
|
|
// Note: another option could be: remove it from drag list
|
2011-03-10 19:36:30 +00:00
|
|
|
item->SetFlags( SELECTED | SKIP_STRUCT );
|
2017-11-15 22:51:18 +00:00
|
|
|
addConnections( item );
|
2011-01-20 11:26:10 +00:00
|
|
|
}
|
2011-03-10 19:36:30 +00:00
|
|
|
|
|
|
|
pickedlist->SetPickerFlags( item->GetFlags(), ii );
|
2011-01-07 19:24:24 +00:00
|
|
|
}
|
|
|
|
else if( item->IsConnectable() )
|
|
|
|
{
|
2017-11-15 22:51:18 +00:00
|
|
|
addConnections( item );
|
|
|
|
}
|
|
|
|
}
|
2011-01-07 19:24:24 +00:00
|
|
|
|
2017-12-19 17:45:56 +00:00
|
|
|
// Select the items that are connected to a block object that was added
|
2017-11-15 22:51:18 +00:00
|
|
|
// to our selection list in the last step.
|
|
|
|
for( unsigned ii = last_select_id; ii < pickedlist->GetCount(); ii++ )
|
|
|
|
{
|
|
|
|
SCH_ITEM* item = (SCH_ITEM*)pickedlist->GetPickedItem( ii );
|
2011-01-07 19:24:24 +00:00
|
|
|
|
2017-12-19 17:45:56 +00:00
|
|
|
if( item->Type() == SCH_COMPONENT_T ||
|
|
|
|
item->Type() == SCH_BUS_BUS_ENTRY_T ||
|
|
|
|
item->Type() == SCH_BUS_WIRE_ENTRY_T ||
|
|
|
|
item->Type() == SCH_SHEET_T ||
|
|
|
|
( item->Type() == SCH_LINE_T && !( item->GetFlags() & ( ENDPOINT | STARTPOINT ) ) ) )
|
2017-11-15 22:51:18 +00:00
|
|
|
{
|
|
|
|
item->SetFlags( IS_DRAGGED );
|
|
|
|
addConnections( item );
|
2011-01-07 19:24:24 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-20 11:26:10 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
m_BlockLocate.Inflate( -1 );
|
2011-01-07 19:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-01 01:21:23 +00:00
|
|
|
void SCH_SCREEN::addConnectedItemsToBlock( const SCH_ITEM* aItem, const wxPoint& position )
|
2011-01-07 19:24:24 +00:00
|
|
|
{
|
|
|
|
SCH_ITEM* item;
|
|
|
|
ITEM_PICKER picker;
|
|
|
|
|
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( item = m_drawList.begin(); item; item = item->Next() )
|
2011-01-07 19:24:24 +00:00
|
|
|
{
|
|
|
|
|
2017-12-19 17:45:56 +00:00
|
|
|
if( !item->IsConnectable() || ( item->GetFlags() & SKIP_STRUCT )
|
|
|
|
|| !item->CanConnect( aItem ) || item == aItem )
|
2017-12-01 01:21:23 +00:00
|
|
|
continue;
|
|
|
|
|
2011-01-20 11:26:10 +00:00
|
|
|
// A line having 2 ends, it can be tested twice: one time per end
|
2011-01-07 19:24:24 +00:00
|
|
|
if( item->Type() == SCH_LINE_T )
|
|
|
|
{
|
|
|
|
SCH_LINE* line = (SCH_LINE*) item;
|
|
|
|
|
2017-12-19 17:45:56 +00:00
|
|
|
if( !item->HitTest( position ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// First time through. Flags set to denote an end that is not moving
|
|
|
|
if( !item->IsSelected() )
|
|
|
|
item->SetFlags( CANDIDATE | STARTPOINT | ENDPOINT );
|
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
if( line->GetStartPoint() == position )
|
2011-03-10 19:36:30 +00:00
|
|
|
item->ClearFlags( STARTPOINT );
|
2011-12-07 20:19:29 +00:00
|
|
|
else if( line->GetEndPoint() == position )
|
2011-03-10 19:36:30 +00:00
|
|
|
item->ClearFlags( ENDPOINT );
|
2017-12-19 17:45:56 +00:00
|
|
|
else
|
|
|
|
// This picks up items such as labels that can connect to the middle of a line
|
|
|
|
item->ClearFlags( STARTPOINT | ENDPOINT );
|
2011-01-07 19:24:24 +00:00
|
|
|
}
|
2017-12-19 17:45:56 +00:00
|
|
|
// We want to move a mid-connected label or bus entry when the full line is being moved
|
|
|
|
else if( !item->IsSelected()
|
|
|
|
&& aItem->Type() == SCH_LINE_T
|
|
|
|
&& !( aItem->GetFlags() & ( ENDPOINT | STARTPOINT ) ) )
|
|
|
|
{
|
|
|
|
std::vector< wxPoint > connections;
|
|
|
|
item->GetConnectionPoints( connections );
|
2011-01-07 19:24:24 +00:00
|
|
|
|
2017-12-19 17:45:56 +00:00
|
|
|
for( auto conn : connections )
|
|
|
|
{
|
|
|
|
if( aItem->HitTest( conn ) )
|
|
|
|
{
|
|
|
|
item->SetFlags( CANDIDATE );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item->IsSelected() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( ( item->GetFlags() & CANDIDATE ) || item->IsConnected( position ) ) // Deal with all non-line items
|
2011-01-20 11:26:10 +00:00
|
|
|
{
|
2017-12-19 17:45:56 +00:00
|
|
|
item->ClearFlags( CANDIDATE );
|
|
|
|
item->SetFlags( SELECTED );
|
|
|
|
picker.SetItem( item );
|
2012-02-05 13:02:46 +00:00
|
|
|
picker.SetFlags( item->GetFlags() );
|
2012-03-26 23:47:08 +00:00
|
|
|
m_BlockLocate.GetItems().PushItem( picker );
|
2011-01-20 11:26:10 +00:00
|
|
|
}
|
2011-01-07 19:24:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-10 16:50:40 +00:00
|
|
|
int SCH_SCREEN::UpdatePickList()
|
|
|
|
{
|
|
|
|
ITEM_PICKER picker;
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT area;
|
2012-12-29 12:55:36 +00:00
|
|
|
unsigned count;
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
area.SetOrigin( m_BlockLocate.GetOrigin() );
|
2011-01-10 16:50:40 +00:00
|
|
|
area.SetSize( m_BlockLocate.GetSize() );
|
|
|
|
area.Normalize();
|
|
|
|
|
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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-01-10 16:50:40 +00:00
|
|
|
{
|
|
|
|
// An item is picked if its bounding box intersects the reference area.
|
2018-09-06 13:11:01 +00:00
|
|
|
if( item->HitTest( area ) &&
|
|
|
|
( !m_BlockLocate.IsDragging() || item->IsType( SCH_COLLECTOR::DraggableItems ) ) )
|
2011-01-10 16:50:40 +00:00
|
|
|
{
|
2011-03-10 19:36:30 +00:00
|
|
|
picker.SetItem( item );
|
2011-01-10 16:50:40 +00:00
|
|
|
m_BlockLocate.PushItem( picker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-29 12:55:36 +00:00
|
|
|
// if the block is composed of one item,
|
|
|
|
// select it as the current item
|
|
|
|
count = m_BlockLocate.GetCount();
|
|
|
|
if( count == 1 )
|
|
|
|
{
|
|
|
|
SetCurItem( (SCH_ITEM*) m_BlockLocate.GetItem( 0 ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetCurItem( NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
2011-01-10 16:50:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-19 15:41:32 +00:00
|
|
|
bool SCH_SCREEN::TestDanglingEnds()
|
2011-01-21 19:30:59 +00:00
|
|
|
{
|
|
|
|
SCH_ITEM* item;
|
|
|
|
std::vector< DANGLING_END_ITEM > endPoints;
|
2016-02-19 15:41:32 +00:00
|
|
|
bool hasStateChanged = false;
|
2011-01-21 19:30:59 +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( item = m_drawList.begin(); item; item = item->Next() )
|
2011-01-21 19:30:59 +00:00
|
|
|
item->GetEndPoints( endPoints );
|
|
|
|
|
2012-02-26 18:39:39 +00:00
|
|
|
for( item = m_drawList.begin(); item; item = item->Next() )
|
2011-01-21 19:30:59 +00:00
|
|
|
{
|
2016-02-19 15:41:32 +00:00
|
|
|
if( item->IsDanglingStateChanged( endPoints ) )
|
2017-02-20 16:57:41 +00:00
|
|
|
{
|
2016-02-19 15:41:32 +00:00
|
|
|
hasStateChanged = true;
|
2017-02-20 16:57:41 +00:00
|
|
|
}
|
2011-01-21 19:30:59 +00:00
|
|
|
}
|
|
|
|
|
2016-02-19 15:41:32 +00:00
|
|
|
return hasStateChanged;
|
2011-01-21 19:30:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
int SCH_SCREEN::GetNode( const wxPoint& aPosition, EDA_ITEMS& aList )
|
|
|
|
{
|
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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
|
|
|
if( item->Type() == SCH_LINE_T && item->HitTest( aPosition )
|
|
|
|
&& (item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE) )
|
|
|
|
{
|
|
|
|
aList.push_back( item );
|
|
|
|
}
|
|
|
|
else if( item->Type() == SCH_JUNCTION_T && item->HitTest( aPosition ) )
|
|
|
|
{
|
|
|
|
aList.push_back( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (int) aList.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_LINE* SCH_SCREEN::GetWireOrBus( const wxPoint& aPosition )
|
|
|
|
{
|
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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
|
|
|
if( (item->Type() == SCH_LINE_T) && item->HitTest( aPosition )
|
|
|
|
&& (item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE) )
|
|
|
|
{
|
|
|
|
return (SCH_LINE*) item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_LINE* SCH_SCREEN::GetLine( const wxPoint& aPosition, int aAccuracy, int aLayer,
|
|
|
|
SCH_LINE_TEST_T aSearchType )
|
|
|
|
{
|
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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
|
|
|
if( item->Type() != SCH_LINE_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( item->GetLayer() != aLayer )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( !item->HitTest( aPosition, aAccuracy ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch( aSearchType )
|
|
|
|
{
|
|
|
|
case ENTIRE_LENGTH_T:
|
|
|
|
return (SCH_LINE*) item;
|
|
|
|
|
|
|
|
case EXCLUDE_END_POINTS_T:
|
|
|
|
if( !( (SCH_LINE*) item )->IsEndPoint( aPosition ) )
|
|
|
|
return (SCH_LINE*) item;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case END_POINTS_ONLY_T:
|
|
|
|
if( ( (SCH_LINE*) item )->IsEndPoint( aPosition ) )
|
|
|
|
return (SCH_LINE*) item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy )
|
|
|
|
{
|
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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
|
|
|
if( item->HitTest( aPosition, aAccuracy ) )
|
|
|
|
return (SCH_TEXT*) item;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:14:07 +00:00
|
|
|
bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxString& aReference,
|
2011-03-28 18:23:01 +00:00
|
|
|
const wxString& aFootPrint, bool aSetVisible )
|
|
|
|
{
|
|
|
|
SCH_COMPONENT* component;
|
|
|
|
bool found = false;
|
|
|
|
|
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( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
2011-03-28 18:23:01 +00:00
|
|
|
{
|
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
component = (SCH_COMPONENT*) item;
|
|
|
|
|
2016-02-15 20:17:51 +00:00
|
|
|
if( aReference.CmpNoCase( component->GetRef( aSheetPath ) ) == 0 )
|
2011-03-28 18:23:01 +00:00
|
|
|
{
|
|
|
|
// Found: Init Footprint Field
|
|
|
|
|
|
|
|
/* Give a reasonable value to the field position and
|
|
|
|
* orientation, if the text is empty at position 0, because
|
|
|
|
* it is probably not yet initialized
|
|
|
|
*/
|
2011-08-19 13:08:24 +00:00
|
|
|
SCH_FIELD * fpfield = component->GetField( FOOTPRINT );
|
2013-03-18 19:36:07 +00:00
|
|
|
if( fpfield->GetText().IsEmpty()
|
2017-01-23 20:30:11 +00:00
|
|
|
&& ( fpfield->GetTextPos() == component->GetPosition() ) )
|
2011-03-28 18:23:01 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
fpfield->SetTextAngle( component->GetField( VALUE )->GetTextAngle() );
|
|
|
|
fpfield->SetTextPos( component->GetField( VALUE )->GetTextPos() );
|
|
|
|
fpfield->SetTextSize( component->GetField( VALUE )->GetTextSize() );
|
2011-12-07 20:19:29 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( fpfield->GetTextAngle() == 0.0 )
|
2013-03-18 19:36:07 +00:00
|
|
|
fpfield->Offset( wxPoint( 0, 100 ) );
|
2011-08-19 13:08:24 +00:00
|
|
|
else
|
2013-03-18 19:36:07 +00:00
|
|
|
fpfield->Offset( wxPoint( 100, 0 ) );
|
2011-03-28 18:23:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
fpfield->SetText( aFootPrint );
|
|
|
|
fpfield->SetVisible( aSetVisible );
|
2011-03-28 18:23:01 +00:00
|
|
|
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-15 12:40:56 +00:00
|
|
|
int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aList,
|
|
|
|
bool aFullConnection )
|
|
|
|
{
|
|
|
|
SCH_ITEM* item;
|
|
|
|
EDA_ITEM* tmp;
|
|
|
|
EDA_ITEMS list;
|
|
|
|
|
|
|
|
// Clear flags member for all items.
|
|
|
|
ClearDrawingState();
|
|
|
|
|
|
|
|
if( GetNode( aPosition, list ) == 0 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for( size_t i = 0; i < list.size(); i++ )
|
|
|
|
{
|
|
|
|
item = (SCH_ITEM*) list[ i ];
|
|
|
|
item->SetFlags( SELECTEDNODE | STRUCT_DELETED );
|
|
|
|
|
|
|
|
/* Put this structure in the picked list: */
|
|
|
|
ITEM_PICKER picker( item, UR_DELETED );
|
|
|
|
aList.PushItem( picker );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mark all wires, junctions, .. connected to the item(s) found.
|
|
|
|
if( aFullConnection )
|
|
|
|
{
|
|
|
|
SCH_LINE* segment;
|
|
|
|
|
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( item = m_drawList.begin(); item; item = item->Next() )
|
2011-04-15 12:40:56 +00:00
|
|
|
{
|
|
|
|
if( !(item->GetFlags() & SELECTEDNODE) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( item->Type() != SCH_LINE_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
MarkConnections( (SCH_LINE*) item );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search all attached wires (i.e wire with one new dangling end )
|
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( item = m_drawList.begin(); item; item = item->Next() )
|
2011-04-15 12:40:56 +00:00
|
|
|
{
|
|
|
|
bool noconnect = false;
|
|
|
|
|
|
|
|
if( item->GetFlags() & STRUCT_DELETED )
|
|
|
|
continue; // Already seen
|
|
|
|
|
|
|
|
if( !(item->GetFlags() & CANDIDATE) )
|
2011-07-04 11:31:31 +00:00
|
|
|
continue; // not a candidate
|
2011-04-15 12:40:56 +00:00
|
|
|
|
|
|
|
if( item->Type() != SCH_LINE_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
item->SetFlags( SKIP_STRUCT );
|
|
|
|
|
|
|
|
segment = (SCH_LINE*) item;
|
|
|
|
|
2011-07-04 11:31:31 +00:00
|
|
|
/* If the wire start point is connected to a wire that was already found
|
2011-04-15 12:40:56 +00:00
|
|
|
* and now is not connected, add the wire to the list. */
|
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( tmp = m_drawList.begin(); tmp; tmp = tmp->Next() )
|
2011-04-15 12:40:56 +00:00
|
|
|
{
|
2011-07-04 11:31:31 +00:00
|
|
|
// Ensure tmp is a previously deleted segment:
|
2011-04-15 12:40:56 +00:00
|
|
|
if( ( tmp->GetFlags() & STRUCT_DELETED ) == 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( tmp->Type() != SCH_LINE_T )
|
|
|
|
continue;
|
|
|
|
|
2011-07-04 11:31:31 +00:00
|
|
|
SCH_LINE* testSegment = (SCH_LINE*) tmp;
|
2011-04-15 12:40:56 +00:00
|
|
|
|
2011-07-04 11:31:31 +00:00
|
|
|
// Test for segment connected to the previously deleted segment:
|
2011-12-07 20:19:29 +00:00
|
|
|
if( testSegment->IsEndPoint( segment->GetStartPoint() ) )
|
2011-04-15 12:40:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-07-04 11:31:31 +00:00
|
|
|
// when tmp != NULL, segment is a new candidate:
|
|
|
|
// put it in deleted list if
|
2018-04-08 10:28:59 +00:00
|
|
|
// the start point is not connected to another item (like pin)
|
2011-12-07 20:19:29 +00:00
|
|
|
if( tmp && !CountConnectedItems( segment->GetStartPoint(), true ) )
|
2011-04-15 12:40:56 +00:00
|
|
|
noconnect = true;
|
|
|
|
|
|
|
|
/* If the wire end point is connected to a wire that has already been found
|
|
|
|
* and now is not connected, add the wire to the list. */
|
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( tmp = m_drawList.begin(); tmp; tmp = tmp->Next() )
|
2011-04-15 12:40:56 +00:00
|
|
|
{
|
2011-07-04 11:31:31 +00:00
|
|
|
// Ensure tmp is a previously deleted segment:
|
2011-04-15 12:40:56 +00:00
|
|
|
if( ( tmp->GetFlags() & STRUCT_DELETED ) == 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( tmp->Type() != SCH_LINE_T )
|
|
|
|
continue;
|
|
|
|
|
2011-07-04 11:31:31 +00:00
|
|
|
SCH_LINE* testSegment = (SCH_LINE*) tmp;
|
|
|
|
|
|
|
|
// Test for segment connected to the previously deleted segment:
|
2011-12-07 20:19:29 +00:00
|
|
|
if( testSegment->IsEndPoint( segment->GetEndPoint() ) )
|
2011-04-15 12:40:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-07-04 11:31:31 +00:00
|
|
|
// when tmp != NULL, segment is a new candidate:
|
|
|
|
// put it in deleted list if
|
2018-04-08 10:28:59 +00:00
|
|
|
// the end point is not connected to another item (like pin)
|
2011-12-07 20:19:29 +00:00
|
|
|
if( tmp && !CountConnectedItems( segment->GetEndPoint(), true ) )
|
2011-04-15 12:40:56 +00:00
|
|
|
noconnect = true;
|
|
|
|
|
|
|
|
item->ClearFlags( SKIP_STRUCT );
|
|
|
|
|
|
|
|
if( noconnect )
|
|
|
|
{
|
|
|
|
item->SetFlags( STRUCT_DELETED );
|
|
|
|
|
|
|
|
ITEM_PICKER picker( item, UR_DELETED );
|
|
|
|
aList.PushItem( picker );
|
|
|
|
|
2012-02-26 18:39:39 +00:00
|
|
|
item = m_drawList.begin();
|
2011-04-15 12:40:56 +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( item = m_drawList.begin(); item; item = item->Next() )
|
2011-04-15 12:40:56 +00:00
|
|
|
{
|
|
|
|
if( item->GetFlags() & STRUCT_DELETED )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( item->Type() != SCH_LABEL_T )
|
|
|
|
continue;
|
|
|
|
|
2011-10-19 20:32:21 +00:00
|
|
|
tmp = GetWireOrBus( ( (SCH_TEXT*) item )->GetPosition() );
|
2011-04-15 12:40:56 +00:00
|
|
|
|
2017-11-27 19:27:24 +00:00
|
|
|
if( tmp && ( tmp->GetFlags() & STRUCT_DELETED ) )
|
2011-04-15 12:40:56 +00:00
|
|
|
{
|
|
|
|
item->SetFlags( STRUCT_DELETED );
|
|
|
|
|
|
|
|
ITEM_PICKER picker( item, UR_DELETED );
|
|
|
|
aList.PushItem( picker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ClearDrawingState();
|
|
|
|
|
|
|
|
return aList.GetCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 17:00:04 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const
|
|
|
|
{
|
|
|
|
// for now, make it look like XML, expand on this later.
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
|
|
|
|
|
|
|
|
for( EDA_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
|
|
|
{
|
|
|
|
item->Show( nestLevel+1, os );
|
|
|
|
}
|
|
|
|
|
|
|
|
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-12-31 19:47:39 +00:00
|
|
|
/**
|
2017-11-18 13:10:32 +00:00
|
|
|
* Sort a list of schematic items by time stamp and type.
|
2010-12-31 19:47:39 +00:00
|
|
|
*/
|
2011-03-25 19:16:05 +00:00
|
|
|
static bool SortByTimeStamp( const EDA_ITEM* item1, const EDA_ITEM* item2 )
|
2010-12-31 19:47:39 +00:00
|
|
|
{
|
2011-12-12 08:37:05 +00:00
|
|
|
int ii = item1->GetTimeStamp() - item2->GetTimeStamp();
|
2010-12-31 19:47:39 +00:00
|
|
|
|
|
|
|
/* If the time stamps are the same, compare type in order to have component objects
|
2011-02-09 12:06:42 +00:00
|
|
|
* before sheet object. This is done because changing the sheet time stamp
|
2010-12-31 19:47:39 +00:00
|
|
|
* before the component time stamp could cause the current annotation to be lost.
|
|
|
|
*/
|
|
|
|
if( ( ii == 0 && ( item1->Type() != item2->Type() ) ) && ( item1->Type() == SCH_SHEET_T ) )
|
|
|
|
ii = -1;
|
|
|
|
|
|
|
|
return ii < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 17:00:04 +00:00
|
|
|
SCH_SCREENS::SCH_SCREENS( SCH_SHEET* aSheet )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
m_index = 0;
|
2017-11-17 17:00:04 +00:00
|
|
|
buildScreenList( ( !aSheet ) ? g_RootSheet : aSheet );
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2010-10-26 20:25:48 +00:00
|
|
|
SCH_SCREENS::~SCH_SCREENS()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_SCREEN* SCH_SCREENS::GetFirst()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
m_index = 0;
|
|
|
|
|
|
|
|
if( m_screens.size() > 0 )
|
|
|
|
return m_screens[0];
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2010-10-26 20:25:48 +00:00
|
|
|
SCH_SCREEN* SCH_SCREENS::GetNext()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
if( m_index < m_screens.size() )
|
|
|
|
m_index++;
|
|
|
|
|
|
|
|
return GetScreen( m_index );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
SCH_SCREEN* SCH_SCREENS::GetScreen( unsigned int aIndex ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
if( aIndex < m_screens.size() )
|
|
|
|
return m_screens[ aIndex ];
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
return NULL;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2017-11-17 17:00:04 +00:00
|
|
|
void SCH_SCREENS::addScreenToList( SCH_SCREEN* aScreen )
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
if( aScreen == NULL )
|
2008-02-26 19:19:54 +00:00
|
|
|
return;
|
2010-10-26 20:25:48 +00:00
|
|
|
|
|
|
|
for( unsigned int i = 0; i < m_screens.size(); i++ )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
if( m_screens[i] == aScreen )
|
2008-02-26 19:19:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-10-26 20:25:48 +00:00
|
|
|
m_screens.push_back( aScreen );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2017-11-17 17:00:04 +00:00
|
|
|
void SCH_SCREENS::buildScreenList( SCH_SHEET* aSheet )
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2017-11-17 17:00:04 +00:00
|
|
|
if( aSheet && aSheet->Type() == SCH_SHEET_T )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2017-11-17 17:00:04 +00:00
|
|
|
SCH_SCREEN* screen = aSheet->GetScreen();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2017-11-17 17:00:04 +00:00
|
|
|
addScreenToList( screen );
|
2014-08-18 16:39:51 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* strct = screen->GetDrawItems();
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
while( strct )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( strct->Type() == SCH_SHEET_T )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2017-11-17 17:00:04 +00:00
|
|
|
buildScreenList( ( SCH_SHEET* )strct );
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
strct = strct->Next();
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2010-12-31 19:47:39 +00:00
|
|
|
|
|
|
|
|
2016-02-15 20:22:45 +00:00
|
|
|
void SCH_SCREENS::ClearAnnotation()
|
|
|
|
{
|
|
|
|
for( size_t i = 0; i < m_screens.size(); i++ )
|
|
|
|
m_screens[i]->ClearAnnotation( NULL );
|
|
|
|
}
|
|
|
|
|
2018-09-03 10:11:39 +00:00
|
|
|
|
|
|
|
void SCH_SCREENS::ClearAnnotationOfNewSheetPaths( SCH_SHEET_LIST& aInitialSheetPathList )
|
|
|
|
{
|
|
|
|
// Clear the annotation for the components inside new sheetpaths
|
|
|
|
// not already in aInitialSheetList
|
|
|
|
SCH_SCREENS screensList( g_RootSheet ); // The list of screens, shared by sheet paths
|
|
|
|
screensList.BuildClientSheetPathList(); // build the shared by sheet paths, by screen
|
|
|
|
|
|
|
|
// Search for new sheet paths, not existing in aInitialSheetPathList
|
|
|
|
// and existing in sheetpathList
|
|
|
|
SCH_SHEET_LIST sheetpathList( g_RootSheet );
|
|
|
|
|
|
|
|
for( SCH_SHEET_PATH& sheetpath: sheetpathList )
|
|
|
|
{
|
|
|
|
bool path_exists = false;
|
|
|
|
|
|
|
|
for( const SCH_SHEET_PATH& existing_sheetpath: aInitialSheetPathList )
|
|
|
|
{
|
|
|
|
if( existing_sheetpath.Path() == sheetpath.Path() )
|
|
|
|
{
|
|
|
|
path_exists = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !path_exists )
|
|
|
|
{
|
|
|
|
// A new sheet path is found: clear the annotation corresponding to this new path:
|
|
|
|
SCH_SCREEN* curr_screen = sheetpath.LastScreen();
|
2018-09-04 16:46:03 +00:00
|
|
|
|
2018-09-03 10:11:39 +00:00
|
|
|
// Clear annotation and create the AR for this path, if not exists,
|
|
|
|
// when the screen is shared by sheet paths.
|
|
|
|
// Otherwise ClearAnnotation do nothing, because the F1 field is used as
|
|
|
|
// reference default value and takes the latest displayed value
|
|
|
|
curr_screen->EnsureAlternateReferencesExist();
|
|
|
|
curr_screen->ClearAnnotation( &sheetpath );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-31 19:47:39 +00:00
|
|
|
int SCH_SCREENS::ReplaceDuplicateTimeStamps()
|
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
EDA_ITEMS items;
|
|
|
|
SCH_ITEM* item;
|
2010-12-31 19:47:39 +00:00
|
|
|
|
|
|
|
for( size_t i = 0; i < m_screens.size(); i++ )
|
|
|
|
m_screens[i]->GetHierarchicalItems( items );
|
|
|
|
|
|
|
|
if( items.size() < 2 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
sort( items.begin(), items.end(), SortByTimeStamp );
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
for( size_t ii = 0; ii < items.size() - 1; ii++ )
|
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
item = (SCH_ITEM*)items[ii];
|
|
|
|
|
|
|
|
SCH_ITEM* nextItem = (SCH_ITEM*)items[ii + 1];
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2011-12-12 08:37:05 +00:00
|
|
|
if( item->GetTimeStamp() == nextItem->GetTimeStamp() )
|
2010-12-31 19:47:39 +00:00
|
|
|
{
|
|
|
|
count++;
|
|
|
|
|
|
|
|
// for a component, update its Time stamp and its paths
|
|
|
|
// (m_PathsAndReferences field)
|
|
|
|
if( item->Type() == SCH_COMPONENT_T )
|
2011-12-07 15:49:32 +00:00
|
|
|
( (SCH_COMPONENT*) item )->SetTimeStamp( GetNewTimeStamp() );
|
2010-12-31 19:47:39 +00:00
|
|
|
|
|
|
|
// for a sheet, update only its time stamp (annotation of its
|
|
|
|
// components will be lost)
|
|
|
|
// @todo: see how to change sheet paths for its cmp list (can
|
|
|
|
// be possible in most cases)
|
|
|
|
else
|
2011-12-12 08:37:05 +00:00
|
|
|
item->SetTimeStamp( GetNewTimeStamp() );
|
2010-12-31 19:47:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-29 12:18:53 +00:00
|
|
|
void SCH_SCREENS::DeleteAllMarkers( enum MARKER_BASE::TYPEMARKER aMarkerType )
|
2011-03-10 19:36:30 +00:00
|
|
|
{
|
|
|
|
SCH_ITEM* item;
|
|
|
|
SCH_ITEM* nextItem;
|
|
|
|
SCH_MARKER* marker;
|
|
|
|
SCH_SCREEN* screen;
|
|
|
|
|
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( screen = GetFirst(); screen; screen = GetNext() )
|
2011-03-10 19:36: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
|
|
|
for( item = screen->GetDrawItems(); item; item = nextItem )
|
2011-03-10 19:36:30 +00:00
|
|
|
{
|
|
|
|
nextItem = item->Next();
|
|
|
|
|
|
|
|
if( item->Type() != SCH_MARKER_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
marker = (SCH_MARKER*) item;
|
|
|
|
|
|
|
|
if( marker->GetMarkerType() != aMarkerType )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
screen->DeleteItem( marker );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
|
|
|
|
2015-07-29 18:06:45 +00:00
|
|
|
int SCH_SCREENS::GetMarkerCount( enum MARKER_BASE::TYPEMARKER aMarkerType,
|
|
|
|
enum MARKER_BASE::MARKER_SEVERITY aSeverity )
|
2011-10-07 14:41:30 +00:00
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
|
2015-07-29 12:18:53 +00:00
|
|
|
for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
|
2011-10-07 14:41:30 +00:00
|
|
|
{
|
2015-07-29 12:18:53 +00:00
|
|
|
for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
|
2011-10-07 14:41:30 +00:00
|
|
|
{
|
|
|
|
if( item->Type() != SCH_MARKER_T )
|
|
|
|
continue;
|
|
|
|
|
2015-07-29 12:18:53 +00:00
|
|
|
SCH_MARKER* marker = (SCH_MARKER*) item;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2015-07-29 12:18:53 +00:00
|
|
|
if( ( aMarkerType != MARKER_BASE::MARKER_UNSPEC ) &&
|
|
|
|
( marker->GetMarkerType() != aMarkerType ) )
|
2011-10-07 14:41:30 +00:00
|
|
|
continue;
|
|
|
|
|
2015-07-29 18:06:45 +00:00
|
|
|
if( aSeverity == MARKER_BASE::MARKER_SEVERITY_UNSPEC ||
|
|
|
|
aSeverity == marker->GetErrorLevel() )
|
2015-07-29 12:18:53 +00:00
|
|
|
count++;
|
2011-10-07 14:41:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2017-03-04 19:49:55 +00:00
|
|
|
|
2017-10-22 00:48:25 +00:00
|
|
|
void SCH_SCREENS::UpdateSymbolLinks( bool aForce )
|
2017-03-04 19:49:55 +00:00
|
|
|
{
|
|
|
|
for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
|
2017-10-22 00:48:25 +00:00
|
|
|
screen->UpdateSymbolLinks( aForce );
|
2017-03-04 19:49:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-10 14:36:55 +00:00
|
|
|
void SCH_SCREENS::TestDanglingEnds()
|
|
|
|
{
|
|
|
|
for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
|
|
|
|
screen->TestDanglingEnds();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-05 22:31:31 +00:00
|
|
|
bool SCH_SCREENS::HasNoFullyDefinedLibIds()
|
|
|
|
{
|
|
|
|
SCH_COMPONENT* symbol;
|
|
|
|
SCH_ITEM* item;
|
|
|
|
SCH_ITEM* nextItem;
|
|
|
|
SCH_SCREEN* screen;
|
2017-10-06 18:07:43 +00:00
|
|
|
unsigned cnt = 0;
|
2017-03-05 22:31:31 +00:00
|
|
|
|
|
|
|
for( screen = GetFirst(); screen; screen = GetNext() )
|
|
|
|
{
|
|
|
|
for( item = screen->GetDrawItems(); item; item = nextItem )
|
|
|
|
{
|
|
|
|
nextItem = item->Next();
|
|
|
|
|
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
|
|
|
continue;
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
cnt += 1;
|
2017-03-05 22:31:31 +00:00
|
|
|
symbol = dynamic_cast< SCH_COMPONENT* >( item );
|
2018-01-06 05:02:28 +00:00
|
|
|
wxASSERT( symbol );
|
2017-03-05 22:31:31 +00:00
|
|
|
|
|
|
|
if( !symbol->GetLibId().GetLibNickname().empty() )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
if( cnt == 0 )
|
|
|
|
return false;
|
|
|
|
|
2017-03-05 22:31:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 17:00:04 +00:00
|
|
|
size_t SCH_SCREENS::GetLibNicknames( wxArrayString& aLibNicknames )
|
2011-12-22 21:57:50 +00:00
|
|
|
{
|
2017-11-17 17:00:04 +00:00
|
|
|
SCH_COMPONENT* symbol;
|
|
|
|
SCH_ITEM* item;
|
|
|
|
SCH_ITEM* nextItem;
|
|
|
|
SCH_SCREEN* screen;
|
|
|
|
wxString nickname;
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2017-11-17 17:00:04 +00:00
|
|
|
for( screen = GetFirst(); screen; screen = GetNext() )
|
2011-12-22 21:57:50 +00:00
|
|
|
{
|
2017-11-17 17:00:04 +00:00
|
|
|
for( item = screen->GetDrawItems(); item; item = nextItem )
|
|
|
|
{
|
|
|
|
nextItem = item->Next();
|
|
|
|
|
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
symbol = dynamic_cast< SCH_COMPONENT* >( item );
|
2018-01-06 05:02:28 +00:00
|
|
|
wxASSERT( symbol );
|
2017-11-17 17:00:04 +00:00
|
|
|
|
|
|
|
nickname = symbol->GetLibId().GetLibNickname();
|
|
|
|
|
|
|
|
if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
|
|
|
|
aLibNicknames.Add( nickname );;
|
|
|
|
}
|
2011-12-22 21:57:50 +00:00
|
|
|
}
|
|
|
|
|
2017-11-17 17:00:04 +00:00
|
|
|
return aLibNicknames.GetCount();
|
2011-12-22 21:57:50 +00:00
|
|
|
}
|
2017-11-17 17:00:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
int SCH_SCREENS::ChangeSymbolLibNickname( const wxString& aFrom, const wxString& aTo )
|
|
|
|
{
|
|
|
|
SCH_COMPONENT* symbol;
|
|
|
|
SCH_ITEM* item;
|
|
|
|
SCH_ITEM* nextItem;
|
|
|
|
SCH_SCREEN* screen;
|
|
|
|
int cnt = 0;
|
|
|
|
|
|
|
|
for( screen = GetFirst(); screen; screen = GetNext() )
|
|
|
|
{
|
|
|
|
for( item = screen->GetDrawItems(); item; item = nextItem )
|
|
|
|
{
|
|
|
|
nextItem = item->Next();
|
|
|
|
|
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
symbol = dynamic_cast< SCH_COMPONENT* >( item );
|
2018-01-06 05:02:28 +00:00
|
|
|
wxASSERT( symbol );
|
2017-11-17 17:00:04 +00:00
|
|
|
|
|
|
|
if( symbol->GetLibId().GetLibNickname() != aFrom )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
LIB_ID id = symbol->GetLibId();
|
|
|
|
id.SetLibNickname( aTo );
|
|
|
|
symbol->SetLibId( id );
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
2018-09-03 10:11:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_SCREENS::BuildClientSheetPathList()
|
|
|
|
{
|
|
|
|
SCH_SHEET_LIST sheetList( g_RootSheet );
|
|
|
|
|
|
|
|
for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
|
|
|
|
curr_screen->GetClientSheetPaths().Clear();
|
|
|
|
|
|
|
|
for( SCH_SHEET_PATH& sheetpath: sheetList )
|
|
|
|
{
|
|
|
|
SCH_SCREEN* used_screen = sheetpath.LastScreen();
|
|
|
|
|
|
|
|
// SEarch for the used_screen in list and add this unique sheet path:
|
|
|
|
for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
|
|
|
|
{
|
|
|
|
if( used_screen == curr_screen )
|
|
|
|
{
|
|
|
|
curr_screen->GetClientSheetPaths().Add( sheetpath.Path() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|