void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) { if( m_zoomSelectBox == NULL ) return; // Should not happen! int id = m_zoomSelectBox->GetCurrentSelection(); if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) ) return; if( id == 0 ) // Auto zoom (Fit in Page) { Zoom_Automatique( true ); } else { id--; double selectedZoom = GetScreen()->m_ZoomList[id]; if( GetScreen()->GetZoom() == selectedZoom ) return; GetScreen()->SetZoom( selectedZoom ); RedrawScreen( GetScrollCenterPosition(), false ); } // Notify GAL TOOL_MANAGER* mgr = GetToolManager(); if( mgr && IsGalCanvasActive() ) mgr->RunAction( "common.Control.zoomPreset", true, id ); }
OPT_TOOL_EVENT eventHandler( const wxMenuEvent& aEvent ) override { BOARD_DESIGN_SETTINGS &bds = m_frame.GetBoard()->GetDesignSettings(); int id = aEvent.GetId(); // On Windows, this handler can be called with an event ID not existing in any // menuitem, so only set flags when we have an ID match. if( id == ID_POPUP_PCB_SELECT_CUSTOM_DIFFPAIR ) { bds.UseCustomDiffPairDimensions( true ); TOOL_MANAGER* toolManager = m_frame.GetToolManager(); toolManager->RunAction( PCB_ACTIONS::routerActivateDpDimensionsDialog, true ); } else if( id == ID_POPUP_PCB_SELECT_USE_NETCLASS_DIFFPAIR ) { bds.UseCustomDiffPairDimensions( false ); bds.SetDiffPairIndex( 0 ); } else if( id >= ID_POPUP_PCB_SELECT_DIFFPAIR1 && id <= ID_POPUP_PCB_SELECT_DIFFPAIR16 ) { bds.UseCustomDiffPairDimensions( false ); // remember that the menu doesn't contain index 0 (which is the netclass values) bds.SetDiffPairIndex( id - ID_POPUP_PCB_SELECT_DIFFPAIR1 + 1 ); } return OPT_TOOL_EVENT( PCB_ACTIONS::trackViaSizeChanged.MakeEvent() ); }
void CONTEXT_MENU::updateHotKeys() { TOOL_MANAGER* toolMgr = getToolManager(); for( std::map<int, const TOOL_ACTION*>::const_iterator it = m_toolActions.begin(); it != m_toolActions.end(); ++it ) { int id = it->first; const TOOL_ACTION& action = *it->second; int key = toolMgr->GetHotKey( action ) & ~MD_MODIFIER_MASK; if( key ) { int mod = toolMgr->GetHotKey( action ) & MD_MODIFIER_MASK; int flags = 0; wxMenuItem* item = FindChildItem( id ); if( item ) { flags |= ( mod & MD_ALT ) ? wxACCEL_ALT : 0; flags |= ( mod & MD_CTRL ) ? wxACCEL_CTRL : 0; flags |= ( mod & MD_SHIFT ) ? wxACCEL_SHIFT : 0; if( !flags ) flags = wxACCEL_NORMAL; wxAcceleratorEntry accel( flags, key, id, item ); item->SetAccel( &accel ); } } } }
void PCB_LAYER_WIDGET::SyncLayerAlphaIndicators() { int count = GetLayerRowCount(); TOOL_MANAGER* mgr = myframe->GetToolManager(); KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( mgr->GetView()->GetPainter() ); KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings(); for( int row = 0; row < count; ++row ) { // this utilizes more implementation knowledge than ideal, eventually // add member ROW getRow() or similar to base LAYER_WIDGET. wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE ); PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) ); KIGFX::COLOR4D screenColor = settings->GetLayerColor( layerId ); COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, COLUMN_COLORBM ) ); KIGFX::COLOR4D layerColor = swatch->GetSwatchColor(); INDICATOR_ICON* indicator = static_cast<INDICATOR_ICON*>( getLayerComp( row, COLUMN_ALPHA_INDICATOR ) ); if( std::abs( screenColor.a - layerColor.a ) > ALPHA_EPSILON ) { if( screenColor.a < layerColor.a ) indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN ); else indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP ); } else indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::OFF ); } }
void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) { int* clientData; int eventId = ID_POPUP_GRID_LEVEL_100; if( event.GetEventType() == wxEVT_CHOICE ) { if( m_gridSelectBox == NULL ) // Should not happen return; /* * Don't use wxCommandEvent::GetClientData() here. It always * returns NULL in GTK. This solution is not as elegant but * it works. */ int index = m_gridSelectBox->GetSelection(); wxASSERT( index != wxNOT_FOUND ); // GerbView does not support custom grid if( m_Ident != FRAME_GERBER ) { if( index == int( m_gridSelectBox->GetCount() - 2 ) ) { // this is the separator wxUpdateUIEvent dummy; OnUpdateSelectGrid( dummy ); return; } else if( index == int( m_gridSelectBox->GetCount() - 1 ) ) { wxUpdateUIEvent dummy; OnUpdateSelectGrid( dummy ); wxCommandEvent dummy2; OnGridSettings( dummy2 ); return; } } clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index ); if( clientData != NULL ) eventId = *clientData; } else { eventId = event.GetId(); } int idx = eventId - ID_POPUP_GRID_LEVEL_1000; // Notify GAL TOOL_MANAGER* mgr = GetToolManager(); if( mgr ) mgr->RunAction( "common.Control.gridPreset", true, idx ); m_canvas->Refresh(); }
bool PCB_BASE_FRAME::InvokeDialogGrid() { wxPoint grid_origin = GetGridOrigin(); DIALOG_SET_GRID dlg( this, &m_UserGridUnit, g_UserUnit, &m_UserGridSize, &grid_origin, &m_FastGrid1, &m_FastGrid2, m_gridSelectBox->GetStrings() ); int ret = dlg.ShowModal(); if( ret == wxID_OK ) { if( GetGridOrigin() != grid_origin && IsType( FRAME_PCB ) ) OnModify(); // because grid origin is saved in board, show as modified SetGridOrigin( grid_origin ); BASE_SCREEN* screen = GetScreen(); screen->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); // If the user grid is the current option, recall SetGrid() // to force new values put in list as current grid value if( screen->GetGridCmdId() == ID_POPUP_GRID_USER ) screen->SetGrid( ID_POPUP_GRID_USER ); // Notify GAL TOOL_MANAGER* mgr = GetToolManager(); if( mgr && IsGalCanvasActive() ) { mgr->RunAction( "common.Control.gridPreset", true, screen->GetGridCmdId() - ID_POPUP_GRID_LEVEL_1000 ); TOOL_EVENT gridOriginUpdate = COMMON_ACTIONS::gridSetOrigin.MakeEvent(); gridOriginUpdate.SetParameter( new VECTOR2D( grid_origin ) ); mgr->ProcessEvent( gridOriginUpdate ); } m_canvas->Refresh(); return true; } return false; }
void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) { int* clientData; int eventId = ID_POPUP_GRID_LEVEL_100; if( event.GetEventType() == wxEVT_CHOICE ) { if( m_gridSelectBox == NULL ) // Should not happen return; /* * Don't use wxCommandEvent::GetClientData() here. It always * returns NULL in GTK. This solution is not as elegant but * it works. */ int index = m_gridSelectBox->GetSelection(); wxASSERT( index != wxNOT_FOUND ); clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index ); if( clientData != NULL ) eventId = *clientData; } else { eventId = event.GetId(); } int idx = eventId - ID_POPUP_GRID_LEVEL_1000; // Notify GAL TOOL_MANAGER* mgr = GetToolManager(); if( mgr && IsGalCanvasActive() ) { mgr->RunAction( "common.Control.gridPreset", true, idx ); } else SetPresetGrid( idx ); m_canvas->Refresh(); }
void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun ) { m_messagePanel->Clear(); REPORTER& reporter = m_messagePanel->Reporter(); TOOL_MANAGER* toolManager = m_frame->GetToolManager(); BOARD* board = m_frame->GetBoard(); // keep trace of the initial baord area, if we want to place new footprints // outside the existinag board EDA_RECT bbox = board->GetBoundingBox(); if( !aDryRun ) { // Clear selection, just in case a selected item has to be removed toolManager->RunAction( PCB_ACTIONS::selectionClear, true ); } m_netlist->SetDeleteExtraFootprints( true ); m_netlist->SetFindByTimeStamp( m_matchByTimestamp->GetValue() ); m_netlist->SetReplaceFootprints( true ); try { m_frame->LoadFootprints( *m_netlist, &reporter ); } catch( IO_ERROR &error ) { wxString msg; reporter.Report( _( "Failed to load one or more footprints. Please add the missing libraries in PCBNew configuration. " "The PCB will not update completely." ), REPORTER::RPT_ERROR ); reporter.Report( error.What(), REPORTER::RPT_INFO ); } BOARD_NETLIST_UPDATER updater( m_frame, m_frame->GetBoard() ); updater.SetReporter ( &reporter ); updater.SetIsDryRun( aDryRun); updater.SetLookupByTimestamp( m_matchByTimestamp->GetValue() ); updater.SetDeleteUnusedComponents ( true ); updater.SetReplaceFootprints( true ); updater.SetDeleteSinglePadNets( false ); updater.UpdateNetlist( *m_netlist ); m_messagePanel->Flush(); if( aDryRun ) return; m_frame->SetCurItem( NULL ); m_frame->SetMsgPanel( board ); std::vector<MODULE*> newFootprints = updater.GetAddedComponents(); // Spread new footprints. wxPoint areaPosition = m_frame->GetCrossHairPosition(); if( !m_frame->IsGalCanvasActive() ) { // In legacy mode place area to the left side of the board. // if the board is empty, the bbox position is (0,0) areaPosition.x = bbox.GetEnd().x + Millimeter2iu( 10 ); areaPosition.y = bbox.GetOrigin().y; } m_frame->SpreadFootprints( &newFootprints, false, false, areaPosition, false ); if( m_frame->IsGalCanvasActive() ) { // Start move and place the new modules command if( !newFootprints.empty() ) { for( MODULE* footprint : newFootprints ) { toolManager->RunAction( PCB_ACTIONS::selectItem, true, footprint ); } toolManager->InvokeTool( "pcbnew.InteractiveEdit" ); } } else // Legacy canvas m_frame->GetCanvas()->Refresh(); m_btnPerformUpdate->Enable( false ); m_btnPerformUpdate->SetLabel( _( "Update complete" ) ); m_btnCancel->SetLabel( _( "Close" ) ); m_btnCancel->SetFocus(); }