Add grid and zone dropdowns to GerbView frame.

(cherry picked from commit be5c1e2)
This commit is contained in:
Jeff Young 2018-07-11 13:56:05 +01:00
parent 5048260749
commit e329a411bf
5 changed files with 137 additions and 7 deletions

View File

@ -141,6 +141,8 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_NET_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, EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE,
GERBVIEW_FRAME::OnSelectHighlightChoice ) GERBVIEW_FRAME::OnSelectHighlightChoice )
EVT_CHOICE( ID_ON_ZOOM_SELECT, GERBVIEW_FRAME::OnSelectZoom )
EVT_CHOICE( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnSelectGrid )
// Right click context menu // Right click context menu
EVT_MENU( ID_HIGHLIGHT_CMP_ITEMS, GERBVIEW_FRAME::Process_Special_Functions ) EVT_MENU( ID_HIGHLIGHT_CMP_ITEMS, GERBVIEW_FRAME::Process_Special_Functions )
@ -162,6 +164,8 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
GERBVIEW_FRAME::OnUpdateShowLayerManager ) GERBVIEW_FRAME::OnUpdateShowLayerManager )
EVT_UPDATE_UI( ID_TB_OPTIONS_DIFF_MODE, GERBVIEW_FRAME::OnUpdateDiffMode ) EVT_UPDATE_UI( ID_TB_OPTIONS_DIFF_MODE, GERBVIEW_FRAME::OnUpdateDiffMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_HIGH_CONTRAST_MODE, GERBVIEW_FRAME::OnUpdateHighContrastMode ) EVT_UPDATE_UI( ID_TB_OPTIONS_HIGH_CONTRAST_MODE, GERBVIEW_FRAME::OnUpdateHighContrastMode )
EVT_UPDATE_UI( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnUpdateSelectGrid )
EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, GERBVIEW_FRAME::OnUpdateSelectZoom )
EVT_UPDATE_UI( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnUpdateSelectDCode ) EVT_UPDATE_UI( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnUpdateSelectDCode )
EVT_UPDATE_UI( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, EVT_UPDATE_UI( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,

View File

@ -1202,6 +1202,7 @@ void GERBVIEW_FRAME::unitsChangeRefresh()
{ // Called on units change (see EDA_DRAW_FRAME) { // Called on units change (see EDA_DRAW_FRAME)
EDA_DRAW_FRAME::unitsChangeRefresh(); EDA_DRAW_FRAME::unitsChangeRefresh();
updateDCodeSelectBox(); updateDCodeSelectBox();
updateGridSelectBox();
} }
@ -1270,6 +1271,103 @@ void GERBVIEW_FRAME::setupTools()
} }
void GERBVIEW_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->SetSelection( icurr );
}
void GERBVIEW_FRAME::updateZoomSelectBox()
{
if( m_zoomSelectBox == NULL )
return;
wxString msg;
m_zoomSelectBox->Clear();
m_zoomSelectBox->Append( _( "Zoom Auto" ) );
m_zoomSelectBox->SetSelection( 0 );
for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); ++i )
{
msg = _( "Zoom " );
double level = m_zoomLevelCoeff / (double)GetScreen()->m_ZoomList[i];
wxString value = wxString::Format( wxT( "%.2f" ), level );
msg += value;
m_zoomSelectBox->Append( msg );
if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
m_zoomSelectBox->SetSelection( i + 1 );
}
}
void GERBVIEW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
{
// No need to update the grid select box if it doesn't exist or the grid setting change
// was made using the select box.
if( m_gridSelectBox == NULL || m_auxiliaryToolBar == NULL )
return;
int select = wxNOT_FOUND;
for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
{
if( GetScreen()->GetGridCmdId() == GetScreen()->GetGrid( i ).m_CmdId )
{
select = (int) i;
break;
}
}
if( select != m_gridSelectBox->GetSelection() )
m_gridSelectBox->SetSelection( select );
}
void GERBVIEW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
{
if( m_zoomSelectBox == NULL || m_auxiliaryToolBar == NULL )
return;
int current = 0; // display Auto if no match found
// check for a match within 1%
double zoom = IsGalCanvasActive() ? GetGalCanvas()->GetLegacyZoom() : GetScreen()->GetZoom();
for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
{
if( std::fabs( zoom - GetScreen()->m_ZoomList[i] ) < ( zoom / 100.0 ) )
{
current = i + 1;
break;
}
}
if( current != m_zoomSelectBox->GetSelection() )
m_zoomSelectBox->SetSelection( current );
}
void GERBVIEW_FRAME::CommonSettingsChanged() void GERBVIEW_FRAME::CommonSettingsChanged()
{ {
EDA_DRAW_FRAME::CommonSettingsChanged(); EDA_DRAW_FRAME::CommonSettingsChanged();

View File

@ -200,6 +200,8 @@ private:
void updateNetnameListSelectBox(); void updateNetnameListSelectBox();
void updateAperAttributesSelectBox(); void updateAperAttributesSelectBox();
void updateDCodeSelectBox(); void updateDCodeSelectBox();
void updateGridSelectBox();
void updateZoomSelectBox();
void unitsChangeRefresh() override; // See class EDA_DRAW_FRAME void unitsChangeRefresh() override; // See class EDA_DRAW_FRAME
// The Tool Framework initalization // The Tool Framework initalization
@ -247,6 +249,8 @@ public:
void OnLeftDClick( wxDC* aDC, const wxPoint& aMousePos ) override; void OnLeftDClick( wxDC* aDC, const wxPoint& aMousePos ) override;
bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) override; bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) override;
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent ); void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent );
void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent );
double BestZoom() override; double BestZoom() override;
void UpdateStatusBar() override; void UpdateStatusBar() override;

View File

@ -117,11 +117,11 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
{ {
m_SelComponentBox = new wxChoice( m_auxiliaryToolBar, m_SelComponentBox = new wxChoice( m_auxiliaryToolBar,
ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE ); ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE );
m_SelComponentBox->SetToolTip( _("Select a component and highlight items belonging to this component") ); m_SelComponentBox->SetToolTip( _("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( text );
m_auxiliaryToolBar->AddControl( m_SelComponentBox ); m_auxiliaryToolBar->AddControl( m_SelComponentBox );
KiScaledSeparator( m_auxiliaryToolBar, this ); m_auxiliaryToolBar->AddSpacer( 5 );
} }
// Creates choice box to display net names and highlight selected: // Creates choice box to display net names and highlight selected:
@ -129,11 +129,11 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
{ {
m_SelNetnameBox = new wxChoice( m_auxiliaryToolBar, m_SelNetnameBox = new wxChoice( m_auxiliaryToolBar,
ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE ); ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE );
m_SelNetnameBox->SetToolTip( _("Select a net name and highlight graphic items belonging to this net") ); m_SelNetnameBox->SetToolTip( _("Highlight 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( text );
m_auxiliaryToolBar->AddControl( m_SelNetnameBox ); m_auxiliaryToolBar->AddControl( m_SelNetnameBox );
KiScaledSeparator( m_auxiliaryToolBar, this ); m_auxiliaryToolBar->AddSpacer( 5 );
} }
// Creates choice box to display aperture attributes and highlight selected: // Creates choice box to display aperture attributes and highlight selected:
@ -141,11 +141,11 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
{ {
m_SelAperAttributesBox = new wxChoice( m_auxiliaryToolBar, 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") ); m_SelAperAttributesBox->SetToolTip( _("Highlight items with this aperture attribute") );
text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Attr:" ) ); text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Attr:" ) );
m_auxiliaryToolBar->AddControl( text ); m_auxiliaryToolBar->AddControl( text );
m_auxiliaryToolBar->AddControl( m_SelAperAttributesBox ); m_auxiliaryToolBar->AddControl( m_SelAperAttributesBox );
KiScaledSeparator( m_auxiliaryToolBar, this ); m_auxiliaryToolBar->AddSpacer( 5 );
} }
if( !m_DCodeSelector ) if( !m_DCodeSelector )
@ -158,10 +158,28 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
m_auxiliaryToolBar->AddControl( m_DCodeSelector ); m_auxiliaryToolBar->AddControl( m_DCodeSelector );
} }
if( !m_gridSelectBox )
{
KiScaledSeparator( m_auxiliaryToolBar, this );
m_gridSelectBox = new wxChoice( m_auxiliaryToolBar, ID_ON_GRID_SELECT,
wxDefaultPosition, wxDefaultSize, 0, nullptr );
m_auxiliaryToolBar->AddControl( m_gridSelectBox );
}
if( !m_zoomSelectBox )
{
KiScaledSeparator( m_auxiliaryToolBar, this );
m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar, ID_ON_ZOOM_SELECT,
wxDefaultPosition, wxDefaultSize, 0, nullptr );
m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
}
updateComponentListSelectBox(); updateComponentListSelectBox();
updateNetnameListSelectBox(); updateNetnameListSelectBox();
updateAperAttributesSelectBox(); updateAperAttributesSelectBox();
updateDCodeSelectBox(); updateDCodeSelectBox();
updateGridSelectBox();
updateZoomSelectBox();
// combobox sizes can have changed: apply new best sizes // combobox sizes can have changed: apply new best sizes
auto item = m_auxiliaryToolBar->FindTool( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE ); auto item = m_auxiliaryToolBar->FindTool( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE );
@ -173,6 +191,12 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
item = m_auxiliaryToolBar->FindTool( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE ); item = m_auxiliaryToolBar->FindTool( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE );
item->SetMinSize( m_SelAperAttributesBox->GetBestSize() ); item->SetMinSize( m_SelAperAttributesBox->GetBestSize() );
item = m_auxiliaryToolBar->FindTool( ID_ON_GRID_SELECT );
item->SetMinSize( m_gridSelectBox->GetBestSize() );
item = m_auxiliaryToolBar->FindTool( ID_ON_ZOOM_SELECT );
item->SetMinSize( m_zoomSelectBox->GetBestSize() );
// after adding the buttons to the toolbar, must call Realize() // after adding the buttons to the toolbar, must call Realize()
m_auxiliaryToolBar->Realize(); m_auxiliaryToolBar->Realize();
} }

View File

@ -130,7 +130,7 @@ protected:
long m_firstRunDialogSetting; long m_firstRunDialogSetting;
/// Choice box to choose the grid size. /// Choice box to choose the grid size.
wxChoice* m_gridSelectBox; wxChoice* m_gridSelectBox;
/// Choice box to choose the zoom value. /// Choice box to choose the zoom value.
wxChoice* m_zoomSelectBox; wxChoice* m_zoomSelectBox;