Pcbnew: fix minor issues about fast grid switching, and next/previous grid selection from hotkeys. (GAL mode still has an issue)

This commit is contained in:
jean-pierre charras 2015-05-12 11:05:36 +02:00
parent b2745c4b00
commit 37b0868376
15 changed files with 149 additions and 63 deletions

View File

@ -48,7 +48,7 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) :
m_NumberOfScreens = 1; // Hierarchy: Root: ScreenNumber = 1 m_NumberOfScreens = 1; // Hierarchy: Root: ScreenNumber = 1
m_Zoom = 32.0; m_Zoom = 32.0;
m_Grid.m_Size = wxRealPoint( 50, 50 ); // Default grid size m_Grid.m_Size = wxRealPoint( 50, 50 ); // Default grid size
m_Grid.m_Id = ID_POPUP_GRID_LEVEL_50; m_Grid.m_CmdId = ID_POPUP_GRID_LEVEL_50;
m_Center = true; m_Center = true;
m_IsPrinting = false; m_IsPrinting = false;
m_ScrollPixelsPerUnitX = 1; m_ScrollPixelsPerUnitX = 1;
@ -183,7 +183,7 @@ int BASE_SCREEN::BuildGridsChoiceList( wxArrayString& aGridsList, bool aMmFirst)
double gridValueMils = To_User_Unit( INCHES, grid.m_Size.x ) * 1000; double gridValueMils = To_User_Unit( INCHES, grid.m_Size.x ) * 1000;
double gridValue_mm = To_User_Unit( MILLIMETRES, grid.m_Size.x ); double gridValue_mm = To_User_Unit( MILLIMETRES, grid.m_Size.x );
if( grid.m_Id == ID_POPUP_GRID_USER ) if( grid.m_CmdId == ID_POPUP_GRID_USER )
{ {
msg = _( "User Grid" ); msg = _( "User Grid" );
idx_usergrid = i; idx_usergrid = i;
@ -232,13 +232,13 @@ int BASE_SCREEN::SetGrid( const wxRealPoint& size )
if( m_grids[i].m_Size == size ) if( m_grids[i].m_Size == size )
{ {
m_Grid = m_grids[i]; m_Grid = m_grids[i];
return m_grids[i].m_Id - ID_POPUP_GRID_LEVEL_1000; return m_grids[i].m_CmdId - ID_POPUP_GRID_LEVEL_1000;
} }
// keep track of the nearest larger grid size, if the exact size is not found // keep track of the nearest larger grid size, if the exact size is not found
if ( size.x < m_grids[i].m_Size.x ) if ( size.x < m_grids[i].m_Size.x )
{ {
gridIdx = m_grids[i].m_Id - ID_POPUP_GRID_LEVEL_1000; gridIdx = m_grids[i].m_CmdId - ID_POPUP_GRID_LEVEL_1000;
nearest_grid = m_grids[i]; nearest_grid = m_grids[i];
} }
} }
@ -259,10 +259,10 @@ int BASE_SCREEN::SetGrid( int aCommandId )
for( unsigned i = 0; i < m_grids.size(); i++ ) for( unsigned i = 0; i < m_grids.size(); i++ )
{ {
if( m_grids[i].m_Id == aCommandId ) if( m_grids[i].m_CmdId == aCommandId )
{ {
m_Grid = m_grids[i]; m_Grid = m_grids[i];
return m_grids[i].m_Id - ID_POPUP_GRID_LEVEL_1000; return m_grids[i].m_CmdId - ID_POPUP_GRID_LEVEL_1000;
} }
} }
@ -272,26 +272,27 @@ int BASE_SCREEN::SetGrid( int aCommandId )
wxT( "grid size( %g, %g )." ), aCommandId, wxT( "grid size( %g, %g )." ), aCommandId,
m_Grid.m_Size.x, m_Grid.m_Size.y ); m_Grid.m_Size.x, m_Grid.m_Size.y );
return m_grids[0].m_Id - ID_POPUP_GRID_LEVEL_1000; return m_grids[0].m_CmdId - ID_POPUP_GRID_LEVEL_1000;
} }
void BASE_SCREEN::AddGrid( const GRID_TYPE& grid ) void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
{ {
for( unsigned i = 0; i < m_grids.size(); i++ ) for( unsigned i = 0; i < m_grids.size(); i++ )
{ {
if( m_grids[i].m_Size == grid.m_Size && grid.m_Id != ID_POPUP_GRID_USER ) if( m_grids[i].m_Size == grid.m_Size && grid.m_CmdId != ID_POPUP_GRID_USER )
{ {
wxLogDebug( wxT( "Discarding duplicate grid size( %g, %g )." ), wxLogDebug( wxT( "Discarding duplicate grid size( %g, %g )." ),
grid.m_Size.x, grid.m_Size.y ); grid.m_Size.x, grid.m_Size.y );
return; return;
} }
if( m_grids[i].m_Id == grid.m_Id ) if( m_grids[i].m_CmdId == grid.m_CmdId )
{ {
wxLogDebug( wxT( "Changing grid ID %d from size( %g, %g ) to " ) \ wxLogDebug( wxT( "Changing grid ID %d from size( %g, %g ) to " ) \
wxT( "size( %g, %g )." ), wxT( "size( %g, %g )." ),
grid.m_Id, m_grids[i].m_Size.x, grid.m_CmdId, m_grids[i].m_Size.x,
m_grids[i].m_Size.y, grid.m_Size.x, grid.m_Size.y ); m_grids[i].m_Size.y, grid.m_Size.x, grid.m_Size.y );
m_grids[i].m_Size = grid.m_Size; m_grids[i].m_Size = grid.m_Size;
return; return;
@ -307,7 +308,7 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id )
GRID_TYPE grid; GRID_TYPE grid;
grid.m_Size = size; grid.m_Size = size;
grid.m_Id = id; grid.m_CmdId = id;
AddGrid( grid ); AddGrid( grid );
} }
@ -319,7 +320,7 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id )
new_size.x = From_User_Unit( aUnit, size.x ); new_size.x = From_User_Unit( aUnit, size.x );
new_size.y = From_User_Unit( aUnit, size.y ); new_size.y = From_User_Unit( aUnit, size.y );
new_grid.m_Id = id; new_grid.m_CmdId = id;
new_grid.m_Size = new_size; new_grid.m_Size = new_size;
AddGrid( new_grid ); AddGrid( new_grid );
@ -335,6 +336,19 @@ GRID_TYPE& BASE_SCREEN::GetGrid( size_t aIndex )
} }
bool BASE_SCREEN::GridExists( int aCommandId )
{
// tests for grid command ID (not an index in grid list, but a wxID) exists in grid list.
for( unsigned i = 0; i < m_grids.size(); i++ )
{
if( m_grids[i].m_CmdId == aCommandId )
return true;
}
return false;
}
wxPoint BASE_SCREEN::getNearestGridPosition( const wxPoint& aPosition, wxPoint BASE_SCREEN::getNearestGridPosition( const wxPoint& aPosition,
const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const
{ {

View File

@ -378,7 +378,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
if( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED ) if( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED )
{ {
if( m_gridSelectBox == NULL ) // Should no happen if( m_gridSelectBox == NULL ) // Should not happen
return; return;
/* /*
@ -404,7 +404,9 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
TOOL_MANAGER* mgr = GetToolManager(); TOOL_MANAGER* mgr = GetToolManager();
if( mgr && IsGalCanvasActive() ) if( mgr && IsGalCanvasActive() )
{
mgr->RunAction( "common.Control.gridPreset", true, idx ); mgr->RunAction( "common.Control.gridPreset", true, idx );
}
else else
SetPresetGrid( idx ); SetPresetGrid( idx );
@ -536,47 +538,58 @@ wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
void EDA_DRAW_FRAME::SetNextGrid() void EDA_DRAW_FRAME::SetNextGrid()
{ {
BASE_SCREEN * screen = GetScreen(); BASE_SCREEN * screen = GetScreen();
int grid_cnt = screen->GetGridCount();
int new_grid_idx = screen->GetGridId() - ID_POPUP_GRID_LEVEL_1000 + 1; int new_grid_cmd = screen->GetGridCmdId();
if( new_grid_idx >= grid_cnt ) // if the grid id is the not the last, increment it
new_grid_idx = 0; if( screen->GridExists( new_grid_cmd + 1 ) )
new_grid_cmd += 1;
SetPresetGrid( new_grid_idx ); SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
} }
void EDA_DRAW_FRAME::SetPrevGrid() void EDA_DRAW_FRAME::SetPrevGrid()
{ {
BASE_SCREEN * screen = GetScreen(); BASE_SCREEN * screen = GetScreen();
int grid_cnt = screen->GetGridCount();
int new_grid_idx = screen->GetGridId() - ID_POPUP_GRID_LEVEL_1000 - 1; int new_grid_cmd = screen->GetGridCmdId();
if( new_grid_idx < 0 ) // if the grid id is the not the first, increment it
new_grid_idx = grid_cnt - 1; if( screen->GridExists( new_grid_cmd - 1 ) )
new_grid_cmd -= 1;
SetPresetGrid( new_grid_idx ); SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
} }
void EDA_DRAW_FRAME::SetPresetGrid( int aIndex ) void EDA_DRAW_FRAME::SetPresetGrid( int aIndex )
{ {
BASE_SCREEN * screen = GetScreen();
if( ! screen->GridExists( aIndex + ID_POPUP_GRID_LEVEL_1000 ) )
aIndex = screen->GetGrids()[0].m_CmdId;
// aIndex is a Command Id relative to ID_POPUP_GRID_LEVEL_1000 comand id code.
// we need an index in grid list (the cmd id in list is is screen->GetGrids()[0].m_CmdId):
int glistIdx = aIndex + ID_POPUP_GRID_LEVEL_1000 - screen->GetGrids()[0].m_CmdId;
if( m_gridSelectBox ) if( m_gridSelectBox )
{ {
if( aIndex < 0 || aIndex >= (int) m_gridSelectBox->GetCount() ) if( glistIdx < 0 || glistIdx >= (int) m_gridSelectBox->GetCount() )
{ {
wxASSERT_MSG( false, "Invalid grid index" ); wxASSERT_MSG( false, "Invalid grid index" );
return; return;
} }
m_gridSelectBox->SetSelection( aIndex ); m_gridSelectBox->SetSelection( glistIdx );
} }
// Be sure m_LastGridSizeId is up to date. // Be sure m_LastGridSizeId is up to date.
m_LastGridSizeId = aIndex; m_LastGridSizeId = aIndex;
GetScreen()->SetGrid( aIndex + ID_POPUP_GRID_LEVEL_1000 ); GetScreen()->SetGrid( aIndex + ID_POPUP_GRID_LEVEL_1000 );
// Put cursor on new grid
SetCrossHairPosition( RefPos( true ) ); SetCrossHairPosition( RefPos( true ) );
} }

View File

@ -289,10 +289,10 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
for( unsigned i = 0; i < gridsList.GetCount(); i++ ) for( unsigned i = 0; i < gridsList.GetCount(); i++ )
{ {
GRID_TYPE& grid = screen->GetGrid( i ); GRID_TYPE& grid = screen->GetGrid( i );
gridMenu->Append( grid.m_Id, gridsList[i], wxEmptyString, true ); gridMenu->Append( grid.m_CmdId, gridsList[i], wxEmptyString, true );
if( (int)i == icurr ) if( (int)i == icurr )
gridMenu->Check( grid.m_Id, true ); gridMenu->Check( grid.m_CmdId, true );
} }
} }

View File

@ -89,12 +89,11 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, CVPCB_MAINFRA
LoadSettings( config() ); LoadSettings( config() );
// Initialize grid id to a default value if not found in config or bad: // Initialize grid id to a default value if not found in config or incorrect:
if( (m_LastGridSizeId <= 0) || if( !( GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) ) )
(m_LastGridSizeId > (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000)) )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000; m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000;
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 );
// Initialize some display options // Initialize some display options
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions();

View File

@ -153,7 +153,7 @@ void DIALOG_EESCHEMA_OPTIONS::SetGridSizes( const GRIDS& aGridSizes, int aGridId
tmp.Printf( wxT( "%0.1f" ), aGridSizes[i].m_Size.x ); tmp.Printf( wxT( "%0.1f" ), aGridSizes[i].m_Size.x );
m_choiceGridSize->Append( tmp ); m_choiceGridSize->Append( tmp );
if( aGridSizes[i].m_Id == aGridId ) if( aGridSizes[i].m_CmdId == aGridId )
select = (int) i; select = (int) i;
} }

View File

@ -56,7 +56,7 @@ void DIALOG_LIBEDIT_OPTIONS::SetGridSizes( const GRIDS& grid_sizes, int grid_id
tmp.Printf( wxT( "%0.1f" ), grid_sizes[i].m_Size.x ); tmp.Printf( wxT( "%0.1f" ), grid_sizes[i].m_Size.x );
m_choiceGridSize->Append( tmp ); m_choiceGridSize->Append( tmp );
if( grid_sizes[i].m_Id == grid_id ) if( grid_sizes[i].m_CmdId == grid_id )
select = (int) i; select = (int) i;
} }

View File

@ -316,7 +316,7 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
units.Add( GetUnitsLabel( MILLIMETRES ) ); units.Add( GetUnitsLabel( MILLIMETRES ) );
dlg.SetUnits( units, g_UserUnit ); dlg.SetUnits( units, g_UserUnit );
dlg.SetGridSizes( grid_list, GetScreen()->GetGridId() ); dlg.SetGridSizes( grid_list, GetScreen()->GetGridCmdId() );
dlg.SetBusWidth( GetDefaultBusThickness() ); dlg.SetBusWidth( GetDefaultBusThickness() );
dlg.SetLineWidth( GetDefaultLineThickness() ); dlg.SetLineWidth( GetDefaultLineThickness() );
dlg.SetTextSize( GetDefaultTextSize() ); dlg.SetTextSize( GetDefaultTextSize() );
@ -784,7 +784,7 @@ void LIB_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
DIALOG_LIBEDIT_OPTIONS dlg( this ); DIALOG_LIBEDIT_OPTIONS dlg( this );
dlg.SetGridSizes( grid_list, GetScreen()->GetGridId() ); dlg.SetGridSizes( grid_list, GetScreen()->GetGridCmdId() );
dlg.SetLineWidth( GetDefaultLineThickness() ); dlg.SetLineWidth( GetDefaultLineThickness() );
dlg.SetPinLength( GetDefaultPinLength() ); dlg.SetPinLength( GetDefaultPinLength() );
dlg.SetPinNumSize( m_textPinNumDefaultSize ); dlg.SetPinNumSize( m_textPinNumDefaultSize );

View File

@ -337,16 +337,14 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
SetIcon( icon ); SetIcon( icon );
// Initialize grid id to the default value (50 mils): // Initialize grid id to the default value (50 mils):
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; const int default_grid = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
m_LastGridSizeId = default_grid;
LoadSettings( config() ); LoadSettings( config() );
// Ensure m_LastGridSizeId is an offset inside the allowed schematic range // Ensure m_LastGridSizeId is an offset inside the allowed schematic grid range
if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000 ) if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; m_LastGridSizeId = default_grid;
if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_1 - ID_POPUP_GRID_LEVEL_1000 )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1 - ID_POPUP_GRID_LEVEL_1000;
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );

View File

@ -1,9 +1,9 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -35,6 +35,7 @@
#include <class_undoredo_container.h> #include <class_undoredo_container.h>
#include <block_commande.h> #include <block_commande.h>
#include <common.h> #include <common.h>
#include <id.h>
/** /**
@ -44,14 +45,14 @@
class GRID_TYPE class GRID_TYPE
{ {
public: public:
int m_Id; int m_CmdId; // The command id of this grid ( first id is ID_POPUP_GRID_LEVEL_1000 )
wxRealPoint m_Size; wxRealPoint m_Size; // the size in internal unit of the grid (can differ for X and Y axis)
GRID_TYPE& operator=( const GRID_TYPE& item ) GRID_TYPE& operator=( const GRID_TYPE& item )
{ {
if( this != &item ) if( this != &item )
{ {
m_Id = item.m_Id; m_CmdId = item.m_CmdId;
m_Size = item.m_Size; m_Size = item.m_Size;
} }
@ -60,7 +61,7 @@ public:
const bool operator==( const GRID_TYPE& item ) const const bool operator==( const GRID_TYPE& item ) const
{ {
return m_Size == item.m_Size && m_Id == item.m_Id; return m_Size == item.m_Size && m_CmdId == item.m_CmdId;
} }
}; };
@ -386,7 +387,7 @@ public:
* *
* @return int - Currently selected grid command ID. * @return int - Currently selected grid command ID.
*/ */
int GetGridId() const { return m_Grid.m_Id; } int GetGridCmdId() const { return m_Grid.m_CmdId; }
/** /**
* Return the grid size of the currently selected grid. * Return the grid size of the currently selected grid.
@ -426,6 +427,14 @@ public:
void AddGrid( const wxRealPoint& size, int id ); void AddGrid( const wxRealPoint& size, int id );
void AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id ); void AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id );
/**
* Function GridExists
* tests for grid command ID (not an index in grid list, but a wxID) exists in grid list.
* @param aCommandId = the wxWidgets command ID
* @return true if the grid exists in grid list.
*/
bool GridExists( int aCommandId );
/** /**
* Function GetGridCount(). * Function GetGridCount().
* Return the size of the grid list. * Return the size of the grid list.

View File

@ -655,6 +655,18 @@ public:
*/ */
void SetFastGrid2(); void SetFastGrid2();
/**
* Virtual function SetNextGrid()
* changes the grid size settings to the next one available.
*/
void SetNextGrid();
/**
* Virtual function SetPrevGrid()
* changes the grid size settings to the previous one available.
*/
void SetPrevGrid();
void ClearSelection(); void ClearSelection();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@ -83,11 +83,10 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
LoadSettings( config() ); LoadSettings( config() );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_1MM-ID_POPUP_GRID_LEVEL_1000 ) if( ! GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1MM - ID_POPUP_GRID_LEVEL_1000; m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1MM - ID_POPUP_GRID_LEVEL_1000;
if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_0_1MM-ID_POPUP_GRID_LEVEL_1000 )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_1MM-ID_POPUP_GRID_LEVEL_1000; GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();

View File

@ -487,7 +487,7 @@ void PCB_BASE_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ ) for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
{ {
if( GetScreen()->GetGridId() == GetScreen()->GetGrid( i ).m_Id ) if( GetScreen()->GetGridCmdId() == GetScreen()->GetGrid( i ).m_CmdId )
{ {
select = (int) i; select = (int) i;
break; break;
@ -815,7 +815,7 @@ void PCB_BASE_FRAME::updateGridSelectBox()
for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ ) for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
{ {
GRID_TYPE& grid = GetScreen()->GetGrid( i ); GRID_TYPE& grid = GetScreen()->GetGrid( i );
m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_Id ); m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId );
} }
m_gridSelectBox->SetSelection( icurr ); m_gridSelectBox->SetSelection( icurr );
@ -850,25 +850,66 @@ void PCB_BASE_FRAME::updateZoomSelectBox()
void PCB_BASE_FRAME::SetFastGrid1() void PCB_BASE_FRAME::SetFastGrid1()
{ {
if( m_FastGrid1 >= GetScreen()->GetGridCount() )
return;
int cmdId = GetScreen()->GetGrids()[m_FastGrid1].m_CmdId;
SetPresetGrid( cmdId - ID_POPUP_GRID_LEVEL_1000 );
if( m_gridSelectBox ) if( m_gridSelectBox )
{ {
m_gridSelectBox->SetSelection( m_FastGrid1 );
wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED ); wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED );
cmd.SetEventObject( this ); cmd.SetEventObject( this );
OnSelectGrid( cmd ); OnSelectGrid( cmd );
} }
else
GetCanvas()->Refresh();
} }
void PCB_BASE_FRAME::SetFastGrid2() void PCB_BASE_FRAME::SetFastGrid2()
{ {
if( m_FastGrid2 >= GetScreen()->GetGridCount() )
return;
int cmdId = GetScreen()->GetGrids()[m_FastGrid2].m_CmdId;
SetPresetGrid( cmdId - ID_POPUP_GRID_LEVEL_1000 );
if( m_gridSelectBox ) if( m_gridSelectBox )
{ {
m_gridSelectBox->SetSelection( m_FastGrid2 );
wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED ); wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED );
cmd.SetEventObject( this ); cmd.SetEventObject( this );
OnSelectGrid( cmd ); OnSelectGrid( cmd );
} }
else
GetCanvas()->Refresh();
}
void PCB_BASE_FRAME::SetNextGrid()
{
EDA_DRAW_FRAME::SetNextGrid();
if( m_gridSelectBox )
{
wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED );
cmd.SetEventObject( this );
OnSelectGrid( cmd );
}
else
GetCanvas()->Refresh();
}
void PCB_BASE_FRAME::SetPrevGrid()
{
EDA_DRAW_FRAME::SetPrevGrid();
if( m_gridSelectBox )
{
wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED );
cmd.SetEventObject( this );
OnSelectGrid( cmd );
}
else
GetCanvas()->Refresh();
} }

View File

@ -226,7 +226,7 @@ bool PCB_BASE_FRAME::InvokeDialogGrid()
// If the user grid is the current option, recall SetGrid() // If the user grid is the current option, recall SetGrid()
// to force new values put in list as current grid value // to force new values put in list as current grid value
if( screen->GetGridId() == ID_POPUP_GRID_USER ) if( screen->GetGridCmdId() == ID_POPUP_GRID_USER )
screen->SetGrid( ID_POPUP_GRID_USER ); screen->SetGrid( ID_POPUP_GRID_USER );
// Notify GAL // Notify GAL

View File

@ -42,6 +42,7 @@
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include <hotkeys.h> #include <hotkeys.h>
#include <class_zone.h> #include <class_zone.h>
#include <tool/tool_manager.h>
/* How to add a new hotkey: /* How to add a new hotkey:
* see hotkeys.cpp * see hotkeys.cpp

View File

@ -44,7 +44,7 @@ GRID_MENU::GRID_MENU( EDA_DRAW_FRAME* aParent ) : m_parent( aParent )
for( unsigned int i = 0; i < gridsList.GetCount(); ++i ) for( unsigned int i = 0; i < gridsList.GetCount(); ++i )
{ {
GRID_TYPE& grid = screen->GetGrid( i ); GRID_TYPE& grid = screen->GetGrid( i );
Append( grid.m_Id, gridsList[i], wxEmptyString, true ); Append( grid.m_CmdId, gridsList[i], wxEmptyString, true );
} }
} }
@ -64,5 +64,5 @@ void GRID_MENU::Update()
for( unsigned int i = 0; i < GetMenuItemCount(); ++i ) for( unsigned int i = 0; i < GetMenuItemCount(); ++i )
Check( ID_POPUP_GRID_SELECT + 1 + i, false ); Check( ID_POPUP_GRID_SELECT + 1 + i, false );
Check( m_parent->GetScreen()->GetGridId(), true ); Check( m_parent->GetScreen()->GetGridCmdId(), true );
} }