Move bus unfold and symbol unit selection to modern toolkit.
This commit is contained in:
parent
f4b92e6acf
commit
6e695aac25
|
@ -322,6 +322,7 @@ void CONTEXT_MENU::updateHotKeys()
|
||||||
void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
||||||
{
|
{
|
||||||
OPT_TOOL_EVENT evt;
|
OPT_TOOL_EVENT evt;
|
||||||
|
wxString menuText;
|
||||||
|
|
||||||
wxEventType type = aEvent.GetEventType();
|
wxEventType type = aEvent.GetEventType();
|
||||||
|
|
||||||
|
@ -381,7 +382,11 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
||||||
|
|
||||||
// Handling non-action menu entries (e.g. items in clarification list)
|
// Handling non-action menu entries (e.g. items in clarification list)
|
||||||
if( !evt )
|
if( !evt )
|
||||||
evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_CHOICE, aEvent.GetId() );
|
{
|
||||||
|
menuText = GetLabelText( aEvent.GetId() );
|
||||||
|
evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_CHOICE, aEvent.GetId(),
|
||||||
|
AS_GLOBAL, &menuText );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,6 @@ set( EESCHEMA_SRCS
|
||||||
netlist_generator.cpp
|
netlist_generator.cpp
|
||||||
netlist_object_list.cpp
|
netlist_object_list.cpp
|
||||||
netlist_object.cpp
|
netlist_object.cpp
|
||||||
onrightclick.cpp
|
|
||||||
operations_on_items_lists.cpp
|
operations_on_items_lists.cpp
|
||||||
pin_number.cpp
|
pin_number.cpp
|
||||||
pin_shape.cpp
|
pin_shape.cpp
|
||||||
|
|
|
@ -455,106 +455,3 @@ SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( const wxPoint& aPosition, bool aAppen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::OnUnfoldBus( wxCommandEvent& event )
|
|
||||||
{
|
|
||||||
wxMenuItem* item = static_cast<wxMenuItem*>( event.GetEventUserData() );
|
|
||||||
wxString net = item->GetItemLabelText();
|
|
||||||
|
|
||||||
GetToolManager()->RunAction( SCH_ACTIONS::unfoldBus, true, &net );
|
|
||||||
|
|
||||||
// Now that we have handled the chosen bus unfold, disconnect all the events so they can be
|
|
||||||
// recreated with updated data on the next unfold
|
|
||||||
Unbind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnUnfoldBus, this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::OnUnfoldBusHotkey( wxCommandEvent& aEvent )
|
|
||||||
{
|
|
||||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
|
||||||
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
|
|
||||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
|
||||||
|
|
||||||
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
|
||||||
|
|
||||||
if( item == NULL )
|
|
||||||
{
|
|
||||||
// If we didn't get here by a hot key, then something has gone wrong.
|
|
||||||
if( aEvent.GetInt() == 0 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
item = selTool->SelectPoint( data->GetPosition(), SCH_COLLECTOR::EditableItems );
|
|
||||||
|
|
||||||
// Exit if no item found at the current location or the item is already being edited.
|
|
||||||
if( item == NULL || item->GetEditFlags() != 0 )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( item->Type() != SCH_LINE_T )
|
|
||||||
return;
|
|
||||||
|
|
||||||
wxMenu* bus_unfold_menu = GetUnfoldBusMenu( static_cast<SCH_LINE*>( item ) );
|
|
||||||
|
|
||||||
if( bus_unfold_menu )
|
|
||||||
{
|
|
||||||
auto controls = GetCanvas()->GetViewControls();
|
|
||||||
auto vmp = controls->GetMousePosition( false );
|
|
||||||
wxPoint mouse_pos( (int) vmp.x, (int) vmp.y );
|
|
||||||
|
|
||||||
GetGalCanvas()->PopupMenu( bus_unfold_menu, mouse_pos );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxMenu* SCH_EDIT_FRAME::GetUnfoldBusMenu( SCH_LINE* aBus )
|
|
||||||
{
|
|
||||||
auto connection = aBus->Connection( *g_CurrentSheet );
|
|
||||||
|
|
||||||
if( !connection || !connection->IsBus() || connection->Members().empty() )
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
int idx = 0;
|
|
||||||
wxMenu* bus_unfolding_menu = new wxMenu;
|
|
||||||
|
|
||||||
for( const auto& member : connection->Members() )
|
|
||||||
{
|
|
||||||
int id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ );
|
|
||||||
wxString name = member->Name( true );
|
|
||||||
|
|
||||||
if( member->Type() == CONNECTION_BUS )
|
|
||||||
{
|
|
||||||
wxMenu* submenu = new wxMenu;
|
|
||||||
bus_unfolding_menu->AppendSubMenu( submenu, _( name ) );
|
|
||||||
|
|
||||||
for( const auto& sub_member : member->Members() )
|
|
||||||
{
|
|
||||||
id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ );
|
|
||||||
|
|
||||||
submenu->Append( id, sub_member->Name( true ), wxEmptyString );
|
|
||||||
|
|
||||||
// See comment in else clause below
|
|
||||||
auto sub_item_clone = new wxMenuItem();
|
|
||||||
sub_item_clone->SetItemLabel( sub_member->Name( true ) );
|
|
||||||
|
|
||||||
Bind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnUnfoldBus, this, id, id,
|
|
||||||
sub_item_clone );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bus_unfolding_menu->Append( id, name, wxEmptyString );
|
|
||||||
|
|
||||||
// Because Bind() takes ownership of the user data item, we
|
|
||||||
// make a new menu item here and set its label. Why create a
|
|
||||||
// menu item instead of just a wxString or something? Because
|
|
||||||
// Bind() requires a pointer to wxObject rather than a void
|
|
||||||
// pointer. Maybe at some point I'll think of a better way...
|
|
||||||
auto item_clone = new wxMenuItem();
|
|
||||||
item_clone->SetItemLabel( name );
|
|
||||||
|
|
||||||
Bind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnUnfoldBus, this, id, id,
|
|
||||||
item_clone );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return bus_unfolding_menu;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,119 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
||||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
|
||||||
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fctsys.h>
|
|
||||||
#include <eeschema_id.h>
|
|
||||||
#include <sch_draw_panel.h>
|
|
||||||
#include <sch_edit_frame.h>
|
|
||||||
#include <menus_helpers.h>
|
|
||||||
|
|
||||||
#include <advanced_config.h>
|
|
||||||
#include <class_library.h>
|
|
||||||
#include <connection_graph.h>
|
|
||||||
#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>
|
|
||||||
#include <symbol_lib_table.h>
|
|
||||||
#include <sch_view.h>
|
|
||||||
|
|
||||||
#include <tool/tool_manager.h>
|
|
||||||
#include <tools/sch_actions.h>
|
|
||||||
#include <tools/sch_selection_tool.h>
|
|
||||||
|
|
||||||
void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, SYMBOL_LIB_TABLE* aLibs )
|
|
||||||
{
|
|
||||||
wxString msg;
|
|
||||||
LIB_PART* part = NULL;
|
|
||||||
LIB_ALIAS* alias = NULL;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
alias = aLibs->LoadSymbol( Component->GetLibId() );
|
|
||||||
}
|
|
||||||
catch( ... )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if( alias )
|
|
||||||
part = alias->GetPart();
|
|
||||||
|
|
||||||
wxMenu* editmenu = new wxMenu;
|
|
||||||
|
|
||||||
if( part && part->GetUnitCount() >= 2 )
|
|
||||||
{
|
|
||||||
wxMenu* sel_unit_menu = new wxMenu; int ii;
|
|
||||||
|
|
||||||
for( ii = 0; ii < part->GetUnitCount(); ii++ )
|
|
||||||
{
|
|
||||||
wxString num_unit;
|
|
||||||
int unit = Component->GetUnit();
|
|
||||||
num_unit.Printf( _( "Unit %s" ), GetChars( LIB_PART::SubReference( ii + 1, false ) ) );
|
|
||||||
wxMenuItem * item = sel_unit_menu->Append( ID_POPUP_SCH_SELECT_UNIT1 + ii,
|
|
||||||
num_unit, wxEmptyString,
|
|
||||||
wxITEM_CHECK );
|
|
||||||
if( unit == ii + 1 )
|
|
||||||
item->Check(true);
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
|
|
||||||
AddMenuItem( editmenu, sel_unit_menu, ID_POPUP_SCH_SELECT_UNIT_CMP,
|
|
||||||
_( "Unit" ), KiBitmap( component_select_unit_xpm ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame )
|
|
||||||
{
|
|
||||||
SCH_SELECTION_TOOL* selTool = frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
|
||||||
|
|
||||||
// TODO(JE) remove once real-time is enabled
|
|
||||||
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
|
||||||
{
|
|
||||||
frame->RecalculateConnections();
|
|
||||||
|
|
||||||
// Have to pick up the pointer again because it may have been changed by SchematicCleanUp
|
|
||||||
KICAD_T busType[] = { SCH_LINE_LOCATE_BUS_T, EOT };
|
|
||||||
SELECTION& selection = selTool->RequestSelection( busType );
|
|
||||||
Bus = (SCH_LINE*) selection.Front();
|
|
||||||
wxASSERT( Bus );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bus unfolding menu (only available if bus is properly defined)
|
|
||||||
wxMenu* bus_unfold_menu = frame->GetUnfoldBusMenu( Bus );
|
|
||||||
|
|
||||||
if( bus_unfold_menu )
|
|
||||||
PopMenu->AppendSubMenu( bus_unfold_menu, _( "Unfold Bus" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -270,8 +270,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||||
EVT_TOOL( ID_SIM_SHOW, SCH_EDIT_FRAME::OnSimulate )
|
EVT_TOOL( ID_SIM_SHOW, SCH_EDIT_FRAME::OnSimulate )
|
||||||
#endif /* KICAD_SPICE */
|
#endif /* KICAD_SPICE */
|
||||||
|
|
||||||
EVT_MENU( ID_SCH_UNFOLD_BUS, SCH_EDIT_FRAME::OnUnfoldBusHotkey )
|
|
||||||
|
|
||||||
EVT_MENU( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnSwitchCanvas )
|
EVT_MENU( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnSwitchCanvas )
|
||||||
EVT_MENU( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnSwitchCanvas )
|
EVT_MENU( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnSwitchCanvas )
|
||||||
|
|
||||||
|
|
|
@ -251,13 +251,6 @@ public:
|
||||||
void Process_Special_Functions( wxCommandEvent& event );
|
void Process_Special_Functions( wxCommandEvent& event );
|
||||||
void Process_Config( wxCommandEvent& event );
|
void Process_Config( wxCommandEvent& event );
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes an "Unfold Bus" command from the right-click menu.
|
|
||||||
* Depending on what the user clicked, this can result in the creation
|
|
||||||
* of one or more new objects.
|
|
||||||
*/
|
|
||||||
void OnUnfoldBus( wxCommandEvent& event );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the context menu for unfolding a bus
|
* Builds the context menu for unfolding a bus
|
||||||
*/
|
*/
|
||||||
|
@ -777,11 +770,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles the keyboard hotkey for unfolding a bus
|
|
||||||
*/
|
|
||||||
void OnUnfoldBusHotkey( wxCommandEvent& event );
|
|
||||||
|
|
||||||
void OnExit( wxCommandEvent& event );
|
void OnExit( wxCommandEvent& event );
|
||||||
void OnAnnotate( wxCommandEvent& event );
|
void OnAnnotate( wxCommandEvent& event );
|
||||||
void OnErc( wxCommandEvent& event );
|
void OnErc( wxCommandEvent& event );
|
||||||
|
|
|
@ -349,6 +349,18 @@ int SCH_DRAWING_TOOL::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER
|
||||||
|
|
||||||
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
||||||
}
|
}
|
||||||
|
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CONTEXT_MENU_CHOICE )
|
||||||
|
{
|
||||||
|
if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
|
||||||
|
&& evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_CMP_MAX )
|
||||||
|
{
|
||||||
|
if( aComponent )
|
||||||
|
{
|
||||||
|
aComponent->SetUnit( evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP );
|
||||||
|
m_toolMgr->RunAction( SCH_ACTIONS::refreshPreview );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if( aComponent && ( evt->IsAction( &SCH_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
|
else if( aComponent && ( evt->IsAction( &SCH_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
|
||||||
{
|
{
|
||||||
aComponent->SetPosition( (wxPoint)cursorPos );
|
aComponent->SetPosition( (wxPoint)cursorPos );
|
||||||
|
|
|
@ -116,7 +116,7 @@ TOOL_ACTION SCH_ACTIONS::autoplaceFields( "eeschema.InteractiveEdit.autoplaceFie
|
||||||
TOOL_ACTION SCH_ACTIONS::convertDeMorgan( "eeschema.InteractiveEdit.convertDeMorgan",
|
TOOL_ACTION SCH_ACTIONS::convertDeMorgan( "eeschema.InteractiveEdit.convertDeMorgan",
|
||||||
AS_GLOBAL, 0,
|
AS_GLOBAL, 0,
|
||||||
_( "DeMorgan Conversion" ), _( "Switch between DeMorgan representations" ),
|
_( "DeMorgan Conversion" ), _( "Switch between DeMorgan representations" ),
|
||||||
nullptr );
|
morgan2_xpm );
|
||||||
|
|
||||||
TOOL_ACTION SCH_ACTIONS::toShapeSlash( "eeschema.InteractiveEdit.toShapeSlash",
|
TOOL_ACTION SCH_ACTIONS::toShapeSlash( "eeschema.InteractiveEdit.toShapeSlash",
|
||||||
AS_GLOBAL, 0,
|
AS_GLOBAL, 0,
|
||||||
|
@ -174,6 +174,65 @@ TOOL_ACTION SCH_ACTIONS::breakBus( "eeschema.InteractiveEdit.breakBus",
|
||||||
break_line_xpm );
|
break_line_xpm );
|
||||||
|
|
||||||
|
|
||||||
|
class SYMBOL_UNIT_MENU : public CONTEXT_MENU
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SYMBOL_UNIT_MENU()
|
||||||
|
{
|
||||||
|
SetIcon( component_select_unit_xpm );
|
||||||
|
SetTitle( _( "Symbol Unit" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CONTEXT_MENU* create() const override
|
||||||
|
{
|
||||||
|
return new SYMBOL_UNIT_MENU();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void update() override
|
||||||
|
{
|
||||||
|
SCH_SELECTION_TOOL* selTool = getToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||||
|
SELECTION& selection = selTool->GetSelection();
|
||||||
|
SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
|
||||||
|
|
||||||
|
if( !component )
|
||||||
|
{
|
||||||
|
Append( ID_POPUP_SCH_UNFOLD_BUS, _( "no symbol selected" ), wxEmptyString );
|
||||||
|
Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int unit = component->GetUnit();
|
||||||
|
auto partRef = component->GetPartRef().lock();
|
||||||
|
|
||||||
|
if( !partRef || partRef->GetUnitCount() < 2 )
|
||||||
|
{
|
||||||
|
Append( ID_POPUP_SCH_UNFOLD_BUS, _( "symbol is not multi-unit" ), wxEmptyString );
|
||||||
|
Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( int ii = 0; ii < partRef->GetUnitCount(); ii++ )
|
||||||
|
{
|
||||||
|
wxString num_unit;
|
||||||
|
num_unit.Printf( _( "Unit %s" ), LIB_PART::SubReference( ii + 1, false ) );
|
||||||
|
|
||||||
|
wxMenuItem * item = Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit, wxEmptyString,
|
||||||
|
wxITEM_CHECK );
|
||||||
|
if( unit == ii + 1 )
|
||||||
|
item->Check(true);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
SCH_EDIT_TOOL::SCH_EDIT_TOOL() :
|
SCH_EDIT_TOOL::SCH_EDIT_TOOL() :
|
||||||
TOOL_INTERACTIVE( "eeschema.InteractiveEdit" ),
|
TOOL_INTERACTIVE( "eeschema.InteractiveEdit" ),
|
||||||
m_selectionTool( nullptr ),
|
m_selectionTool( nullptr ),
|
||||||
|
@ -295,12 +354,6 @@ bool SCH_EDIT_TOOL::Init()
|
||||||
auto singleSheetCondition = SCH_CONDITIONS::Count( 1 )
|
auto singleSheetCondition = SCH_CONDITIONS::Count( 1 )
|
||||||
&& SCH_CONDITIONS::OnlyType( SCH_SHEET_T );
|
&& SCH_CONDITIONS::OnlyType( SCH_SHEET_T );
|
||||||
|
|
||||||
auto wireOrBusTool = [ this ] ( const SELECTION& aSel ) {
|
|
||||||
return ( m_frame->GetToolId() == ID_WIRE_BUTT
|
|
||||||
|| m_frame->GetToolId() == ID_BUS_BUTT
|
|
||||||
|| m_frame->GetToolId() == ID_JUNCTION_BUTT );
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Build the edit tool menu (shown when moving or dragging)
|
// Build the edit tool menu (shown when moving or dragging)
|
||||||
//
|
//
|
||||||
|
@ -321,7 +374,11 @@ bool SCH_EDIT_TOOL::Init()
|
||||||
ctxMenu.AddItem( SCH_ACTIONS::editValue, singleComponentCondition );
|
ctxMenu.AddItem( SCH_ACTIONS::editValue, singleComponentCondition );
|
||||||
ctxMenu.AddItem( SCH_ACTIONS::editFootprint, singleComponentCondition );
|
ctxMenu.AddItem( SCH_ACTIONS::editFootprint, singleComponentCondition );
|
||||||
ctxMenu.AddItem( SCH_ACTIONS::convertDeMorgan, SCH_CONDITIONS::SingleDeMorganSymbol );
|
ctxMenu.AddItem( SCH_ACTIONS::convertDeMorgan, SCH_CONDITIONS::SingleDeMorganSymbol );
|
||||||
// JEY TODO: add menu access for changing symbol unit
|
|
||||||
|
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
|
||||||
|
symUnitMenu->SetTool( this );
|
||||||
|
m_menu.AddSubMenu( symUnitMenu );
|
||||||
|
ctxMenu.AddMenu( symUnitMenu.get(), false, SCH_CONDITIONS::SingleMultiUnitSymbol, 1 );
|
||||||
|
|
||||||
ctxMenu.AddSeparator( SCH_CONDITIONS::IdleSelection );
|
ctxMenu.AddSeparator( SCH_CONDITIONS::IdleSelection );
|
||||||
ctxMenu.AddItem( SCH_ACTIONS::cut, SCH_CONDITIONS::IdleSelection );
|
ctxMenu.AddItem( SCH_ACTIONS::cut, SCH_CONDITIONS::IdleSelection );
|
||||||
|
@ -346,7 +403,12 @@ bool SCH_EDIT_TOOL::Init()
|
||||||
drawingMenu.AddItem( SCH_ACTIONS::editValue, singleComponentCondition, 200 );
|
drawingMenu.AddItem( SCH_ACTIONS::editValue, singleComponentCondition, 200 );
|
||||||
drawingMenu.AddItem( SCH_ACTIONS::editFootprint, singleComponentCondition, 200 );
|
drawingMenu.AddItem( SCH_ACTIONS::editFootprint, singleComponentCondition, 200 );
|
||||||
drawingMenu.AddItem( SCH_ACTIONS::convertDeMorgan, SCH_CONDITIONS::SingleDeMorganSymbol, 200 );
|
drawingMenu.AddItem( SCH_ACTIONS::convertDeMorgan, SCH_CONDITIONS::SingleDeMorganSymbol, 200 );
|
||||||
// JEY TODO: add menu access for changing symbol unit
|
|
||||||
|
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
|
||||||
|
symUnitMenu2->SetTool( drawingTool );
|
||||||
|
drawingTool->GetToolMenu().AddSubMenu( symUnitMenu2 );
|
||||||
|
drawingMenu.AddMenu( symUnitMenu2.get(), false, SCH_CONDITIONS::SingleMultiUnitSymbol, 1 );
|
||||||
|
|
||||||
drawingMenu.AddItem( SCH_ACTIONS::toShapeSlash, entryCondition, 200 );
|
drawingMenu.AddItem( SCH_ACTIONS::toShapeSlash, entryCondition, 200 );
|
||||||
drawingMenu.AddItem( SCH_ACTIONS::toShapeBackslash, entryCondition, 200 );
|
drawingMenu.AddItem( SCH_ACTIONS::toShapeBackslash, entryCondition, 200 );
|
||||||
drawingMenu.AddItem( SCH_ACTIONS::toLabel, toLabelCondition, 200 );
|
drawingMenu.AddItem( SCH_ACTIONS::toLabel, toLabelCondition, 200 );
|
||||||
|
@ -374,7 +436,12 @@ bool SCH_EDIT_TOOL::Init()
|
||||||
selToolMenu.AddItem( SCH_ACTIONS::editFootprint, SCH_CONDITIONS::SingleSymbol, 200 );
|
selToolMenu.AddItem( SCH_ACTIONS::editFootprint, SCH_CONDITIONS::SingleSymbol, 200 );
|
||||||
selToolMenu.AddItem( SCH_ACTIONS::autoplaceFields, singleComponentCondition, 200 );
|
selToolMenu.AddItem( SCH_ACTIONS::autoplaceFields, singleComponentCondition, 200 );
|
||||||
selToolMenu.AddItem( SCH_ACTIONS::convertDeMorgan, SCH_CONDITIONS::SingleSymbol, 200 );
|
selToolMenu.AddItem( SCH_ACTIONS::convertDeMorgan, SCH_CONDITIONS::SingleSymbol, 200 );
|
||||||
// JEY TODO: add menu access for changing symbol unit
|
|
||||||
|
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
|
||||||
|
symUnitMenu3->SetTool( m_selectionTool );
|
||||||
|
m_selectionTool->GetToolMenu().AddSubMenu( symUnitMenu3 );
|
||||||
|
selToolMenu.AddMenu( symUnitMenu3.get(), false, SCH_CONDITIONS::SingleMultiUnitSymbol, 1 );
|
||||||
|
|
||||||
selToolMenu.AddItem( SCH_ACTIONS::toShapeSlash, entryCondition, 200 );
|
selToolMenu.AddItem( SCH_ACTIONS::toShapeSlash, entryCondition, 200 );
|
||||||
selToolMenu.AddItem( SCH_ACTIONS::toShapeBackslash, entryCondition, 200 );
|
selToolMenu.AddItem( SCH_ACTIONS::toShapeBackslash, entryCondition, 200 );
|
||||||
selToolMenu.AddItem( SCH_ACTIONS::toLabel, toLabelCondition, 200 );
|
selToolMenu.AddItem( SCH_ACTIONS::toLabel, toLabelCondition, 200 );
|
||||||
|
@ -643,6 +710,20 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
chain_commands = true;
|
chain_commands = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if( evt->Action() == TA_CONTEXT_MENU_CHOICE )
|
||||||
|
{
|
||||||
|
if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
|
||||||
|
&& evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_CMP_MAX )
|
||||||
|
{
|
||||||
|
SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
|
||||||
|
|
||||||
|
if( component )
|
||||||
|
{
|
||||||
|
component->SetUnit( evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP );
|
||||||
|
m_toolMgr->RunAction( SCH_ACTIONS::refreshPreview );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <connection_graph.h>
|
||||||
#include <sch_line_drawing_tool.h>
|
#include <sch_line_drawing_tool.h>
|
||||||
#include <sch_selection_tool.h>
|
#include <sch_selection_tool.h>
|
||||||
#include <sch_actions.h>
|
#include <sch_actions.h>
|
||||||
|
@ -40,7 +41,7 @@
|
||||||
#include <sch_bus_entry.h>
|
#include <sch_bus_entry.h>
|
||||||
#include <sch_text.h>
|
#include <sch_text.h>
|
||||||
#include <sch_sheet.h>
|
#include <sch_sheet.h>
|
||||||
|
#include <advanced_config.h>
|
||||||
|
|
||||||
TOOL_ACTION SCH_ACTIONS::startWire( "eeschema.InteractiveLineDrawing.startWire",
|
TOOL_ACTION SCH_ACTIONS::startWire( "eeschema.InteractiveLineDrawing.startWire",
|
||||||
AS_GLOBAL, 0,
|
AS_GLOBAL, 0,
|
||||||
|
@ -92,6 +93,83 @@ TOOL_ACTION SCH_ACTIONS::finishLine( "eeschema.InteractiveLineDrawing.finishLine
|
||||||
checked_ok_xpm, AF_NONE );
|
checked_ok_xpm, AF_NONE );
|
||||||
|
|
||||||
|
|
||||||
|
class BUS_UNFOLD_MENU : public CONTEXT_MENU
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BUS_UNFOLD_MENU()
|
||||||
|
{
|
||||||
|
SetIcon( add_line2bus_xpm );
|
||||||
|
SetTitle( _( "Unfold Bus" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CONTEXT_MENU* create() const override
|
||||||
|
{
|
||||||
|
return new BUS_UNFOLD_MENU();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void update() override
|
||||||
|
{
|
||||||
|
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) getToolManager()->GetEditFrame();
|
||||||
|
SCH_SELECTION_TOOL* selTool = getToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||||
|
KICAD_T busType[] = { SCH_LINE_LOCATE_BUS_T, EOT };
|
||||||
|
SELECTION& selection = selTool->RequestSelection( busType );
|
||||||
|
SCH_LINE* bus = (SCH_LINE*) selection.Front();
|
||||||
|
|
||||||
|
// TODO(JE) remove once real-time is enabled
|
||||||
|
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
||||||
|
{
|
||||||
|
frame->RecalculateConnections();
|
||||||
|
|
||||||
|
// Have to pick up the pointer again because it may have been changed by SchematicCleanUp
|
||||||
|
selection = selTool->RequestSelection( busType );
|
||||||
|
bus = (SCH_LINE*) selection.Front();
|
||||||
|
}
|
||||||
|
if( !bus )
|
||||||
|
{
|
||||||
|
Append( ID_POPUP_SCH_UNFOLD_BUS, _( "no bus selected" ), wxEmptyString );
|
||||||
|
Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCH_CONNECTION* connection = bus->Connection( *g_CurrentSheet );
|
||||||
|
|
||||||
|
if( !connection || !connection->IsBus() || connection->Members().empty() )
|
||||||
|
{
|
||||||
|
Append( ID_POPUP_SCH_UNFOLD_BUS, _( "bus has no connections" ), wxEmptyString );
|
||||||
|
Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
|
||||||
|
for( const auto& member : connection->Members() )
|
||||||
|
{
|
||||||
|
int id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ );
|
||||||
|
wxString name = member->Name( true );
|
||||||
|
|
||||||
|
if( member->Type() == CONNECTION_BUS )
|
||||||
|
{
|
||||||
|
wxMenu* submenu = new CONTEXT_MENU;
|
||||||
|
AppendSubMenu( submenu, name );
|
||||||
|
|
||||||
|
for( const auto& sub_member : member->Members() )
|
||||||
|
{
|
||||||
|
id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ );
|
||||||
|
submenu->Append( id, sub_member->Name( true ), wxEmptyString );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Append( id, name, wxEmptyString );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SCH_LINE_DRAWING_TOOL::SCH_LINE_DRAWING_TOOL() :
|
SCH_LINE_DRAWING_TOOL::SCH_LINE_DRAWING_TOOL() :
|
||||||
TOOL_INTERACTIVE( "eeschema.InteractiveLineDrawing" ),
|
TOOL_INTERACTIVE( "eeschema.InteractiveLineDrawing" ),
|
||||||
|
@ -141,7 +219,10 @@ bool SCH_LINE_DRAWING_TOOL::Init()
|
||||||
ctxMenu.AddItem( SCH_ACTIONS::finishBus, IsDrawingBus, 1 );
|
ctxMenu.AddItem( SCH_ACTIONS::finishBus, IsDrawingBus, 1 );
|
||||||
ctxMenu.AddItem( SCH_ACTIONS::finishLine, IsDrawingLine, 1 );
|
ctxMenu.AddItem( SCH_ACTIONS::finishLine, IsDrawingLine, 1 );
|
||||||
|
|
||||||
// TODO(JE): add menu access to unfold bus...
|
std::shared_ptr<BUS_UNFOLD_MENU> busUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
|
||||||
|
busUnfoldMenu->SetTool( this );
|
||||||
|
m_menu.AddSubMenu( busUnfoldMenu );
|
||||||
|
ctxMenu.AddMenu( busUnfoldMenu.get(), false, SCH_CONDITIONS::Idle, 1 );
|
||||||
|
|
||||||
ctxMenu.AddSeparator( wireOrBusTool && SCH_CONDITIONS::Idle, 100 );
|
ctxMenu.AddSeparator( wireOrBusTool && SCH_CONDITIONS::Idle, 100 );
|
||||||
ctxMenu.AddItem( SCH_ACTIONS::addJunction, wireOrBusTool && SCH_CONDITIONS::Idle, 100 );
|
ctxMenu.AddItem( SCH_ACTIONS::addJunction, wireOrBusTool && SCH_CONDITIONS::Idle, 100 );
|
||||||
|
@ -255,44 +336,28 @@ int SCH_LINE_DRAWING_TOOL::DrawBus( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_LINE_DRAWING_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
|
SCH_LINE* SCH_LINE_DRAWING_TOOL::unfoldBus( const wxString& aNet )
|
||||||
{
|
{
|
||||||
wxString net = *aEvent.Parameter<wxString*>();
|
|
||||||
wxPoint pos = m_frame->GetCrossHairPosition();
|
wxPoint pos = m_frame->GetCrossHairPosition();
|
||||||
|
|
||||||
/**
|
|
||||||
* Unfolding a bus consists of the following user inputs:
|
|
||||||
* 1) User selects a bus to unfold (see AddMenusForBus())
|
|
||||||
* We land in this event handler.
|
|
||||||
*
|
|
||||||
* 2) User clicks to set the net label location (handled by BeginSegment())
|
|
||||||
* Before this first click, the posture of the bus entry follows the
|
|
||||||
* mouse cursor in X and Y (handled by DrawSegment())
|
|
||||||
*
|
|
||||||
* 3) User is now in normal wiring mode and can exit in any normal way.
|
|
||||||
*/
|
|
||||||
|
|
||||||
wxASSERT( !m_busUnfold.in_progress );
|
|
||||||
|
|
||||||
m_busUnfold.entry = new SCH_BUS_WIRE_ENTRY( pos, '\\' );
|
m_busUnfold.entry = new SCH_BUS_WIRE_ENTRY( pos, '\\' );
|
||||||
m_busUnfold.entry->SetParent( m_frame->GetScreen() );
|
m_busUnfold.entry->SetParent( m_frame->GetScreen() );
|
||||||
m_frame->AddToScreen( m_busUnfold.entry );
|
m_frame->AddToScreen( m_busUnfold.entry );
|
||||||
|
|
||||||
m_busUnfold.label = new SCH_LABEL( m_busUnfold.entry->m_End(), net );
|
m_busUnfold.label = new SCH_LABEL( m_busUnfold.entry->m_End(), aNet );
|
||||||
m_busUnfold.label->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) );
|
m_busUnfold.label->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) );
|
||||||
m_busUnfold.label->SetLabelSpinStyle( 0 );
|
m_busUnfold.label->SetLabelSpinStyle( 0 );
|
||||||
m_busUnfold.label->SetParent( m_frame->GetScreen() );
|
m_busUnfold.label->SetParent( m_frame->GetScreen() );
|
||||||
|
|
||||||
m_busUnfold.in_progress = true;
|
m_busUnfold.in_progress = true;
|
||||||
m_busUnfold.origin = pos;
|
m_busUnfold.origin = pos;
|
||||||
m_busUnfold.net_name = net;
|
m_busUnfold.net_name = aNet;
|
||||||
|
|
||||||
m_frame->SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
|
m_frame->SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
|
||||||
|
|
||||||
m_frame->SetCrossHairPosition( m_busUnfold.entry->m_End() );
|
m_frame->SetCrossHairPosition( m_busUnfold.entry->m_End() );
|
||||||
|
|
||||||
SCH_LINE* segment = startSegments( LAYER_WIRE, m_busUnfold.entry->m_End() );
|
return startSegments( LAYER_WIRE, m_busUnfold.entry->m_End() );
|
||||||
return doDrawSegments( LAYER_WIRE, segment );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -426,6 +491,9 @@ int SCH_LINE_DRAWING_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
|
||||||
{
|
{
|
||||||
wxPoint cursorPos = (wxPoint)m_controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
wxPoint cursorPos = (wxPoint)m_controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Handle cancel:
|
||||||
|
//
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
|
||||||
{
|
{
|
||||||
if( aSegment || m_busUnfold.in_progress )
|
if( aSegment || m_busUnfold.in_progress )
|
||||||
|
@ -465,6 +533,9 @@ int SCH_LINE_DRAWING_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Handle finish:
|
||||||
|
//
|
||||||
else if( evt->IsAction( &SCH_ACTIONS::finishLineWireOrBus )
|
else if( evt->IsAction( &SCH_ACTIONS::finishLineWireOrBus )
|
||||||
|| evt->IsAction( &SCH_ACTIONS::finishWire )
|
|| evt->IsAction( &SCH_ACTIONS::finishWire )
|
||||||
|| evt->IsAction( &SCH_ACTIONS::finishBus )
|
|| evt->IsAction( &SCH_ACTIONS::finishBus )
|
||||||
|
@ -479,14 +550,9 @@ int SCH_LINE_DRAWING_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
|
||||||
if( m_frame->GetToolId() == ID_NO_TOOL_SELECTED )
|
if( m_frame->GetToolId() == ID_NO_TOOL_SELECTED )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
//------------------------------------------------------------------------
|
||||||
{
|
// Handle click:
|
||||||
// Warp after context menu only if dragging...
|
//
|
||||||
if( !aSegment )
|
|
||||||
m_toolMgr->VetoContextMenuMouseWarp();
|
|
||||||
|
|
||||||
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
|
||||||
}
|
|
||||||
else if( evt->IsClick( BUT_LEFT ) || ( aSegment && evt->IsDblClick( BUT_LEFT ) ) )
|
else if( evt->IsClick( BUT_LEFT ) || ( aSegment && evt->IsDblClick( BUT_LEFT ) ) )
|
||||||
{
|
{
|
||||||
// First click when unfolding places the label and wire-to-bus entry
|
// First click when unfolding places the label and wire-to-bus entry
|
||||||
|
@ -539,6 +605,9 @@ int SCH_LINE_DRAWING_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Handle motion:
|
||||||
|
//
|
||||||
else if( evt->IsMotion() )
|
else if( evt->IsMotion() )
|
||||||
{
|
{
|
||||||
m_view->ClearPreview();
|
m_view->ClearPreview();
|
||||||
|
@ -591,6 +660,28 @@ int SCH_LINE_DRAWING_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
|
||||||
m_view->AddToPreview( seg->Clone() );
|
m_view->AddToPreview( seg->Clone() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Handle context menu:
|
||||||
|
//
|
||||||
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
|
{
|
||||||
|
// Warp after context menu only if dragging...
|
||||||
|
if( !aSegment )
|
||||||
|
m_toolMgr->VetoContextMenuMouseWarp();
|
||||||
|
|
||||||
|
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
||||||
|
}
|
||||||
|
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CONTEXT_MENU_CHOICE )
|
||||||
|
{
|
||||||
|
if( evt->GetCommandId().get() >= ID_POPUP_SCH_UNFOLD_BUS
|
||||||
|
&& evt->GetCommandId().get() <= ID_POPUP_SCH_UNFOLD_BUS_END )
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( !aSegment, "Bus unfold event recieved when already drawing!" );
|
||||||
|
|
||||||
|
wxString net = *evt->Parameter<wxString*>();
|
||||||
|
aSegment = unfoldBus( net );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Enable autopanning and cursor capture only when there is a segment to be placed
|
// Enable autopanning and cursor capture only when there is a segment to be placed
|
||||||
m_controls->SetAutoPan( !!aSegment );
|
m_controls->SetAutoPan( !!aSegment );
|
||||||
|
@ -797,7 +888,6 @@ void SCH_LINE_DRAWING_TOOL::setTransitions()
|
||||||
{
|
{
|
||||||
Go( &SCH_LINE_DRAWING_TOOL::DrawWire, SCH_ACTIONS::drawWire.MakeEvent() );
|
Go( &SCH_LINE_DRAWING_TOOL::DrawWire, SCH_ACTIONS::drawWire.MakeEvent() );
|
||||||
Go( &SCH_LINE_DRAWING_TOOL::DrawBus, SCH_ACTIONS::drawBus.MakeEvent() );
|
Go( &SCH_LINE_DRAWING_TOOL::DrawBus, SCH_ACTIONS::drawBus.MakeEvent() );
|
||||||
Go( &SCH_LINE_DRAWING_TOOL::UnfoldBus, SCH_ACTIONS::unfoldBus.MakeEvent() );
|
|
||||||
Go( &SCH_LINE_DRAWING_TOOL::DrawLines, SCH_ACTIONS::drawLines.MakeEvent() );
|
Go( &SCH_LINE_DRAWING_TOOL::DrawLines, SCH_ACTIONS::drawLines.MakeEvent() );
|
||||||
|
|
||||||
Go( &SCH_LINE_DRAWING_TOOL::StartWire, SCH_ACTIONS::startWire.MakeEvent() );
|
Go( &SCH_LINE_DRAWING_TOOL::StartWire, SCH_ACTIONS::startWire.MakeEvent() );
|
||||||
|
|
|
@ -77,15 +77,11 @@ public:
|
||||||
int StartWire( const TOOL_EVENT& aEvent );
|
int StartWire( const TOOL_EVENT& aEvent );
|
||||||
int StartBus( const TOOL_EVENT& aEvent );
|
int StartBus( const TOOL_EVENT& aEvent );
|
||||||
int StartLines( const TOOL_EVENT& aEvent );
|
int StartLines( const TOOL_EVENT& aEvent );
|
||||||
int AddJunction( const TOOL_EVENT& aEvent );
|
|
||||||
int AddLabel( const TOOL_EVENT& aEvent );
|
|
||||||
|
|
||||||
int DrawWire( const TOOL_EVENT& aEvent );
|
int DrawWire( const TOOL_EVENT& aEvent );
|
||||||
int DrawBus( const TOOL_EVENT& aEvent );
|
int DrawBus( const TOOL_EVENT& aEvent );
|
||||||
int DrawLines( const TOOL_EVENT& aEvent );
|
int DrawLines( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
int UnfoldBus( const TOOL_EVENT& aEvent );
|
|
||||||
|
|
||||||
// SELECTION_CONDITIONs:
|
// SELECTION_CONDITIONs:
|
||||||
static bool IsDrawingLine( const SELECTION& aSelection );
|
static bool IsDrawingLine( const SELECTION& aSelection );
|
||||||
static bool IsDrawingWire( const SELECTION& aSelection );
|
static bool IsDrawingWire( const SELECTION& aSelection );
|
||||||
|
@ -96,6 +92,7 @@ private:
|
||||||
|
|
||||||
int doDrawSegments( int aType, SCH_LINE* aSegment );
|
int doDrawSegments( int aType, SCH_LINE* aSegment );
|
||||||
SCH_LINE* startSegments( int aType, const wxPoint& aPos );
|
SCH_LINE* startSegments( int aType, const wxPoint& aPos );
|
||||||
|
SCH_LINE* unfoldBus( const wxString& aNet );
|
||||||
void finishSegments();
|
void finishSegments();
|
||||||
|
|
||||||
///> Sets up handlers for various events.
|
///> Sets up handlers for various events.
|
||||||
|
|
|
@ -128,6 +128,23 @@ SELECTION_CONDITION SCH_CONDITIONS::SingleDeMorganSymbol = [] ( const SELECTION&
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
SELECTION_CONDITION SCH_CONDITIONS::SingleMultiUnitSymbol = [] ( const SELECTION& aSel )
|
||||||
|
{
|
||||||
|
if( aSel.GetSize() == 1 )
|
||||||
|
{
|
||||||
|
SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( aSel.Front() );
|
||||||
|
|
||||||
|
if( comp )
|
||||||
|
{
|
||||||
|
auto partRef = comp->GetPartRef().lock();
|
||||||
|
return partRef && partRef->GetUnitCount() >= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
SCH_SELECTION_TOOL::SCH_SELECTION_TOOL() :
|
SCH_SELECTION_TOOL::SCH_SELECTION_TOOL() :
|
||||||
TOOL_INTERACTIVE( "eeschema.InteractiveSelection" ),
|
TOOL_INTERACTIVE( "eeschema.InteractiveSelection" ),
|
||||||
m_frame( nullptr ),
|
m_frame( nullptr ),
|
||||||
|
@ -148,7 +165,7 @@ SCH_SELECTION_TOOL::~SCH_SELECTION_TOOL()
|
||||||
|
|
||||||
bool SCH_SELECTION_TOOL::Init()
|
bool SCH_SELECTION_TOOL::Init()
|
||||||
{
|
{
|
||||||
m_frame = getEditFrame<SCH_BASE_FRAME>();
|
m_frame = getEditFrame<SCH_EDIT_FRAME>();
|
||||||
|
|
||||||
static KICAD_T wireOrBusTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
|
static KICAD_T wireOrBusTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
|
||||||
|
|
||||||
|
@ -167,6 +184,7 @@ bool SCH_SELECTION_TOOL::Init()
|
||||||
auto& menu = m_menu.GetMenu();
|
auto& menu = m_menu.GetMenu();
|
||||||
|
|
||||||
// TODO(JE): add menu access to unfold bus on busSelectionCondition...
|
// TODO(JE): add menu access to unfold bus on busSelectionCondition...
|
||||||
|
|
||||||
menu.AddItem( SCH_ACTIONS::resizeSheet, singleSheetCondition && SCH_CONDITIONS::Idle, 1 );
|
menu.AddItem( SCH_ACTIONS::resizeSheet, singleSheetCondition && SCH_CONDITIONS::Idle, 1 );
|
||||||
|
|
||||||
menu.AddItem( SCH_ACTIONS::startWire, SCH_CONDITIONS::Empty, 1 );
|
menu.AddItem( SCH_ACTIONS::startWire, SCH_CONDITIONS::Empty, 1 );
|
||||||
|
@ -193,7 +211,7 @@ bool SCH_SELECTION_TOOL::Init()
|
||||||
|
|
||||||
void SCH_SELECTION_TOOL::Reset( RESET_REASON aReason )
|
void SCH_SELECTION_TOOL::Reset( RESET_REASON aReason )
|
||||||
{
|
{
|
||||||
m_frame = getEditFrame<SCH_BASE_FRAME>();
|
m_frame = getEditFrame<SCH_EDIT_FRAME>();
|
||||||
|
|
||||||
if( aReason == TOOL_BASE::MODEL_RELOAD )
|
if( aReason == TOOL_BASE::MODEL_RELOAD )
|
||||||
{
|
{
|
||||||
|
@ -298,6 +316,23 @@ int SCH_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// symbol unit selection menu? Adjust the unit if a symbol is selected
|
||||||
|
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CONTEXT_MENU_CHOICE )
|
||||||
|
{
|
||||||
|
if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
|
||||||
|
&& evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_CMP_MAX )
|
||||||
|
{
|
||||||
|
SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( m_selection.Front() );
|
||||||
|
|
||||||
|
if( component )
|
||||||
|
{
|
||||||
|
m_frame->SaveCopyInUndoList( component, UR_CHANGED );
|
||||||
|
component->SetUnit( evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP );
|
||||||
|
m_frame->RefreshItem( component );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )
|
else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )
|
||||||
{
|
{
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
|
|
||||||
static SELECTION_CONDITION SingleSymbol;
|
static SELECTION_CONDITION SingleSymbol;
|
||||||
static SELECTION_CONDITION SingleDeMorganSymbol;
|
static SELECTION_CONDITION SingleDeMorganSymbol;
|
||||||
|
static SELECTION_CONDITION SingleMultiUnitSymbol;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -225,7 +226,7 @@ private:
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SCH_BASE_FRAME* m_frame; // Pointer to the parent frame
|
SCH_EDIT_FRAME* m_frame; // Pointer to the parent frame
|
||||||
SELECTION m_selection; // Current state of selection
|
SELECTION m_selection; // Current state of selection
|
||||||
|
|
||||||
bool m_additive; // Items should be added to selection (instead of replacing)
|
bool m_additive; // Items should be added to selection (instead of replacing)
|
||||||
|
|
Loading…
Reference in New Issue