|
|
|
@ -316,10 +316,14 @@ |
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnUnfoldBus( wxCommandEvent& event ) |
|
|
|
{ |
|
|
|
wxMenuItem* item = static_cast< wxMenuItem* >( event.GetEventUserData() ); |
|
|
|
static wxString net = item->GetItemLabelText(); |
|
|
|
wxMenuItem* item = static_cast<wxMenuItem*>( event.GetEventUserData() ); |
|
|
|
wxString net = item->GetItemLabelText(); |
|
|
|
|
|
|
|
GetToolManager()->RunAction( SCH_ACTIONS::unfoldBus, true, &net ); |
|
|
|
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 ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1182,57 +1186,72 @@ void SCH_EDIT_FRAME::OnUnfoldBusHotkey( wxCommandEvent& aEvent ) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
auto connection = item->Connection( *g_CurrentSheet ); |
|
|
|
if( item->Type() != SCH_LINE_T ) |
|
|
|
return; |
|
|
|
|
|
|
|
wxMenu* bus_unfold_menu = GetUnfoldBusMenu( static_cast<SCH_LINE*>( item ) ); |
|
|
|
|
|
|
|
if( connection && connection->IsBus() ) |
|
|
|
if( bus_unfold_menu ) |
|
|
|
{ |
|
|
|
int idx = 0; |
|
|
|
wxMenu* bus_unfolding_menu = new wxMenu; |
|
|
|
auto controls = GetCanvas()->GetViewControls(); |
|
|
|
auto vmp = controls->GetMousePosition( false ); |
|
|
|
wxPoint mouse_pos( (int) vmp.x, (int) vmp.y ); |
|
|
|
|
|
|
|
for( const auto& member : connection->Members() ) |
|
|
|
{ |
|
|
|
int id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ ); |
|
|
|
GetGalCanvas()->PopupMenu( bus_unfold_menu, mouse_pos ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if( member->Type() == CONNECTION_BUS ) |
|
|
|
{ |
|
|
|
wxMenu* submenu = new wxMenu; |
|
|
|
bus_unfolding_menu->AppendSubMenu( submenu, _( member->Name() ) ); |
|
|
|
|
|
|
|
for( const auto& sub_member : member->Members() ) |
|
|
|
{ |
|
|
|
id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ ); |
|
|
|
wxMenu* SCH_EDIT_FRAME::GetUnfoldBusMenu( SCH_LINE* aBus ) |
|
|
|
{ |
|
|
|
auto connection = aBus->Connection( *g_CurrentSheet ); |
|
|
|
|
|
|
|
submenu->Append( id, sub_member->Name(), wxEmptyString ); |
|
|
|
if( !connection || !connection->IsBus() || connection->Members().empty() ) |
|
|
|
return nullptr; |
|
|
|
|
|
|
|
// See comment in else clause below
|
|
|
|
auto sub_item_clone = new wxMenuItem(); |
|
|
|
sub_item_clone->SetItemLabel( sub_member->Name() ); |
|
|
|
int idx = 0; |
|
|
|
wxMenu* bus_unfolding_menu = new wxMenu; |
|
|
|
|
|
|
|
Bind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnUnfoldBus, |
|
|
|
this, id, id, sub_item_clone ); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
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() ) |
|
|
|
{ |
|
|
|
bus_unfolding_menu->Append( id, member->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( member->Name() ); |
|
|
|
|
|
|
|
Bind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnUnfoldBus, |
|
|
|
this, id, id, item_clone ); |
|
|
|
} |
|
|
|
} |
|
|
|
id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ ); |
|
|
|
|
|
|
|
auto controls = GetCanvas()->GetViewControls(); |
|
|
|
auto vmp = controls->GetMousePosition( false ); |
|
|
|
wxPoint mouse_pos( (int) vmp.x, (int) vmp.y ); |
|
|
|
submenu->Append( id, sub_member->Name( true ), wxEmptyString ); |
|
|
|
|
|
|
|
GetGalCanvas()->PopupMenu( bus_unfolding_menu, mouse_pos ); |
|
|
|
// 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; |
|
|
|
} |