2011-10-19 20:32:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2014-02-07 19:32:08 +00:00
|
|
|
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-10-06 18:07:43 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2018-12-29 08:39:08 +00:00
|
|
|
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-19 20:32:21 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <eeschema_id.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2019-04-13 14:28:40 +00:00
|
|
|
#include <advanced_config.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <class_library.h>
|
2019-04-29 21:44:49 +00:00
|
|
|
#include <connection_graph.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <hotkeys.h>
|
|
|
|
#include <sch_bus_entry.h>
|
|
|
|
#include <sch_junction.h>
|
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_line.h>
|
|
|
|
#include <sch_sheet.h>
|
|
|
|
#include <sch_sheet_path.h>
|
2017-10-06 18:07:43 +00:00
|
|
|
#include <symbol_lib_table.h>
|
2018-12-29 08:39:08 +00:00
|
|
|
#include <sch_view.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2019-04-21 23:45:34 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2019-04-17 19:09:48 +00:00
|
|
|
#include <tools/sch_actions.h>
|
2019-04-21 23:45:34 +00:00
|
|
|
#include <tools/sch_selection_tool.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, SYMBOL_LIB_TABLE* aLibs )
|
2012-12-29 12:55:36 +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
|
|
|
wxString msg;
|
|
|
|
LIB_PART* part = NULL;
|
2017-10-06 18:07:43 +00:00
|
|
|
LIB_ALIAS* alias = NULL;
|
2012-12-29 12:55:36 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
alias = aLibs->LoadSymbol( Component->GetLibId() );
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if( alias )
|
|
|
|
part = alias->GetPart();
|
2012-12-29 12:55:36 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
wxMenu* editmenu = new wxMenu;
|
2008-12-12 21:30:07 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( part && part->GetUnitCount() >= 2 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
wxMenu* sel_unit_menu = new wxMenu; int ii;
|
2011-09-01 12:54:34 +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( ii = 0; ii < part->GetUnitCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
wxString num_unit;
|
2011-01-18 10:42:49 +00:00
|
|
|
int unit = Component->GetUnit();
|
2015-04-07 11:52:29 +00:00
|
|
|
num_unit.Printf( _( "Unit %s" ), GetChars( LIB_PART::SubReference( ii + 1, false ) ) );
|
2011-01-18 10:42:49 +00:00
|
|
|
wxMenuItem * item = sel_unit_menu->Append( ID_POPUP_SCH_SELECT_UNIT1 + ii,
|
2011-09-01 12:54:34 +00:00
|
|
|
num_unit, wxEmptyString,
|
|
|
|
wxITEM_CHECK );
|
2011-01-18 10:42:49 +00:00
|
|
|
if( unit == ii + 1 )
|
|
|
|
item->Check(true);
|
2015-04-07 11:52:29 +00:00
|
|
|
|
|
|
|
// The ID max for these submenus is ID_POPUP_SCH_SELECT_UNIT_CMP_MAX
|
|
|
|
// See eeschema_id to modify this value.
|
|
|
|
if( ii >= (ID_POPUP_SCH_SELECT_UNIT_CMP_MAX - ID_POPUP_SCH_SELECT_UNIT1) )
|
|
|
|
break; // We have used all IDs for these submenus
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( editmenu, sel_unit_menu, ID_POPUP_SCH_SELECT_UNIT_CMP,
|
2011-09-08 05:58:45 +00:00
|
|
|
_( "Unit" ), KiBitmap( component_select_unit_xpm ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame )
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2019-04-21 23:45:34 +00:00
|
|
|
SCH_SELECTION_TOOL* selTool = frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
|
|
|
wxPoint pos = frame->GetCrossHairPosition();
|
|
|
|
wxString msg;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2019-04-11 04:17:07 +00:00
|
|
|
// TODO(JE) remove once real-time is enabled
|
2019-04-29 21:44:49 +00:00
|
|
|
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
2019-04-13 14:28:40 +00:00
|
|
|
{
|
|
|
|
frame->RecalculateConnections();
|
|
|
|
|
|
|
|
// Have to pick up the pointer again because it may have been changed by SchematicCleanUp
|
|
|
|
bool actionCancelled = false;
|
2019-04-21 23:45:34 +00:00
|
|
|
Bus = dynamic_cast<SCH_LINE*>( selTool->SelectPoint( pos, SCH_COLLECTOR::AllItemsButPins,
|
|
|
|
&actionCancelled ) );
|
2019-04-13 14:28:40 +00:00
|
|
|
wxASSERT( Bus );
|
|
|
|
}
|
2019-04-11 04:17:07 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
// Bus unfolding menu (only available if bus is properly defined)
|
2019-05-02 02:29:02 +00:00
|
|
|
wxMenu* bus_unfold_menu = frame->GetUnfoldBusMenu( Bus );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-05-02 02:29:02 +00:00
|
|
|
if( bus_unfold_menu )
|
|
|
|
PopMenu->AppendSubMenu( bus_unfold_menu, _( "Unfold Bus" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|