bool PCB_EDITOR_CONTROL::Init() { auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>(); zoneMenu->SetTool( this ); auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>(); lockMenu->SetTool( this ); // Add the PCB control menus to relevant other tools SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>(); if( selTool ) { auto& toolMenu = selTool->GetToolMenu(); auto& menu = toolMenu.GetMenu(); toolMenu.AddSubMenu( zoneMenu ); toolMenu.AddSubMenu( lockMenu ); menu.AddMenu( zoneMenu.get(), false, SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) ); menu.AddMenu( lockMenu.get(), false, SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ); } DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>(); if( drawingTool ) { auto& toolMenu = drawingTool->GetToolMenu(); auto& menu = toolMenu.GetMenu(); toolMenu.AddSubMenu( zoneMenu ); // Functor to say if the PCB_EDIT_FRAME is in a given mode // Capture the tool pointer and tool mode by value auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode ) { return [=]( const SELECTION& sel ) { return drawingTool->GetDrawingMode() == aMode; }; }; menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) ); } return true; }
bool MODULE_TOOLS::Init() { // Find the selection tool, so they can cooperate SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>(); if( !selectionTool ) { DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) ); return false; } selectionTool->GetToolMenu().GetMenu().AddItem( COMMON_ACTIONS::enumeratePads ); return true; }