From a5cca18dd1f348579328de29f09e56e591fe6ae0 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Tue, 13 Mar 2018 17:59:46 -0400 Subject: [PATCH] GerbView: add view menu. Include all actions provided by left vertical toolbar in a new view menu for consistency with other main frames. Move show/hide layer manager to view menu. Simplify some toolbar and menu update logic. Fixes lp:1753337 https://bugs.launchpad.net/kicad/+bug/1753337 --- gerbview/events_called_functions.cpp | 113 ++++++++-------- gerbview/gerbview_frame.cpp | 6 + gerbview/gerbview_frame.h | 186 ++++++++++++++------------- gerbview/gerbview_id.h | 3 +- gerbview/menubar.cpp | 119 +++++++++++++++-- gerbview/toolbars_gerber.cpp | 113 ++++++++++++---- 6 files changed, 354 insertions(+), 186 deletions(-) diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index 14ced4e975..d0f33cb1a3 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -43,6 +43,8 @@ #include #include +#include +#include #include #include #include @@ -84,8 +86,6 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME ) EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END, GERBVIEW_FRAME::Process_Config ) - EVT_MENU( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, - GERBVIEW_FRAME::OnSelectOptionToolbar ) EVT_MENU( wxID_PREFERENCES, GERBVIEW_FRAME::InstallGerberOptionsDialog ) EVT_UPDATE_UI( ID_MENU_CANVAS_LEGACY, GERBVIEW_FRAME::OnUpdateSwitchCanvas ) EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::OnUpdateSwitchCanvas ) @@ -126,12 +126,12 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME ) //EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions ) // mentioned below EVT_TOOL( ID_ZOOM_SELECTION, GERBVIEW_FRAME::Process_Special_Functions ) EVT_TOOL( ID_TB_MEASUREMENT_TOOL, GERBVIEW_FRAME::Process_Special_Functions ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_POLAR_COORD, GERBVIEW_FRAME::OnSelectOptionToolbar ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar ) + EVT_TOOL( ID_TB_OPTIONS_SHOW_POLAR_COORD, GERBVIEW_FRAME::OnToggleCoordType ) + EVT_TOOL( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, GERBVIEW_FRAME::OnTogglePolygonDrawMode ) + EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, GERBVIEW_FRAME::OnToggleFlashItemDrawMode ) + EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnToggleLineDrawMode ) EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, - GERBVIEW_FRAME::OnSelectOptionToolbar ) + GERBVIEW_FRAME::OnToggleShowLayerManager ) EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES, GERBVIEW_FRAME::OnSelectOptionToolbar ) EVT_TOOL( ID_TB_OPTIONS_SHOW_NEGATIVE_ITEMS, GERBVIEW_FRAME::OnSelectOptionToolbar ) EVT_TOOL_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2, @@ -142,7 +142,8 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME ) // Auxiliary horizontal toolbar EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice ) EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice ) - EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice ) + EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, + GERBVIEW_FRAME::OnSelectHighlightChoice ) // Right click context menu EVT_MENU( ID_HIGHLIGHT_CMP_ITEMS, GERBVIEW_FRAME::Process_Special_Functions ) @@ -156,8 +157,8 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLAR_COORD, GERBVIEW_FRAME::OnUpdateCoordType ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, GERBVIEW_FRAME::OnUpdateFlashedItemsDrawMode ) - EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnUpdateLinesDrawMode ) - EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, GERBVIEW_FRAME::OnUpdatePolygonsDrawMode ) + EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnUpdateLineDrawMode ) + EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, GERBVIEW_FRAME::OnUpdatePolygonDrawMode ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_DCODES, GERBVIEW_FRAME::OnUpdateShowDCodes ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_NEGATIVE_ITEMS, GERBVIEW_FRAME::OnUpdateShowNegativeItems ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, @@ -370,6 +371,7 @@ void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event ) if( gerber_layer ) { wxString editorname = Pgm().GetEditorName(); + if( !editorname.IsEmpty() ) { wxFileName fn( gerber_layer->m_FileName ); @@ -390,7 +392,6 @@ void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event ) else wxMessageBox( _( "No editor defined. Please select one" ) ); } - else { wxString msg; @@ -445,78 +446,45 @@ void GERBVIEW_FRAME::ShowChangedLanguage() } +void GERBVIEW_FRAME::OnToggleShowLayerManager( wxCommandEvent& aEvent ) +{ + m_show_layer_manager_tools = !m_show_layer_manager_tools; + + // show/hide auxiliary Vertical layers and visibility manager toolbar + m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools ); + m_auimgr.Update(); +} + + void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) { int id = event.GetId(); - bool state; bool needs_refresh = false; GBR_DISPLAY_OPTIONS options = m_DisplayOptions; switch( id ) { - case ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG: - state = ! m_show_layer_manager_tools; - id = ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR; - break; - - default: - state = m_optionsToolBar->GetToolToggled( id ); - break; - } - - switch( id ) - { - case ID_TB_OPTIONS_SHOW_POLAR_COORD: - options.m_DisplayPolarCood = state; - break; - - case ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH: - options.m_DisplayFlashedItemsFill = not state; - needs_refresh = true; - break; - - case ID_TB_OPTIONS_SHOW_LINES_SKETCH: - options.m_DisplayLinesFill = not state; - needs_refresh = true; - break; - - case ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH: - options.m_DisplayPolygonsFill = not state; - needs_refresh = true; - break; - case ID_TB_OPTIONS_SHOW_DCODES: - SetElementVisibility( LAYER_DCODES, state ); + SetElementVisibility( LAYER_DCODES, !IsElementVisible( LAYER_DCODES ) ); m_canvas->Refresh( true ); break; case ID_TB_OPTIONS_SHOW_NEGATIVE_ITEMS: - SetElementVisibility( LAYER_NEGATIVE_OBJECTS, state ); - needs_refresh = true; + SetElementVisibility( LAYER_NEGATIVE_OBJECTS, !IsElementVisible( LAYER_NEGATIVE_OBJECTS ) ); + m_canvas->Refresh( true ); break; case ID_TB_OPTIONS_DIFF_MODE: - options.m_DiffMode = state; + options.m_DiffMode = !options.m_DiffMode; needs_refresh = true; break; case ID_TB_OPTIONS_HIGH_CONTRAST_MODE: - options.m_HighContrastMode = state; + options.m_HighContrastMode = !options.m_HighContrastMode; needs_refresh = true; break; - case ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR: - - // show/hide auxiliary Vertical layers and visibility manager toolbar - m_show_layer_manager_tools = state; - m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools ); - m_auimgr.Update(); - GetMenuBar()->SetLabel( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, - m_show_layer_manager_tools ? - _("Hide &Layers Manager" ) : _("Show &Layers Manager" )); - break; - // collect GAL-only tools here: case ID_TB_MEASUREMENT_TOOL: SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) ); @@ -532,6 +500,33 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) } +void GERBVIEW_FRAME::OnTogglePolygonDrawMode( wxCommandEvent& aEvent ) +{ + GBR_DISPLAY_OPTIONS options = m_DisplayOptions; + options.m_DisplayPolygonsFill = !m_DisplayOptions.m_DisplayPolygonsFill; + + UpdateDisplayOptions( options ); +} + + +void GERBVIEW_FRAME::OnToggleLineDrawMode( wxCommandEvent& aEvent ) +{ + GBR_DISPLAY_OPTIONS options = m_DisplayOptions; + options.m_DisplayLinesFill = !m_DisplayOptions.m_DisplayLinesFill; + + UpdateDisplayOptions( options ); +} + + +void GERBVIEW_FRAME::OnToggleFlashItemDrawMode( wxCommandEvent& aEvent ) +{ + GBR_DISPLAY_OPTIONS options = m_DisplayOptions; + options.m_DisplayFlashedItemsFill = !m_DisplayOptions.m_DisplayFlashedItemsFill; + + UpdateDisplayOptions( options ); +} + + void GERBVIEW_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent ) { aEvent.Check( GetToolId() == aEvent.GetId() ); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 49c002cbb8..8fe78c4403 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -136,8 +136,10 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): if( m_LastGridSizeId < 0 ) m_LastGridSizeId = 0; + if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000 ) m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000; + GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); m_auimgr.SetManagedWindow( this ); @@ -1074,6 +1076,7 @@ EDA_RECT GERBVIEW_FRAME::GetGerberLayoutBoundingBox() return GetGerberLayout()->GetBoundingBox(); } + void GERBVIEW_FRAME::UpdateStatusBar() { EDA_DRAW_FRAME::UpdateStatusBar(); @@ -1177,11 +1180,13 @@ const wxString GERBVIEW_FRAME::GetZoomLevelIndicator() const return EDA_DRAW_FRAME::GetZoomLevelIndicator(); } + GERBER_FILE_IMAGE* GERBVIEW_FRAME::GetGbrImage( int aIdx ) const { return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx ); } + unsigned GERBVIEW_FRAME::ImagesMaxCount() const { return m_gerberLayout->GetImagesList()->ImagesMaxCount(); @@ -1236,6 +1241,7 @@ void GERBVIEW_FRAME::UseGalCanvas( bool aEnable ) m_LayersManager->ReFillRender(); ReCreateOptToolbar(); + ReCreateMenuBar(); } diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 76e51c64da..06927d13ba 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2013 Wayne Stambaugh + * Copyright (C) 2013 Wayne Stambaugh * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it @@ -104,23 +104,23 @@ public: * calculates the bounding box containing all gerber items. * @return EDA_RECT - the items bounding box */ - EDA_RECT GetGerberLayoutBoundingBox(); + EDA_RECT GetGerberLayoutBoundingBox(); - void SetPageSettings( const PAGE_INFO& aPageSettings ) override; - const PAGE_INFO& GetPageSettings() const override; - const wxSize GetPageSizeIU() const override; + void SetPageSettings( const PAGE_INFO& aPageSettings ) override; + const PAGE_INFO& GetPageSettings() const override; + const wxSize GetPageSizeIU() const override; - const wxPoint& GetAuxOrigin() const override; - void SetAuxOrigin( const wxPoint& aPoint ) override; + const wxPoint& GetAuxOrigin() const override; + void SetAuxOrigin( const wxPoint& aPoint ) override; - const wxPoint& GetGridOrigin() const override { return m_grid_origin; } - void SetGridOrigin( const wxPoint& aPoint ) override + const wxPoint& GetGridOrigin() const override { return m_grid_origin; } + void SetGridOrigin( const wxPoint& aPoint ) override { m_grid_origin = aPoint; } const TITLE_BLOCK& GetTitleBlock() const override; - void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override; + void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override; /** * Function SetCurItem @@ -132,7 +132,7 @@ public: * @param aItem The GERBER_DRAW_ITEM to make the selected item or NULL if none. * @param aDisplayInfo = true to display item info, false if not (default = true) */ - void SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo = true ); + void SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo = true ); /** Install the dialog box for layer selection * @param aDefaultLayer = Preselection (NB_PCB_LAYERS for "(Deselect)" layer) @@ -222,21 +222,20 @@ private: * @param aFilenameList is a list of filenames to load * @return true if every file loaded successfully */ - bool loadListOfGerberFiles( const wxString& aPath, - const wxArrayString& aFilenameList ); + bool loadListOfGerberFiles( const wxString& aPath, const wxArrayString& aFilenameList ); public: GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ); ~GERBVIEW_FRAME(); - void OnCloseWindow( wxCloseEvent& Event ); + void OnCloseWindow( wxCloseEvent& Event ); - bool OpenProjectFiles( const std::vector& aFileSet, int aCtl ) override; + bool OpenProjectFiles( const std::vector& aFileSet, int aCtl ) override; // Virtual basic functions: - void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override; - void ReCreateHToolbar() override; - void ReCreateAuxiliaryToolbar() override; + void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override; + void ReCreateHToolbar() override; + void ReCreateAuxiliaryToolbar() override; /** * Function ReCreateVToolbar @@ -244,20 +243,20 @@ public: * * @note This is currently not used. */ - void ReCreateVToolbar() override; + void ReCreateVToolbar() override; /** * Create or update the left vertical toolbar (option toolbar */ - void ReCreateOptToolbar(); + void ReCreateOptToolbar(); - void ReCreateMenuBar() override; - void OnLeftClick( wxDC* aDC, const wxPoint& aMousePos ) override; - void OnLeftDClick( wxDC* aDC, const wxPoint& aMousePos ) override; - bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) override; - void OnUpdateSelectTool( wxUpdateUIEvent& aEvent ); - double BestZoom() override; - void UpdateStatusBar() override; + void ReCreateMenuBar() override; + void OnLeftClick( wxDC* aDC, const wxPoint& aMousePos ) override; + void OnLeftDClick( wxDC* aDC, const wxPoint& aMousePos ) override; + bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) override; + void OnUpdateSelectTool( wxUpdateUIEvent& aEvent ); + double BestZoom() override; + void UpdateStatusBar() override; wxAuiToolBar* GetMainToolBar() { return m_optionsToolBar; } @@ -313,7 +312,7 @@ public: * @param aItemIdVisible is an item id from the enum GERBVIEW_LAYER_ID * @return bool - true if the element is visible. */ - bool IsElementVisible( GERBVIEW_LAYER_ID aItemIdVisible ) const; + bool IsElementVisible( GERBVIEW_LAYER_ID aItemIdVisible ) const; /** * Function SetElementVisibility @@ -322,14 +321,14 @@ public: * @param aNewState = The new visibility state of the element category * (see enum PCB) */ - void SetElementVisibility( GERBVIEW_LAYER_ID aItemIdVisible, bool aNewState ); + void SetElementVisibility( GERBVIEW_LAYER_ID aItemIdVisible, bool aNewState ); /** * Function SetGridVisibility(), virtual from EDA_DRAW_FRAME * It may be overloaded by derived classes * @param aVisible = true if the grid must be shown */ - void SetGridVisibility( bool aVisible ) override; + void SetGridVisibility( bool aVisible ) override; /** * Function GetVisibleLayers @@ -345,7 +344,7 @@ public: * changes the bit-mask of visible layers * @param aLayerMask = The new bit-mask of visible layers */ - void SetVisibleLayers( long aLayerMask ); + void SetVisibleLayers( long aLayerMask ); /** * Function IsLayerVisible @@ -353,7 +352,7 @@ public: * @param aLayer = The layer to be tested (still 0-31!) * @return bool - true if the layer is visible. */ - bool IsLayerVisible( int aLayer ) const; + bool IsLayerVisible( int aLayer ) const; /** * Function GetVisibleElementColor @@ -361,7 +360,7 @@ public: */ COLOR4D GetVisibleElementColor( GERBVIEW_LAYER_ID aItemIdVisible ); - void SetVisibleElementColor( GERBVIEW_LAYER_ID aItemIdVisible, COLOR4D aColor ); + void SetVisibleElementColor( GERBVIEW_LAYER_ID aItemIdVisible, COLOR4D aColor ); /** * Function GetLayerColor @@ -373,7 +372,7 @@ public: * Function SetLayerColor * changes a layer color for any valid layer. */ - void SetLayerColor( int aLayer, COLOR4D aColor ); + void SetLayerColor( int aLayer, COLOR4D aColor ); /** * Function GetNegativeItemsColor @@ -418,7 +417,7 @@ public: * changes out all the layers in m_Layers and may be called upon * loading new gerber files. */ - void ReFillLayerWidget(); + void ReFillLayerWidget(); /** * Function SetActiveLayer @@ -455,7 +454,7 @@ public: * This function cannot be inline without including layer_widget.h in * here and we do not want to do that. */ - void syncLayerWidget(); + void syncLayerWidget(); /** * Function syncLayerBox @@ -465,7 +464,7 @@ public: * @param aRebuildLayerBox = true to rebuild the layer box * false to just updates the selection. */ - void syncLayerBox( bool aRebuildLayerBox = false ); + void syncLayerBox( bool aRebuildLayerBox = false ); /** * Function UpdateTitleAndInfo @@ -476,7 +475,7 @@ public: * Name of the Image (found in the gerber file: IN <name> command) in the status bar * and other data in toolbar */ - void UpdateTitleAndInfo(); + void UpdateTitleAndInfo(); /** * Function GetConfigurationSettings @@ -487,26 +486,32 @@ public: * GerbView source code (mainly in dialogs). If you need to define a configuration * setting that need to be loaded at run time, this is the place to define it. */ - PARAM_CFG_ARRAY& GetConfigurationSettings( void ); + PARAM_CFG_ARRAY& GetConfigurationSettings( void ); void LoadSettings( wxConfigBase* aCfg ) override; void SaveSettings( wxConfigBase* aCfg ) override; - void ShowChangedLanguage() override; + void OnToggleCoordType( wxCommandEvent& aEvent ); + void OnToggleFlashItemDrawMode( wxCommandEvent& aEvent ); + void OnToggleLineDrawMode( wxCommandEvent& aEvent ); + void OnTogglePolygonDrawMode( wxCommandEvent& aEvent ); + void OnToggleShowLayerManager( wxCommandEvent& aEvent ); - void Process_Special_Functions( wxCommandEvent& event ); - void OnSelectOptionToolbar( wxCommandEvent& event ); + void ShowChangedLanguage() override; + + void Process_Special_Functions( wxCommandEvent& event ); + void OnSelectOptionToolbar( wxCommandEvent& event ); /// Handles the changing of the highlighted component/net/attribute - void OnSelectHighlightChoice( wxCommandEvent& event ); + void OnSelectHighlightChoice( wxCommandEvent& event ); /** * Function OnSelectActiveDCode * Selects the active DCode for the current active layer. * Items using this DCode are highlighted. */ - void OnSelectActiveDCode( wxCommandEvent& event ); + void OnSelectActiveDCode( wxCommandEvent& event ); /** * Function OnSelectActiveLayer @@ -514,14 +519,14 @@ public: * - if a file is loaded, it is loaded in this layer * _ this layer is displayed on top of other layers */ - void OnSelectActiveLayer( wxCommandEvent& event ); + void OnSelectActiveLayer( wxCommandEvent& event ); /** * Function OnShowGerberSourceFile * Call the preferred editor to show (and edit) the gerber source file * loaded in the active layer */ - void OnShowGerberSourceFile( wxCommandEvent& event ); + void OnShowGerberSourceFile( wxCommandEvent& event ); /** * Function OnSelectDisplayMode @@ -529,13 +534,13 @@ public: * Mode selection can be fast display, * or exact mode with stacked images or with transparency */ - void OnSelectDisplayMode( wxCommandEvent& event ); + void OnSelectDisplayMode( wxCommandEvent& event ); /** * Function OnQuit * called on request of application quit */ - void OnQuit( wxCommandEvent& event ); + void OnQuit( wxCommandEvent& event ); ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; @@ -551,39 +556,39 @@ public: */ bool OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ) override; - GERBER_DRAW_ITEM* Locate( const wxPoint& aPosition, int typeloc ); + GERBER_DRAW_ITEM* Locate( const wxPoint& aPosition, int typeloc ); - void Process_Config( wxCommandEvent& event ); - void InstallGerberOptionsDialog( wxCommandEvent& event ); + void Process_Config( wxCommandEvent& event ); + void InstallGerberOptionsDialog( wxCommandEvent& event ); - void OnUpdateDrawMode( wxUpdateUIEvent& aEvent ); - void OnUpdateCoordType( wxUpdateUIEvent& aEvent ); - void OnUpdateFlashedItemsDrawMode( wxUpdateUIEvent& aEvent ); - void OnUpdateLinesDrawMode( wxUpdateUIEvent& aEvent ); - void OnUpdatePolygonsDrawMode( wxUpdateUIEvent& aEvent ); - void OnUpdateShowDCodes( wxUpdateUIEvent& aEvent ); - void OnUpdateShowNegativeItems( wxUpdateUIEvent& aEvent ); - void OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent ); - void OnUpdateSelectDCode( wxUpdateUIEvent& aEvent ); - void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ); - void OnUpdateDiffMode( wxUpdateUIEvent& aEvent ); - void OnUpdateHighContrastMode( wxUpdateUIEvent& aEvent ); + void OnUpdateDrawMode( wxUpdateUIEvent& aEvent ); + void OnUpdateCoordType( wxUpdateUIEvent& aEvent ); + void OnUpdateFlashedItemsDrawMode( wxUpdateUIEvent& aEvent ); + void OnUpdateLineDrawMode( wxUpdateUIEvent& aEvent ); + void OnUpdatePolygonDrawMode( wxUpdateUIEvent& aEvent ); + void OnUpdateShowDCodes( wxUpdateUIEvent& aEvent ); + void OnUpdateShowNegativeItems( wxUpdateUIEvent& aEvent ); + void OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent ); + void OnUpdateSelectDCode( wxUpdateUIEvent& aEvent ); + void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ); + void OnUpdateDiffMode( wxUpdateUIEvent& aEvent ); + void OnUpdateHighContrastMode( wxUpdateUIEvent& aEvent ); /** * Function BlockCommand * returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to * the \a aKey (ALT, SHIFT ALT ..) */ - virtual int BlockCommand( EDA_KEY key ) override; + virtual int BlockCommand( EDA_KEY key ) override; /** * Function HandleBlockPlace * handles the block place command. */ - virtual void HandleBlockPlace( wxDC* DC ) override; + virtual void HandleBlockPlace( wxDC* DC ) override; /** - * Function HandleBlockEnd( ) + * Function HandleBlockEnd * handles the end of a block command, * It is called at the end of the definition of the area of a block. * Depending on the current block command, this command is executed @@ -593,7 +598,7 @@ public: * @return false if no item selected, or command finished, * true if some items found and HandleBlockPlace must be called later. */ - virtual bool HandleBlockEnd( wxDC* DC ) override; + virtual bool HandleBlockEnd( wxDC* DC ) override; /** * Function Block_Move @@ -601,42 +606,42 @@ public: * New location is determined by the current offset from the selected * block's original location. */ - void Block_Move(); + void Block_Move(); /** * Function ToPrinter * Open a dialog frame to print layers */ - void ToPrinter( wxCommandEvent& event ); + void ToPrinter( wxCommandEvent& event ); - void Files_io( wxCommandEvent& event ); + void Files_io( wxCommandEvent& event ); /** * Function OnGbrFileHistory * deletes the current data and loads a Gerber file selected from history list on * current layer. */ - void OnGbrFileHistory( wxCommandEvent& event ); + void OnGbrFileHistory( wxCommandEvent& event ); /** * Function OnDrlFileHistory * deletes the current data and load a drill file in Excellon format selected from * history list on current layer. */ - void OnDrlFileHistory( wxCommandEvent& event ); + void OnDrlFileHistory( wxCommandEvent& event ); /** * Function OnZipFileHistory * deletes the current data and load a zip archive file selected from the * history list. The archive is expected coantaining a set of gerber and drill file */ - void OnZipFileHistory( wxCommandEvent& event ); + void OnZipFileHistory( wxCommandEvent& event ); /** * deletes the current data and load a gerber job file selected from the * history list. */ - void OnJobFileHistory( wxCommandEvent& event ); + void OnJobFileHistory( wxCommandEvent& event ); /** * Extracts gerber and drill files from the zip archive, and load them @@ -644,8 +649,7 @@ public: * @param aReporter a REPORTER to collect warning and error messages * @return true if OK, false if a file cannot be readable */ - bool unarchiveFiles( const wxString& aFullFileName, - REPORTER* aReporter = nullptr ); + bool unarchiveFiles( const wxString& aFullFileName, REPORTER* aReporter = nullptr ); /** * function LoadGerberFiles @@ -655,8 +659,8 @@ public: * if void string: user will be prompted for filename(s) * @return true if file was opened successfully. */ - bool LoadGerberFiles( const wxString& aFileName ); - bool Read_GERBER_File( const wxString& GERBER_FullFileName ); + bool LoadGerberFiles( const wxString& aFileName ); + bool Read_GERBER_File( const wxString& GERBER_FullFileName ); /** * function LoadExcellonFiles @@ -666,8 +670,8 @@ public: * if empty string: user will be prompted for filename(s) * @return true if file was opened successfully. */ - bool LoadExcellonFiles( const wxString& aFileName ); - bool Read_EXCELLON_File( const wxString& aFullFileName ); + bool LoadExcellonFiles( const wxString& aFileName ); + bool Read_EXCELLON_File( const wxString& aFullFileName ); /** * function LoadZipArchiveFileLoadZipArchiveFile @@ -677,7 +681,7 @@ public: * if empty string: user will be prompted for filename(s) * @return true if file was opened successfully. */ - bool LoadZipArchiveFile( const wxString& aFileName ); + bool LoadZipArchiveFile( const wxString& aFileName ); /** @@ -687,30 +691,30 @@ public: * if empty string: user will be prompted for filename(s) * @return true if file(s) was opened successfully. */ - bool LoadGerberJobFile( const wxString& aFileName ); + bool LoadGerberJobFile( const wxString& aFileName ); - bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override; + bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override; /** * Set Size Items (Lines, Flashes) from DCodes List */ - void Liste_D_Codes(); + void Liste_D_Codes(); // PCB handling - bool Clear_DrawLayers( bool query ); - void Erase_Current_DrawLayer( bool query ); + bool Clear_DrawLayers( bool query ); + void Erase_Current_DrawLayer( bool query ); - void SortLayersByX2Attributes(); + void SortLayersByX2Attributes(); /** * Updates the display options and refreshes the view as needed * @param aOptions is the new options to apply */ - void UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions ); + void UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions ); // Conversion function - void ExportDataInPcbnewFormat( wxCommandEvent& event ); + void ExportDataInPcbnewFormat( wxCommandEvent& event ); /* SaveCopyInUndoList() virtual * currently: do nothing in GerbView. @@ -742,8 +746,8 @@ public: * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ - virtual void PrintPage( wxDC* aDC, LSET aPrintMasklayer, bool aPrintMirrorMode, - void* aData = NULL ) override; + virtual void PrintPage( wxDC* aDC, LSET aPrintMasklayer, bool aPrintMirrorMode, + void* aData = NULL ) override; ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas virtual void UseGalCanvas( bool aEnable ) override; diff --git a/gerbview/gerbview_id.h b/gerbview/gerbview_id.h index 035aa716a2..e33568848e 100644 --- a/gerbview/gerbview_id.h +++ b/gerbview/gerbview_id.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2010-2014 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2018 KiCad Developers, see change_log.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 @@ -48,7 +48,6 @@ enum gerbview_ids ID_GERBVIEW_SHOW_SOURCE, ID_GERBVIEW_EXPORT_TO_PCBNEW, - ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR, ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE, diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 62f64f30d4..54c3e9280b 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -2,8 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2009-2013 Wayne Stambaugh - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2009 Wayne Stambaugh + * Copyright (C) 1992-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 @@ -179,15 +179,115 @@ void GERBVIEW_FRAME::ReCreateMenuBar() _( "&Close" ), _( "Close GerbView" ), KiBitmap( exit_xpm ) ); - // Menu for configuration and preferences - wxMenu* configMenu = new wxMenu; + //--------- View menu ---------------- + wxMenu* viewMenu = new wxMenu; // Hide layer manager - AddMenuItem( configMenu, ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, - _( "Hide &Layers Manager" ), - m_show_layer_manager_tools ? - _( "Hide &Layers Manager" ) : _("Show &Layers Manager" ), - KiBitmap( layers_manager_xpm ) ); + AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, + _( "Show &Layers Manager" ), _( "Show or hide the layer manager" ), + KiBitmap( layers_manager_xpm ), wxITEM_CHECK ); + + viewMenu->AppendSeparator(); + + /* Important Note for ZOOM IN and ZOOM OUT commands from menubar: + * we cannot add hotkey info here, because the hotkey HK_ZOOM_IN and HK_ZOOM_OUT + * events(default = WXK_F1 and WXK_F2) are *NOT* equivalent to this menu command: + * zoom in and out from hotkeys are equivalent to the pop up menu zoom + * From here, zooming is made around the screen center + * From hotkeys, zooming is made around the mouse cursor position + * (obviously not possible from the toolbar or menubar command) + * + * in other words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerators + * for Zoom in and Zoom out sub menus + */ + text = AddHotkeyName( _( "Zoom &In" ), GerbviewHokeysDescr, + HK_ZOOM_IN, IS_ACCELERATOR ); + AddMenuItem( viewMenu, ID_ZOOM_IN, text, _( "Zoom in" ), KiBitmap( zoom_in_xpm ) ); + + text = AddHotkeyName( _( "Zoom &Out" ), GerbviewHokeysDescr, + HK_ZOOM_OUT, IS_ACCELERATOR ); + AddMenuItem( viewMenu, ID_ZOOM_OUT, text, _( "Zoom out" ), KiBitmap( zoom_out_xpm ) ); + + text = AddHotkeyName( _( "&Fit" ), GerbviewHokeysDescr, HK_ZOOM_AUTO ); + AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, _( "Zoom to fit" ), + KiBitmap( zoom_fit_in_page_xpm ) ); + + text = AddHotkeyName( _( "&Redraw" ), GerbviewHokeysDescr, HK_ZOOM_REDRAW ); + AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text, + _( "Refresh screen" ), KiBitmap( zoom_redraw_xpm ) ); + + viewMenu->AppendSeparator(); + + AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_GRID, + _( "Show &Grid" ), wxEmptyString, + KiBitmap( grid_xpm ), wxITEM_CHECK ); + + AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_POLAR_COORD, + _( "Display &Polar Coordinates" ), wxEmptyString, + KiBitmap( polar_coord_xpm ), wxITEM_CHECK ); + + // Units submenu + wxMenu* unitsSubMenu = new wxMenu; + AddMenuItem( unitsSubMenu, ID_TB_OPTIONS_SELECT_UNIT_INCH, + _( "&Imperial" ), _( "Use imperial units" ), + KiBitmap( unit_inch_xpm ), wxITEM_RADIO ); + + AddMenuItem( unitsSubMenu, ID_TB_OPTIONS_SELECT_UNIT_MM, + _( "&Metric" ), _( "Use metric units" ), + KiBitmap( unit_mm_xpm ), wxITEM_RADIO ); + + AddMenuItem( viewMenu, unitsSubMenu, + -1, _( "&Units" ), + _( "Select which units are displayed" ), + KiBitmap( unit_mm_xpm ) ); + + viewMenu->AppendSeparator(); + + AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, + _( "Sketch F&lashed Items" ),_( "Show flashed items in outline mode" ), + KiBitmap( pad_sketch_xpm ), wxITEM_CHECK ); + + AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_LINES_SKETCH, + _( "Sketch &Lines" ),_( "Show lines in outline mode" ), + KiBitmap( showtrack_xpm ), wxITEM_CHECK ); + + AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, + _( "Sketch Pol&ygons" ),_( "Show polygons in outline mode" ), + KiBitmap( opt_show_polygon_xpm ), wxITEM_CHECK ); + + AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_DCODES, + _( "Show &DCodes" ), _( "Show or hide DCodes" ), + KiBitmap( show_dcodenumber_xpm ), wxITEM_CHECK ); + + AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_NEGATIVE_ITEMS, + _( "Show &Negative Objects" ), _( "Show negative objects in ghost color" ), + KiBitmap( gerbview_show_negative_objects_xpm ), wxITEM_CHECK ); + + if( IsGalCanvasActive() ) + { + AddMenuItem( viewMenu, ID_TB_OPTIONS_DIFF_MODE, + _( "Show in Differential Mode" ), _( "Show layers in differential mode" ), + KiBitmap( gbr_select_mode2_xpm ), wxITEM_CHECK ); + + AddMenuItem( viewMenu, ID_TB_OPTIONS_HIGH_CONTRAST_MODE, + _( "Show in High Contrast" ), _( "Show in high contrast mode" ), + KiBitmap( contrast_mode_xpm ), wxITEM_CHECK ); + } + else + { + AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_GBR_MODE_0, + _( "Show Normal Mode" ), _( "Show layers in normal mode" ), + KiBitmap( gbr_select_mode0_xpm ), wxITEM_RADIO ); + AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_GBR_MODE_1, + _( "Show Stacked Mode" ), _( "Show layers in stacked mode" ), + KiBitmap( gbr_select_mode1_xpm ), wxITEM_RADIO ); + AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_GBR_MODE_2, + _( "Show Transparency Mode" ), _( "Show layers in transparency mode" ), + KiBitmap( gbr_select_mode2_xpm ), wxITEM_RADIO ); + } + + // Menu for configuration and preferences + wxMenu* configMenu = new wxMenu; // Options (Preferences on WXMAC) #ifdef __WXMAC__ @@ -293,6 +393,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar() // Append menus to the menubar menuBar->Append( fileMenu, _( "&File" ) ); + menuBar->Append( viewMenu, _( "&View" ) ); menuBar->Append( configMenu, _( "&Preferences" ) ); menuBar->Append( miscellaneousMenu, _( "&Miscellaneous" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 7a1bbea57c..2c774baad3 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2013 Wayne Stambaugh + * Copyright (C) 2013 Wayne Stambaugh * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it @@ -81,17 +81,18 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void ) msg = AddHotkeyName( _( "Zoom out" ), GerbviewHokeysDescr, HK_ZOOM_OUT, IS_COMMENT ); m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiScaledBitmap( zoom_out_xpm, this ), msg ); - msg = AddHotkeyName( _( "Zoom auto" ), GerbviewHokeysDescr, HK_ZOOM_AUTO, IS_COMMENT ); - m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg ); + msg = AddHotkeyName( _( "Zoom to fit" ), GerbviewHokeysDescr, HK_ZOOM_AUTO, IS_COMMENT ); + m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, + KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg ); m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiScaledBitmap( zoom_area_xpm, this ), - _( "Zoom to selection" ), wxITEM_CHECK ); + _( "Zoom to selection" ), wxITEM_CHECK ); KiScaledSeparator( m_mainToolBar, this ); m_SelLayerBox = new GBR_LAYER_BOX_SELECTOR( m_mainToolBar, - ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, - wxDefaultPosition, wxDefaultSize, 0,NULL); + ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, + wxDefaultPosition, wxDefaultSize, 0, NULL ); m_SelLayerBox->Resync(); m_mainToolBar->AddControl( m_SelLayerBox ); @@ -111,7 +112,8 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar() wxStaticText* text; if( !m_auxiliaryToolBar ) - m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize, + m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, + wxDefaultSize, KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT ); // Creates box to display and choose components: @@ -120,7 +122,7 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar() m_SelComponentBox = new wxChoice( m_auxiliaryToolBar, ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE ); m_SelComponentBox->SetToolTip( _("Select a component and highlight items belonging to this component") ); - text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("Cmp:") ); + text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Cmp: ") ); m_auxiliaryToolBar->AddControl( text ); m_auxiliaryToolBar->AddControl( m_SelComponentBox ); KiScaledSeparator( m_auxiliaryToolBar, this ); @@ -132,7 +134,7 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar() m_SelNetnameBox = new wxChoice( m_auxiliaryToolBar, ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE ); m_SelNetnameBox->SetToolTip( _("Select a net name and highlight graphic items belonging to this net") ); - text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("Net:") ); + text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Net:" ) ); m_auxiliaryToolBar->AddControl( text ); m_auxiliaryToolBar->AddControl( m_SelNetnameBox ); KiScaledSeparator( m_auxiliaryToolBar, this ); @@ -142,9 +144,9 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar() if( !m_SelAperAttributesBox ) { m_SelAperAttributesBox = new wxChoice( m_auxiliaryToolBar, - ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE ); + ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE ); m_SelAperAttributesBox->SetToolTip( _("Select an aperture attribute and highlight graphic items having this attribute") ); - text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("Attr:") ); + text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Attr:" ) ); m_auxiliaryToolBar->AddControl( text ); m_auxiliaryToolBar->AddControl( m_SelAperAttributesBox ); KiScaledSeparator( m_auxiliaryToolBar, this ); @@ -155,7 +157,7 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar() m_DCodeSelector = new DCODE_SELECTION_BOX( m_auxiliaryToolBar, ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, wxDefaultPosition, wxSize( 150, -1 ) ); - text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("DCode:") ); + text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "DCode:" ) ); m_auxiliaryToolBar->AddControl( text ); m_auxiliaryToolBar->AddControl( m_DCodeSelector ); } @@ -189,7 +191,8 @@ void GERBVIEW_FRAME::ReCreateVToolbar( void ) KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL ); // Set up toolbar - m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ) ); + m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, + KiScaledBitmap( cursor_xpm, this ) ); KiScaledSeparator( m_mainToolBar, this ); m_drawToolBar->Realize(); @@ -207,7 +210,8 @@ void GERBVIEW_FRAME::ReCreateOptToolbar( void ) // TODO: these can be moved to the 'proper' vertical toolbar if and when there are // actual tools to put there. That, or I'll get around to implementing configurable // toolbars. - m_optionsToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ), + m_optionsToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, + KiScaledBitmap( cursor_xpm, this ), wxEmptyString, wxITEM_CHECK ); if( IsGalCanvasActive() ) @@ -220,7 +224,8 @@ void GERBVIEW_FRAME::ReCreateOptToolbar( void ) KiScaledSeparator( m_mainToolBar, this ); - m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, KiScaledBitmap( grid_xpm, this ), + m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, + KiScaledBitmap( grid_xpm, this ), _( "Turn grid off" ), wxITEM_CHECK ); m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString, @@ -249,15 +254,15 @@ void GERBVIEW_FRAME::ReCreateOptToolbar( void ) KiScaledSeparator( m_mainToolBar, this ); m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, wxEmptyString, KiScaledBitmap( pad_sketch_xpm, this ), - _( "Show spots in sketch mode" ), wxITEM_CHECK ); + _( "Show flashed items in outline mode" ), wxITEM_CHECK ); m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_LINES_SKETCH, wxEmptyString, KiScaledBitmap( showtrack_xpm, this ), - _( "Show lines in sketch mode" ), wxITEM_CHECK ); + _( "Show lines in outline mode" ), wxITEM_CHECK ); m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, wxEmptyString, KiScaledBitmap( opt_show_polygon_xpm, this ), - _( "Show polygons in sketch mode" ), + _( "Show polygons in outline mode" ), wxITEM_CHECK ); m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_NEGATIVE_ITEMS, wxEmptyString, @@ -277,17 +282,17 @@ void GERBVIEW_FRAME::ReCreateOptToolbar( void ) KiScaledBitmap( gbr_select_mode0_xpm, this ), _( "Show layers in raw mode\n" "(could have problems with negative items when more than one gerber file is shown)" ), - wxITEM_CHECK ); + wxITEM_RADIO ); m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GBR_MODE_1, wxEmptyString, KiScaledBitmap( gbr_select_mode1_xpm, this ), _( "Show layers in stacked mode\n" "(show negative items without artifacts)" ), - wxITEM_CHECK ); + wxITEM_RADIO ); m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GBR_MODE_2, wxEmptyString, KiScaledBitmap( gbr_select_mode2_xpm, this ), _( "Show layers in transparency mode\n" "(show negative items without artifacts)" ), - wxITEM_CHECK ); + wxITEM_RADIO ); } else { @@ -375,6 +380,7 @@ void GERBVIEW_FRAME::updateDCodeSelectBox() } } + void GERBVIEW_FRAME::updateComponentListSelectBox() { m_SelComponentBox->Clear(); @@ -479,6 +485,7 @@ void GERBVIEW_FRAME::updateAperAttributesSelectBox() m_SelAperAttributesBox->SetSelection( 0 ); } + void GERBVIEW_FRAME::OnUpdateDrawMode( wxUpdateUIEvent& aEvent ) { switch( aEvent.GetId() ) @@ -501,50 +508,106 @@ void GERBVIEW_FRAME::OnUpdateDrawMode( wxUpdateUIEvent& aEvent ) } +void GERBVIEW_FRAME::OnToggleCoordType( wxCommandEvent& aEvent ) +{ + m_DisplayOptions.m_DisplayPolarCood = !m_DisplayOptions.m_DisplayPolarCood; + + UpdateStatusBar(); +} + + void GERBVIEW_FRAME::OnUpdateCoordType( wxUpdateUIEvent& aEvent ) { aEvent.Check( m_DisplayOptions.m_DisplayPolarCood ); + + if( m_optionsToolBar ) + m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD, + m_DisplayOptions.m_DisplayPolarCood ? + _( "Turn rectangular coordinates on" ) : + _( "Tunn polar coordinates on" ) ); } + void GERBVIEW_FRAME::OnUpdateFlashedItemsDrawMode( wxUpdateUIEvent& aEvent ) { aEvent.Check( !m_DisplayOptions.m_DisplayFlashedItemsFill ); + + if( m_optionsToolBar ) + m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, + m_DisplayOptions.m_DisplayFlashedItemsFill ? + _( "Show flashed items in outline mode" ) : + _( "Show flashed items in fill mode" ) ); } -void GERBVIEW_FRAME::OnUpdateLinesDrawMode( wxUpdateUIEvent& aEvent ) +void GERBVIEW_FRAME::OnUpdateLineDrawMode( wxUpdateUIEvent& aEvent ) { aEvent.Check( !m_DisplayOptions.m_DisplayLinesFill ); + + if( m_optionsToolBar ) + m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_LINES_SKETCH, + m_DisplayOptions.m_DisplayFlashedItemsFill ? + _( "Show lines in outline mode" ) : + _( "Show lines in fill mode" ) ); } -void GERBVIEW_FRAME::OnUpdatePolygonsDrawMode( wxUpdateUIEvent& aEvent ) +void GERBVIEW_FRAME::OnUpdatePolygonDrawMode( wxUpdateUIEvent& aEvent ) { aEvent.Check( !m_DisplayOptions.m_DisplayPolygonsFill ); + + if( m_optionsToolBar ) + m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, + m_DisplayOptions.m_DisplayFlashedItemsFill ? + _( "Show polygons in outline mode" ) : + _( "Show polygons in fill mode" ) ); } void GERBVIEW_FRAME::OnUpdateShowDCodes( wxUpdateUIEvent& aEvent ) { aEvent.Check( IsElementVisible( LAYER_DCODES ) ); + + if( m_optionsToolBar ) + m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_DCODES, + IsElementVisible( LAYER_DCODES ) ? + _( "Hide DCodes" ) : _( "Show DCodes" ) ); } void GERBVIEW_FRAME::OnUpdateShowNegativeItems( wxUpdateUIEvent& aEvent ) { aEvent.Check( IsElementVisible( LAYER_NEGATIVE_OBJECTS ) ); + + if( m_optionsToolBar ) + m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_NEGATIVE_ITEMS, + IsElementVisible( LAYER_NEGATIVE_OBJECTS ) ? + _( "Show negative objects in normal color" ) : + _( "Show negative objects in ghost color" ) ); } void GERBVIEW_FRAME::OnUpdateDiffMode( wxUpdateUIEvent& aEvent ) { aEvent.Check( m_DisplayOptions.m_DiffMode ); + + if( m_optionsToolBar ) + m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_DIFF_MODE, + m_DisplayOptions.m_DiffMode ? + _( "Show layers in normal mode" ) : + _( "Show layers in differential mode" ) ); } void GERBVIEW_FRAME::OnUpdateHighContrastMode( wxUpdateUIEvent& aEvent ) { aEvent.Check( m_DisplayOptions.m_HighContrastMode ); + + if( m_optionsToolBar ) + m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIGH_CONTRAST_MODE, + m_DisplayOptions.m_HighContrastMode ? + _( "Disable high contrast mode" ) : + _( "Enable high contrast mode" ) ); } @@ -555,9 +618,9 @@ void GERBVIEW_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent ) if( m_optionsToolBar ) { if( m_show_layer_manager_tools ) - m_optionsToolBar->SetToolShortHelp( aEvent.GetId(), _("Hide layers manager" ) ); + m_optionsToolBar->SetToolShortHelp( aEvent.GetId(), _( "Hide layers manager" ) ); else - m_optionsToolBar->SetToolShortHelp( aEvent.GetId(), _("Show layers manager" ) ); + m_optionsToolBar->SetToolShortHelp( aEvent.GetId(), _( "Show layers manager" ) ); } }