void DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup( bool aDryRun ) { for( DRC_ITEM* item : m_items ) delete item; m_items.clear(); wxBusyCursor busy; BOARD_COMMIT commit( m_parentFrame ); TRACKS_CLEANER cleaner( m_parentFrame->GetUserUnits(), m_parentFrame->GetBoard(), commit ); if( !aDryRun ) { // Clear current selection list to avoid selection of deleted items m_parentFrame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true ); } // Old model has to be refreshed, GAL normally does not keep updating it m_parentFrame->Compile_Ratsnest( NULL, false ); bool modified = cleaner.CleanupBoard( aDryRun, &m_items, m_cleanShortCircuitOpt->GetValue(), m_cleanViasOpt->GetValue(), m_mergeSegmOpt->GetValue(), m_deleteUnconnectedOpt->GetValue() ); if( aDryRun ) { m_ItemsListBox->SetList( GetUserUnits(), new DRC_LIST_GENERIC( &m_items ) ); } else if( modified ) { // Clear undo and redo lists to avoid inconsistencies between lists commit.Push( _( "Board cleanup" ) ); m_parentFrame->GetCanvas()->Refresh( true ); } }
bool DIALOG_DRC_CONTROL::writeReport( const wxString& aFullFileName ) { FILE* fp = wxFopen( aFullFileName, wxT( "w" ) ); if( fp == NULL ) return false; int count; EDA_UNITS_T units = GetUserUnits(); fprintf( fp, "** Drc report for %s **\n", TO_UTF8( m_brdEditor->GetBoard()->GetFileName() ) ); wxDateTime now = wxDateTime::Now(); fprintf( fp, "** Created on %s **\n", TO_UTF8( now.Format( wxT( "%F %T" ) ) ) ); count = m_ClearanceListBox->GetItemCount(); fprintf( fp, "\n** Found %d DRC errors **\n", count ); for( int i = 0; i<count; ++i ) fprintf( fp, "%s", TO_UTF8( m_ClearanceListBox->GetItem( i )->ShowReport( units ) ) ); count = m_UnconnectedListBox->GetItemCount(); fprintf( fp, "\n** Found %d unconnected pads **\n", count ); for( int i = 0; i<count; ++i ) fprintf( fp, "%s", TO_UTF8( m_UnconnectedListBox->GetItem( i )->ShowReport( units ) ) ); fprintf( fp, "\n** End of Report **\n" ); fclose( fp ); return true; }
void PCB_BASE_FRAME::UpdateGridSelectBox() { UpdateStatusBar(); DisplayUnitsMsg(); if( m_gridSelectBox == NULL ) return; // Update grid values with the current units setting. m_gridSelectBox->Clear(); wxArrayString gridsList; int icurr = GetScreen()->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES ); for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ ) { GRID_TYPE& grid = GetScreen()->GetGrid( i ); m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId ); } m_gridSelectBox->Append( wxT( "---" ) ); m_gridSelectBox->Append( _( "Edit user grid..." ) ); m_gridSelectBox->SetSelection( icurr ); }
bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem ) { if( aHotkeyCode == 0 ) return false; bool itemCurrentlyEdited = GetCurItem() && GetCurItem()->GetFlags(); MODULE* module = NULL; int evt_type = 0; //Used to post a wxCommandEvent on demand PCB_SCREEN* screen = GetScreen(); auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions(); /* Convert lower to upper case * (the usual toupper function has problem with non ascii codes like function keys */ if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') ) aHotkeyCode += 'A' - 'a'; EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, common_Hotkey_List ); if( HK_Descr == NULL ) HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, board_edit_Hotkey_List ); if( HK_Descr == NULL ) return false; int hk_id = HK_Descr->m_Idcommand; // Create a wxCommandEvent that will be posted in some hot keys functions wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); LAYER_NUM ll; switch( hk_id ) { default: case HK_NOT_FOUND: return false; case HK_LEFT_CLICK: OnLeftClick( aDC, aPosition ); break; case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events OnLeftClick( aDC, aPosition ); OnLeftDClick( aDC, aPosition ); break; case HK_SWITCH_TRACK_WIDTH_TO_NEXT: if( GetCanvas()->IsMouseCaptured() ) GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); if( GetDesignSettings().GetTrackWidthIndex() < GetDesignSettings().m_TrackWidthList.size() - 1 ) GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().GetTrackWidthIndex() + 1 ); else GetDesignSettings().SetTrackWidthIndex( 0 ); if( GetCanvas()->IsMouseCaptured() ) GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); break; case HK_SWITCH_TRACK_WIDTH_TO_PREVIOUS: if( GetCanvas()->IsMouseCaptured() ) GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); if( GetDesignSettings().GetTrackWidthIndex() <= 0 ) GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().m_TrackWidthList.size() -1 ); else GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().GetTrackWidthIndex() - 1 ); if( GetCanvas()->IsMouseCaptured() ) GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); break; case HK_SWITCH_GRID_TO_FASTGRID1: SetFastGrid1(); break; case HK_SWITCH_GRID_TO_FASTGRID2: SetFastGrid2(); break; case HK_SWITCH_GRID_TO_NEXT: evt_type = ID_POPUP_GRID_NEXT; break; case HK_SWITCH_GRID_TO_PREVIOUS: evt_type = ID_POPUP_GRID_PREV; break; case HK_SWITCH_LAYER_TO_PREVIOUS: ll = GetActiveLayer(); if( !IsCopperLayer( ll ) ) break; if( ll == F_Cu ) ll = B_Cu; else if( ll == B_Cu ) ll = ToLAYER_ID( GetBoard()->GetCopperLayerCount() - 2 ); else ll = ll - 1; SwitchLayer( aDC, ToLAYER_ID( ll ) ); break; case HK_SWITCH_LAYER_TO_NEXT: ll = GetActiveLayer(); if( !IsCopperLayer( ll ) ) break; if( ll == B_Cu ) ll = F_Cu; else if( ++ll >= GetBoard()->GetCopperLayerCount() - 1 ) ll = B_Cu; SwitchLayer( aDC, ToLAYER_ID( ll ) ); break; case HK_SWITCH_LAYER_TO_COMPONENT: SwitchLayer( aDC, F_Cu ); break; case HK_SWITCH_LAYER_TO_COPPER: SwitchLayer( aDC, B_Cu ); break; case HK_SWITCH_LAYER_TO_INNER1: SwitchLayer( aDC, In1_Cu ); break; case HK_SWITCH_LAYER_TO_INNER2: SwitchLayer( aDC, In2_Cu ); break; case HK_SWITCH_LAYER_TO_INNER3: SwitchLayer( aDC, In3_Cu ); break; case HK_SWITCH_LAYER_TO_INNER4: SwitchLayer( aDC, In4_Cu ); break; case HK_SWITCH_LAYER_TO_INNER5: SwitchLayer( aDC, In5_Cu ); break; case HK_SWITCH_LAYER_TO_INNER6: SwitchLayer( aDC, In6_Cu ); break; case HK_HELP: // Display Current hotkey list DisplayHotkeyList( this, g_Board_Editor_Hotkeys_Descr ); break; case HK_PREFERENCES: evt_type = wxID_PREFERENCES; break; case HK_ZOOM_IN: evt_type = ID_KEY_ZOOM_IN; break; case HK_ZOOM_OUT: evt_type = ID_KEY_ZOOM_OUT; break; case HK_ZOOM_REDRAW: evt_type = ID_ZOOM_REDRAW; break; case HK_ZOOM_AUTO: evt_type = ID_ZOOM_PAGE; break; case HK_ZOOM_CENTER: evt_type = ID_POPUP_ZOOM_CENTER; break; case HK_ZOOM_SELECTION: evt_type = ID_ZOOM_SELECTION; break; case HK_ADD_MODULE: evt_type = ID_PCB_MODULE_BUTT; break; case HK_UNDO: case HK_REDO: if( !itemCurrentlyEdited ) { wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent ); wxPostEvent( this, event ); } break; case HK_RESET_LOCAL_COORD: // Set the relative coord GetScreen()->m_O_Curseur = GetCrossHairPosition(); break; case HK_SET_GRID_ORIGIN: PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this, new KIGFX::ORIGIN_VIEWITEM( GetGridOrigin(), UR_TRANSIENT ), GetCrossHairPosition() ); m_canvas->Refresh(); break; case HK_RESET_GRID_ORIGIN: PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this, new KIGFX::ORIGIN_VIEWITEM( GetGridOrigin(), UR_TRANSIENT ), wxPoint( 0, 0 ) ); m_canvas->Refresh(); break; case HK_SWITCH_UNITS: evt_type = (GetUserUnits() == INCHES) ? ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH; break; case HK_SWITCH_TRACK_DISPLAY_MODE: displ_opts->m_DisplayPcbTrackFill = !displ_opts->m_DisplayPcbTrackFill; m_canvas->Refresh(); break; case HK_DELETE: OnHotkeyDeleteItem( aDC ); break; case HK_BACK_SPACE: if( IsCopperLayer( GetActiveLayer() ) ) { if( !itemCurrentlyEdited ) { // no track is currently being edited - select a segment and remove it. // @todo: possibly? pass the HK command code to PcbGeneralLocateAndDisplay() // so it can restrict its search to specific item types. BOARD_ITEM * item = PcbGeneralLocateAndDisplay(); // don't let backspace delete modules!! if( item && item->IsTrack() ) { Delete_Segment( aDC, (TRACK*) item ); SetCurItem( NULL ); } OnModify(); } else if( GetCurItem()->IsTrack() ) { // then an element is being edited - remove the last segment. // simple lines for debugger: TRACK* track = (TRACK*) GetCurItem(); track = Delete_Segment( aDC, track ); SetCurItem( track ); OnModify(); } } break; case HK_GET_AND_MOVE_FOOTPRINT: if( !itemCurrentlyEdited ) evt_type = ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST; break; case HK_FIND_ITEM: if( !itemCurrentlyEdited ) evt_type = ID_FIND_ITEMS; break; case HK_OPEN: if( !itemCurrentlyEdited ) evt_type = ID_LOAD_FILE ; break; case HK_SAVE: if( !itemCurrentlyEdited ) evt_type = ID_SAVE_BOARD; break; case HK_ADD_MICROVIA: // Place a micro via if a track is in progress if( GetToolId() != ID_TRACK_BUTT ) return true; if( !itemCurrentlyEdited ) // no track in progress: nothing to do break; if( GetCurItem()->Type() != PCB_TRACE_T ) // Should not occur return true; if( !GetCurItem()->IsNew() ) return true; // place micro via and switch layer if( IsMicroViaAcceptable() ) evt_type = ID_POPUP_PCB_PLACE_MICROVIA; break; case HK_ADD_BLIND_BURIED_VIA: case HK_ADD_THROUGH_VIA: // Switch to alternate layer and Place a via if a track is in progress if( GetBoard()->GetDesignSettings().m_BlindBuriedViaAllowed && hk_id == HK_ADD_BLIND_BURIED_VIA ) GetBoard()->GetDesignSettings().m_CurrentViaType = VIA_BLIND_BURIED; else GetBoard()->GetDesignSettings().m_CurrentViaType = VIA_THROUGH; if( !itemCurrentlyEdited ) // no track in progress: switch layer only { Other_Layer_Route( NULL, aDC ); if( displ_opts->m_ContrastModeDisplay ) m_canvas->Refresh(); break; } if( GetToolId() != ID_TRACK_BUTT ) return true; if( GetCurItem()->Type() != PCB_TRACE_T ) return true; if( !GetCurItem()->IsNew() ) return true; evt_type = hk_id == HK_ADD_BLIND_BURIED_VIA ? ID_POPUP_PCB_PLACE_BLIND_BURIED_VIA : ID_POPUP_PCB_PLACE_THROUGH_VIA; break; case HK_SEL_LAYER_AND_ADD_THROUGH_VIA: case HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA: if( GetCurItem() == NULL || !GetCurItem()->IsNew() || GetCurItem()->Type() != PCB_TRACE_T ) break; evt_type = hk_id == HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA ? ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_BLIND_BURIED_VIA : ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_THROUGH_VIA; break; case HK_SWITCH_TRACK_POSTURE: /* change the position of initial segment when creating new tracks * switch from _/ to -\ . */ evt_type = ID_POPUP_PCB_SWITCH_TRACK_POSTURE ; break; case HK_DRAG_TRACK_KEEP_SLOPE: OnHotkeyMoveItem( HK_DRAG_TRACK_KEEP_SLOPE ); break; case HK_PLACE_ITEM: OnHotkeyPlaceItem( aDC ); break; case HK_ADD_NEW_TRACK: // Start new track, if possible OnHotkeyBeginRoute( aDC ); break; case HK_EDIT_ITEM: // Edit board item OnHotkeyEditItem( HK_EDIT_ITEM ); break; case HK_EDIT_MODULE_WITH_MODEDIT: // Edit module with module editor OnHotkeyEditItem( HK_EDIT_MODULE_WITH_MODEDIT ); break; case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status: // get any module, locked or not locked and toggle its locked status if( !itemCurrentlyEdited ) { wxPoint pos = RefPos( true ); module = GetBoard()->GetFootprint( pos, screen->m_Active_Layer, true ); } else if( GetCurItem()->Type() == PCB_MODULE_T ) { module = (MODULE*) GetCurItem(); } if( module ) { SetCurItem( module ); module->SetLocked( !module->IsLocked() ); OnModify(); SetMsgPanel( module ); } break; case HK_DRAG_ITEM: // Start drag module or track segment OnHotkeyMoveItem( HK_DRAG_ITEM ); break; case HK_MOVE_ITEM: // Start move item OnHotkeyMoveItem( HK_MOVE_ITEM ); break; case HK_COPY_ITEM: evt_type = OnHotkeyCopyItem(); break; case HK_ROTATE_ITEM: // Rotation OnHotkeyRotateItem( HK_ROTATE_ITEM ); break; case HK_FLIP_ITEM: OnHotkeyFlipItem( HK_FLIP_ITEM ); break; case HK_MOVE_ITEM_EXACT: case HK_DUPLICATE_ITEM: case HK_DUPLICATE_ITEM_AND_INCREMENT: case HK_CREATE_ARRAY: OnHotkeyDuplicateOrArrayItem( HK_Descr->m_Idcommand ); break; case HK_SWITCH_HIGHCONTRAST_MODE: // switch to high contrast mode and refresh the canvas displ_opts->m_ContrastModeDisplay = !displ_opts->m_ContrastModeDisplay; m_canvas->Refresh(); break; case HK_CANVAS_CAIRO: evt_type = ID_MENU_CANVAS_CAIRO; break; case HK_CANVAS_OPENGL: evt_type = ID_MENU_CANVAS_OPENGL; break; case HK_CANVAS_LEGACY: evt_type = ID_MENU_CANVAS_LEGACY; break; case HK_ZONE_FILL_OR_REFILL: evt_type = ID_POPUP_PCB_FILL_ALL_ZONES; break; case HK_ZONE_REMOVE_FILLED: evt_type = ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES; break; } if( evt_type != 0 ) { wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); evt.SetEventObject( this ); evt.SetId( evt_type ); GetEventHandler()->ProcessEvent( evt ); } return true; }
void PL_EDITOR_FRAME::UpdateStatusBar() { PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) GetScreen(); if( !screen ) return; // Display Zoom level: EDA_DRAW_FRAME::UpdateStatusBar(); // coordinate origin can be the paper Top Left corner, or each of 4 page corners wxPoint originCoord; int Xsign = 1; int Ysign = 1; WS_DATA_ITEM dummy( WS_DATA_ITEM::WS_SEGMENT ); switch( m_originSelectChoice ) { default: case 0: // Origin = paper Left Top corner break; case 1: // Origin = page Right Bottom corner Xsign = -1; Ysign = -1; dummy.SetStart( 0, 0, RB_CORNER ); originCoord = dummy.GetStartPosUi(); break; case 2: // Origin = page Left Bottom corner Ysign = -1; dummy.SetStart( 0, 0, LB_CORNER ); originCoord = dummy.GetStartPosUi(); break; case 3: // Origin = page Right Top corner Xsign = -1; dummy.SetStart( 0, 0, RT_CORNER ); originCoord = dummy.GetStartPosUi(); break; case 4: // Origin = page Left Top corner dummy.SetStart( 0, 0, LT_CORNER ); originCoord = dummy.GetStartPosUi(); break; } SetGridOrigin( originCoord ); // Display absolute coordinates: wxPoint coord = GetCrossHairPosition() - originCoord; double dXpos = To_User_Unit( GetUserUnits(), coord.x*Xsign ); double dYpos = To_User_Unit( GetUserUnits(), coord.y*Ysign ); wxString pagesizeformatter = _( "Page size: width %.4g height %.4g" ); wxString absformatter = wxT( "X %.4g Y %.4g" ); wxString locformatter = wxT( "dx %.4g dy %.4g" ); switch( GetUserUnits() ) { case INCHES: SetStatusText( _("inches"), 5 ); break; case MILLIMETRES: SetStatusText( _("mm"), 5 ); break; case UNSCALED_UNITS: SetStatusText( wxEmptyString, 5 ); break; case DEGREES: wxASSERT( false ); break; } wxString line; // Display page size #define MILS_TO_MM (25.4/1000) DSIZE size = GetPageSettings().GetSizeMils(); size = size * MILS_TO_MM; line.Printf( pagesizeformatter, size.x, size.y ); SetStatusText( line, 0 ); // Display abs coordinates line.Printf( absformatter, dXpos, dYpos ); SetStatusText( line, 2 ); // Display relative coordinates: int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x; int dy = GetCrossHairPosition().y - screen->m_O_Curseur.y; dXpos = To_User_Unit( GetUserUnits(), dx * Xsign ); dYpos = To_User_Unit( GetUserUnits(), dy * Ysign ); line.Printf( locformatter, dXpos, dYpos ); SetStatusText( line, 3 ); // Display corner reference for coord origin line.Printf( _("coord origin: %s"), m_originSelectBox->GetString( m_originSelectChoice ). GetData() ); SetStatusText( line, 4 ); // Display units }
void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu ) { int maxZoomIds; double zoom; wxString msg; BASE_SCREEN* screen = m_canvas->GetScreen(); msg = AddHotkeyName( _( "Center" ), m_hotkeysDescrList, HK_ZOOM_CENTER ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, KiBitmap( zoom_center_on_screen_xpm ) ); msg = AddHotkeyName( _( "Zoom In" ), m_hotkeysDescrList, HK_ZOOM_IN ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_IN, msg, KiBitmap( zoom_in_xpm ) ); msg = AddHotkeyName( _( "Zoom Out" ), m_hotkeysDescrList, HK_ZOOM_OUT ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_OUT, msg, KiBitmap( zoom_out_xpm ) ); msg = AddHotkeyName( _( "Redraw View" ), m_hotkeysDescrList, HK_ZOOM_REDRAW ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_REDRAW, msg, KiBitmap( zoom_redraw_xpm ) ); msg = AddHotkeyName( _( "Zoom to Fit" ), m_hotkeysDescrList, HK_ZOOM_AUTO ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_PAGE, msg, KiBitmap( zoom_fit_in_page_xpm ) ); wxMenu* zoom_choice = new wxMenu; AddMenuItem( MasterMenu, zoom_choice, ID_POPUP_ZOOM_SELECT, _( "Zoom" ), KiBitmap( zoom_selection_xpm ) ); zoom = screen->GetZoom(); maxZoomIds = ID_POPUP_ZOOM_LEVEL_END - ID_POPUP_ZOOM_LEVEL_START; maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.size() ) ? maxZoomIds : screen->m_ZoomList.size(); // Populate zoom submenu. for( int i = 0; i < maxZoomIds; i++ ) { msg.Printf( wxT( "%.2f" ), m_zoomLevelCoeff / screen->m_ZoomList[i] ); zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg, wxEmptyString, wxITEM_CHECK ); if( zoom == screen->m_ZoomList[i] ) zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true ); } // Create grid submenu as required. if( screen->GetGridCount() ) { wxMenu* gridMenu = new wxMenu; AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT, _( "Grid" ), KiBitmap( grid_select_xpm ) ); wxArrayString gridsList; int icurr = screen->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES ); for( unsigned i = 0; i < gridsList.GetCount(); i++ ) { GRID_TYPE& grid = screen->GetGrid( i ); gridMenu->Append( grid.m_CmdId, gridsList[i], wxEmptyString, wxITEM_CHECK ); if( (int)i == icurr ) gridMenu->Check( grid.m_CmdId, true ); } } MasterMenu->AppendSeparator(); AddMenuItem( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), KiBitmap( cancel_xpm ) ); }
/* * Update the status bar information. */ void PCB_BASE_FRAME::UpdateStatusBar() { PCB_SCREEN* screen = GetScreen(); if( !screen ) return; wxString line; wxString locformatter; EDA_DRAW_FRAME::UpdateStatusBar(); if( GetShowPolarCoords() ) // display polar coordinates { double dx = (double)GetCrossHairPosition().x - (double)screen->m_O_Curseur.x; double dy = (double)GetCrossHairPosition().y - (double)screen->m_O_Curseur.y; double theta = ArcTangente( -dy, dx ) / 10; double ro = hypot( dx, dy ); wxString formatter; switch( GetUserUnits() ) { case INCHES: formatter = "r %.6f theta %.1f"; break; case MILLIMETRES: formatter = "r %.6f theta %.1f"; break; case UNSCALED_UNITS: formatter = "r %f theta %f"; break; case DEGREES: wxASSERT( false ); break; } line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta ); SetStatusText( line, 3 ); } // Display absolute coordinates: double dXpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().x ); double dYpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().y ); // The following sadly is an if Eeschema/if Pcbnew wxString absformatter; switch( GetUserUnits() ) { case INCHES: absformatter = "X %.6f Y %.6f"; locformatter = "dx %.6f dy %.6f dist %.4f"; break; case MILLIMETRES: absformatter = "X %.6f Y %.6f"; locformatter = "dx %.6f dy %.6f dist %.3f"; break; case UNSCALED_UNITS: absformatter = "X %f Y %f"; locformatter = "dx %f dy %f dist %f"; break; case DEGREES: wxASSERT( false ); break; } line.Printf( absformatter, dXpos, dYpos ); SetStatusText( line, 2 ); if( !GetShowPolarCoords() ) // display relative cartesian coordinates { // Display relative coordinates: double dx = (double)GetCrossHairPosition().x - (double)screen->m_O_Curseur.x; double dy = (double)GetCrossHairPosition().y - (double)screen->m_O_Curseur.y; dXpos = To_User_Unit( GetUserUnits(), dx ); dYpos = To_User_Unit( GetUserUnits(), dy ); // We already decided the formatter above line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) ); SetStatusText( line, 3 ); } }
void SCH_EDIT_FRAME::ReCreateMenuBar() { EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>(); // wxWidgets handles the Mac Application menu behind the scenes, but that means // we always have to start from scratch with a new wxMenuBar. wxMenuBar* oldMenuBar = GetMenuBar(); wxMenuBar* menuBar = new wxMenuBar(); auto modifiedDocumentCondition = [] ( const SELECTION& sel ) { SCH_SHEET_LIST sheetList( g_RootSheet ); return sheetList.IsModified(); }; //-- File menu ----------------------------------------------------------- // CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool ); static ACTION_MENU* openRecentMenu; if( Kiface().IsSingle() ) // not when under a project mgr { // Add this menu to list menu managed by m_fileHistory // (the file history will be updated when adding/removing files in history) if( openRecentMenu ) Kiface().GetFileHistory().RemoveMenu( openRecentMenu ); openRecentMenu = new ACTION_MENU(); openRecentMenu->SetTool( selTool ); openRecentMenu->SetTitle( _( "Open Recent" ) ); openRecentMenu->SetIcon( recent_xpm ); Kiface().GetFileHistory().UseMenu( openRecentMenu ); Kiface().GetFileHistory().AddFilesToMenu( openRecentMenu ); fileMenu->AddItem( ACTIONS::doNew, EE_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::open, EE_CONDITIONS::ShowAlways ); fileMenu->AddMenu( openRecentMenu, EE_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); } fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition ); fileMenu->AddItem( ACTIONS::saveAs, EE_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::saveAll, modifiedDocumentCondition ); fileMenu->AddSeparator(); fileMenu->AddItem( ID_APPEND_PROJECT, _( "Append Schematic Sheet Content..." ), _( "Append schematic sheet content from another project to the current sheet" ), add_document_xpm, EE_CONDITIONS::ShowAlways ); fileMenu->AddItem( ID_IMPORT_NON_KICAD_SCH, _( "Import Non KiCad Schematic..." ), _( "Replace current schematic sheet with one imported from another application" ), import_document_xpm, EE_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); // Import submenu ACTION_MENU* submenuImport = new ACTION_MENU(); submenuImport->SetTool( selTool ); submenuImport->SetTitle( _( "Import" ) ); submenuImport->SetIcon( import_xpm ); submenuImport->Add( _( "Footprint Association File..." ), HELP_IMPORT_FOOTPRINTS, ID_BACKANNO_ITEMS, import_footprint_names_xpm ); fileMenu->AddMenu( submenuImport, EE_CONDITIONS::ShowAlways ); // Export submenu ACTION_MENU* submenuExport = new ACTION_MENU(); submenuExport->SetTool( selTool ); submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetIcon( export_xpm ); submenuExport->Add( _( "Drawing to Clipboard" ), _( "Export drawings to clipboard" ), ID_GEN_COPY_SHEET_TO_CLIPBOARD, copy_xpm ); submenuExport->Add( _( "Netlist..." ), _( "Export netlist file" ), ID_GET_NETLIST, netlist_xpm ); fileMenu->AddMenu( submenuExport, EE_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); fileMenu->AddItem( ACTIONS::pageSettings, EE_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::print, EE_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::plot, EE_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); // Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, EE_CONDITIONS::ShowAlways ); //-- Edit menu ----------------------------------------------------------- // CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool ); auto enableUndoCondition = [ this ] ( const SELECTION& sel ) { return GetScreen() && GetScreen()->GetUndoCommandCount() > 0; }; auto enableRedoCondition = [ this ] ( const SELECTION& sel ) { return GetScreen() && GetScreen()->GetRedoCommandCount() > 0; }; editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); editMenu->AddItem( ACTIONS::redo, enableRedoCondition ); editMenu->AddSeparator(); editMenu->AddItem( ACTIONS::cut, EE_CONDITIONS::NotEmpty ); editMenu->AddItem( ACTIONS::copy, EE_CONDITIONS::NotEmpty ); editMenu->AddItem( ACTIONS::paste, EE_CONDITIONS::Idle ); editMenu->AddItem( ACTIONS::duplicate, EE_CONDITIONS::NotEmpty ); editMenu->AddSeparator(); editMenu->AddItem( EE_ACTIONS::deleteItemCursor, EE_CONDITIONS::ShowAlways ); // Find editMenu->AddSeparator(); editMenu->AddItem( ACTIONS::find, EE_CONDITIONS::ShowAlways ); editMenu->AddItem( ACTIONS::findAndReplace, EE_CONDITIONS::ShowAlways ); editMenu->AddSeparator(); // Update field values editMenu->AddItem( ID_UPDATE_FIELDS, _( "Update Fields from Library..." ), _( "Sets symbol fields to original library values" ), update_fields_xpm, EE_CONDITIONS::ShowAlways ); //-- View menu ----------------------------------------------------------- // CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool ); auto belowRootSheetCondition = [] ( const SELECTION& aSel ) { return g_CurrentSheet->Last() != g_RootSheet; }; auto gridShownCondition = [ this ] ( const SELECTION& aSel ) { return IsGridVisible(); }; auto imperialUnitsCondition = [ this ] ( const SELECTION& aSel ) { return GetUserUnits() == INCHES; }; auto metricUnitsCondition = [ this ] ( const SELECTION& aSel ) { return GetUserUnits() == MILLIMETRES; }; auto fullCrosshairCondition = [ this ] ( const SELECTION& aSel ) { return GetGalDisplayOptions().m_fullscreenCursor; }; auto hiddenPinsCondition = [ this ] ( const SELECTION& aSel ) { return GetShowAllPins(); }; viewMenu->AddItem( EE_ACTIONS::showLibraryBrowser, EE_CONDITIONS::ShowAlways ); viewMenu->AddItem( EE_ACTIONS::navigateHierarchy, EE_CONDITIONS::ShowAlways ); viewMenu->AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition ); viewMenu->AddSeparator(); viewMenu->AddItem( ACTIONS::zoomInCenter, EE_CONDITIONS::ShowAlways ); viewMenu->AddItem( ACTIONS::zoomOutCenter, EE_CONDITIONS::ShowAlways ); viewMenu->AddItem( ACTIONS::zoomFitScreen, EE_CONDITIONS::ShowAlways ); viewMenu->AddItem( ACTIONS::zoomTool, EE_CONDITIONS::ShowAlways ); viewMenu->AddItem( ACTIONS::zoomRedraw, EE_CONDITIONS::ShowAlways ); viewMenu->AddSeparator(); viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition ); viewMenu->AddItem( ACTIONS::gridProperties, EE_CONDITIONS::ShowAlways ); // Units submenu CONDITIONAL_MENU* unitsSubMenu = new CONDITIONAL_MENU( false, selTool ); unitsSubMenu->SetTitle( _( "&Units" ) ); unitsSubMenu->SetIcon( unit_mm_xpm ); unitsSubMenu->AddCheckItem( ACTIONS::imperialUnits, imperialUnitsCondition ); unitsSubMenu->AddCheckItem( ACTIONS::metricUnits, metricUnitsCondition ); viewMenu->AddMenu( unitsSubMenu ); viewMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition ); viewMenu->AddSeparator(); viewMenu->AddCheckItem( EE_ACTIONS::toggleHiddenPins, hiddenPinsCondition ); #ifdef __APPLE__ viewMenu->AppendSeparator(); #endif //-- Place menu ----------------------------------------------------------- // CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool ); placeMenu->AddItem( EE_ACTIONS::placeSymbol, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::placePower, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::drawWire, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::drawBus, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::placeBusWireEntry, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::placeBusBusEntry, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::placeNoConnect, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::placeJunction, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::placeLabel, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::placeGlobalLabel, EE_CONDITIONS::ShowAlways ); placeMenu->AddSeparator(); placeMenu->AddItem( EE_ACTIONS::placeHierarchicalLabel, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::drawSheet, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::importSheetPin, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::placeSheetPin, EE_CONDITIONS::ShowAlways ); placeMenu->AddSeparator(); placeMenu->AddItem( EE_ACTIONS::drawLines, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::placeSchematicText, EE_CONDITIONS::ShowAlways ); placeMenu->AddItem( EE_ACTIONS::placeImage, EE_CONDITIONS::ShowAlways ); //-- Inspect menu ----------------------------------------------- // wxMenu* inspectMenu = new wxMenu; AddMenuItem( inspectMenu, ID_GET_ERC, _( "Electrical Rules &Checker" ), _( "Perform electrical rules check" ), KiBitmap( erc_xpm ) ); //-- Tools menu ----------------------------------------------- // wxMenu* toolsMenu = new wxMenu; prepareToolsMenu( toolsMenu ); //-- Preferences menu ----------------------------------------------- // CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, selTool ); auto acceleratedGraphicsCondition = [ this ] ( const SELECTION& aSel ) { return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; }; auto standardGraphicsCondition = [ this ] ( const SELECTION& aSel ) { return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; }; prefsMenu->AddItem( ID_PREFERENCES_CONFIGURE_PATHS, _( "Configure Pa&ths..." ), _( "Edit path configuration environment variables" ), path_xpm, EE_CONDITIONS::ShowAlways ); prefsMenu->AddItem( ID_EDIT_SYM_LIB_TABLE, _( "Manage Symbol Libraries..." ), _( "Edit the global and project symbol library lists" ), library_table_xpm, EE_CONDITIONS::ShowAlways ); prefsMenu->AddItem( wxID_PREFERENCES, AddHotkeyName( _( "&Preferences..." ), g_Eeschema_Hotkeys_Descr, HK_PREFERENCES ), _( "Show preferences for all open tools" ), preference_xpm, EE_CONDITIONS::ShowAlways ); prefsMenu->AddSeparator(); Pgm().AddMenuLanguageList( prefsMenu ); prefsMenu->AddSeparator(); prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition ); prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition ); //-- Menubar ----------------------------------------------- // menuBar->Append( fileMenu, _( "&File" ) ); menuBar->Append( editMenu, _( "&Edit" ) ); menuBar->Append( viewMenu, _( "&View" ) ); menuBar->Append( placeMenu, _( "&Place" ) ); menuBar->Append( inspectMenu, _( "&Inspect" ) ); menuBar->Append( toolsMenu, _( "&Tools" ) ); menuBar->Append( prefsMenu, _( "P&references" ) ); AddStandardHelpMenu( menuBar ); SetMenuBar( menuBar ); delete oldMenuBar; }