Commit 1d3f2d52 authored by charras's avatar charras

Pcbnew : refinements for user grig

parent aee56a93
...@@ -12,8 +12,7 @@ email address. ...@@ -12,8 +12,7 @@ email address.
This is mandatory in Pcbnew to handle metric user grids without error This is mandatory in Pcbnew to handle metric user grids without error
(was unusable before, using integer grid size). (was unusable before, using integer grid size).
A lot of footprints uses not metric grid. A lot of footprints uses not metric grid.
TODO: refinements for user grid (mainly in read/write config).
more refinements for user grid (mainly in read/wrire config).
2009-Feb-06 UPDATE Dick Hollenbeck <dick@softplc.com> 2009-Feb-06 UPDATE Dick Hollenbeck <dick@softplc.com>
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base_struct.h" #include "base_struct.h"
#include "sch_item_struct.h" #include "sch_item_struct.h"
#include "class_base_screen.h" #include "class_base_screen.h"
#include "id.h"
/* Implement wxSize array for grid list implementation. */ /* Implement wxSize array for grid list implementation. */
#include <wx/arrimpl.cpp> #include <wx/arrimpl.cpp>
...@@ -356,7 +357,7 @@ void BASE_SCREEN::SetGrid( int id ) ...@@ -356,7 +357,7 @@ void BASE_SCREEN::SetGrid( int id )
m_Grid = m_GridList[0].m_Size; m_Grid = m_GridList[0].m_Size;
wxLogWarning( _( "Grid ID %d not in grid list, falling back to " \ wxLogWarning( _( "Grid ID %d not in grid list, falling back to " \
"grid size( %f, %f )." ), id, m_Grid.x, m_Grid.y ); "grid size( %g, %g )." ), id, m_Grid.x, m_Grid.y );
} }
void BASE_SCREEN::AddGrid( const GRID_TYPE& grid ) void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
...@@ -365,16 +366,17 @@ void BASE_SCREEN::AddGrid( const GRID_TYPE& grid ) ...@@ -365,16 +366,17 @@ void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
for( i = 0; i < m_GridList.GetCount(); i++ ) for( i = 0; i < m_GridList.GetCount(); i++ )
{ {
if( m_GridList[i].m_Size == grid.m_Size ) if( m_GridList[i].m_Size == grid.m_Size &&
grid.m_Id != ID_POPUP_GRID_USER)
{ {
wxLogDebug( wxT( "Discarding duplicate grid size( %d, %d )." ), 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_GridList[i].m_Id == grid.m_Id ) if( m_GridList[i].m_Id == grid.m_Id )
{ {
wxLogDebug( wxT( "Changing grid ID %d from size( %d, %d ) to " \ wxLogDebug( wxT( "Changing grid ID %d from size( %g, %g ) to " \
"size( %d, %d )." ), "size( %g, %g )." ),
grid.m_Id, m_GridList[i].m_Size.x, grid.m_Id, m_GridList[i].m_Size.x,
m_GridList[i].m_Size.y, grid.m_Size.x, grid.m_Size.y ); m_GridList[i].m_Size.y, grid.m_Size.x, grid.m_Size.y );
m_GridList[i].m_Size = grid.m_Size; m_GridList[i].m_Size = grid.m_Size;
...@@ -418,8 +420,8 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id ) ...@@ -418,8 +420,8 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id )
y = size.y; y = size.y;
} }
new_size = wxRealPoint( x * (double) GetInternalUnits(), new_size.x = x * GetInternalUnits();
y * (double) GetInternalUnits() ); new_size.y = y * GetInternalUnits();
new_grid.m_Id = id; new_grid.m_Id = id;
new_grid.m_Size = new_size; new_grid.m_Size = new_size;
......
...@@ -362,38 +362,6 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -362,38 +362,6 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
continue; continue;
} }
if( stricmp( Line, "UserGridSize" ) == 0 )
{
wxString msg;
if( data )
{
msg = CONV_FROM_UTF8( data );
msg.ToDouble( &g_UserGrid.x );
}
else
continue;
data = strtok( NULL, " =\n\r" );
if( data )
{
msg = CONV_FROM_UTF8( data );
msg.ToDouble( &g_UserGrid.y );
}
else
g_UserGrid.y = g_UserGrid.x;
data = strtok( NULL, " =\n\r" );
if( data )
{
if( stricmp( data, "mm" ) == 0 )
g_UserGrid_Unit = MILLIMETRE;
else
g_UserGrid_Unit = INCHES;
GetScreen()->AddGrid( g_UserGrid, g_UserGrid_Unit,
ID_POPUP_GRID_USER );
}
continue;
}
if( stricmp( Line, "DrawSegmWidth" ) == 0 ) if( stricmp( Line, "DrawSegmWidth" ) == 0 )
{ {
...@@ -512,10 +480,6 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard ) ...@@ -512,10 +480,6 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT ); sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
fprintf( aFile, text ); fprintf( aFile, text );
sprintf( text, "UserGridSize %lf %lf %s\n", g_UserGrid.x, g_UserGrid.y,
( g_UserGrid_Unit == 0 ) ? "INCH" : "mm" );
fprintf( aFile, text );
fprintf( aFile, "ZoneGridSize %d\n", g_GridRoutingSize ); fprintf( aFile, "ZoneGridSize %d\n", g_GridRoutingSize );
fprintf( aFile, "Layers %d\n", aBoard->GetCopperLayerCount() ); fprintf( aFile, "Layers %d\n", aBoard->GetCopperLayerCount() );
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include "3d_viewer.h" #include "3d_viewer.h"
// Keys used in read/write config // Keys used in read/write config
#define MODEDIT_CURR_GRID_X wxT( "ModEditCurrGrid_X" ) #define MODEDIT_CURR_GRID wxT( "ModEditCurrGrid" )
#define MODEDIT_CURR_GRID_Y wxT( "ModEditCurrGrid_Y" )
/********************************/ /********************************/
/* class WinEDA_ModuleEditFrame */ /* class WinEDA_ModuleEditFrame */
...@@ -188,23 +187,8 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, ...@@ -188,23 +187,8 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
GetSettings(); GetSettings();
wxRealPoint GridSize( 500, 500 );
if( config )
{
double SizeX, SizeY;
if( config->Read( MODEDIT_CURR_GRID_X, &SizeX )
&& config->Read( MODEDIT_CURR_GRID_Y, &SizeY ) )
{
GridSize.x = SizeX;
GridSize.y = SizeY;
}
}
GetScreen()->AddGrid( g_UserGrid, g_UserGrid_Unit, ID_POPUP_GRID_USER ); GetScreen()->AddGrid( g_UserGrid, g_UserGrid_Unit, ID_POPUP_GRID_USER );
GetScreen()->SetGrid( GridSize );
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 );
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
...@@ -212,6 +196,13 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, ...@@ -212,6 +196,13 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
ReCreateVToolbar(); ReCreateVToolbar();
ReCreateOptToolbar(); ReCreateOptToolbar();
if( config )
{
long gridselection = 1;
config->Read( MODEDIT_CURR_GRID, &gridselection );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + gridselection );
}
if( DrawPanel ) if( DrawPanel )
DrawPanel->m_Block_Enable = TRUE; DrawPanel->m_Block_Enable = TRUE;
} }
...@@ -244,9 +235,7 @@ void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -244,9 +235,7 @@ void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event )
SaveSettings(); SaveSettings();
if( config ) if( config )
{ {
wxRealPoint GridSize = GetScreen()->GetGrid(); config->Write( MODEDIT_CURR_GRID, m_SelGridBox->GetSelection() );
config->Write( MODEDIT_CURR_GRID_X, GridSize.x );
config->Write( MODEDIT_CURR_GRID_Y, GridSize.y );
} }
Destroy(); Destroy();
} }
......
...@@ -719,31 +719,6 @@ static PARAM_CFG_INT WTraitSerigraphiePlotCfg ...@@ -719,31 +719,6 @@ static PARAM_CFG_INT WTraitSerigraphiePlotCfg
1, 10000 /* Min and max values*/ 1, 10000 /* Min and max values*/
); );
static PARAM_CFG_DOUBLE UserGrilleXCfg
(
wxT( "UserGrX" ), /* Keyword */
&g_UserGrid.x, /* Parameter address */
0.01, /* Default value */
0.0001, 100.0 /* Min and max values(inches)*/
);
static PARAM_CFG_DOUBLE UserGrilleYCfg
(
wxT( "UserGrY" ), /* Keyword */
&g_UserGrid.y, /* Parameter address */
0.01, /* Default value */
0.0001, 100.0 /* Min and max values (inches)*/
);
static PARAM_CFG_INT UserGrilleUnitCfg
(
wxT( "UserGrU" ), /* Keyword */
&g_UserGrid_Unit, /* Parameter address */
1, /* Default value */
0, 1 /* Min and max values*/
);
static PARAM_CFG_INT TimeOutCfg //Duree entre Sauvegardes auto en secondes static PARAM_CFG_INT TimeOutCfg //Duree entre Sauvegardes auto en secondes
( (
INSETUP, INSETUP,
...@@ -803,6 +778,9 @@ static PARAM_CFG_BOOL TwoSegmentTrackBuildCfg ...@@ -803,6 +778,9 @@ static PARAM_CFG_BOOL TwoSegmentTrackBuildCfg
TRUE /* Default value */ TRUE /* Default value */
); );
/* parameters in this list will be saved on request (when saving config).
*/
PARAM_CFG_BASE* ParamCfgList[] = PARAM_CFG_BASE* ParamCfgList[] =
{ {
&UserLibDirBufCfg, &UserLibDirBufCfg,
...@@ -893,9 +871,6 @@ PARAM_CFG_BASE* ParamCfgList[] = ...@@ -893,9 +871,6 @@ PARAM_CFG_BASE* ParamCfgList[] =
&TexteSegmLargeurCfg, &TexteSegmLargeurCfg,
&ModuleSegmWidthCfg, &ModuleSegmWidthCfg,
&WTraitSerigraphiePlotCfg, &WTraitSerigraphiePlotCfg,
&UserGrilleXCfg,
&UserGrilleYCfg,
&UserGrilleUnitCfg,
&TimeOutCfg, &TimeOutCfg,
&DisplPolairCfg, &DisplPolairCfg,
&CursorShapeCfg, &CursorShapeCfg,
......
...@@ -17,12 +17,15 @@ ...@@ -17,12 +17,15 @@
#include "kbool/include/kbool/booleng.h" #include "kbool/include/kbool/booleng.h"
// Keys used in read/write config // Keys used in read/write config
#define PCB_CURR_GRID_X wxT( "PcbCurrGrid_X" ) #define PCB_CURR_GRID wxT( "PcbCurrGrid" )
#define PCB_CURR_GRID_Y wxT( "PcbCurrGrid_Y" )
#define PCB_MAGNETIC_PADS_OPT wxT( "PcbMagPadOpt" ) #define PCB_MAGNETIC_PADS_OPT wxT( "PcbMagPadOpt" )
#define PCB_MAGNETIC_TRACKS_OPT wxT( "PcbMagTrackOpt" ) #define PCB_MAGNETIC_TRACKS_OPT wxT( "PcbMagTrackOpt" )
#define SHOW_MICROWAVE_TOOLS wxT( "ShowMicrowaveTools" ) #define SHOW_MICROWAVE_TOOLS wxT( "ShowMicrowaveTools" )
#define PCB_USER_GRID_X wxT( "PcbUserGrid_X" )
#define PCB_USER_GRID_Y wxT( "PcbUserGrid_Y" )
#define PCB_USER_GRID_UNIT wxT( "PcbUserGrid_Unit" )
/*******************************/ /*******************************/
/* class WinEDA_PcbFrame */ /* class WinEDA_PcbFrame */
/*******************************/ /*******************************/
...@@ -238,21 +241,30 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, ...@@ -238,21 +241,30 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
GetSettings(); GetSettings();
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 );
wxRealPoint GridSize( 500, 500 ); // Read some parameters from config
g_UserGrid.x = g_UserGrid.y = 0.5; // Default user grid size
g_UserGrid_Unit = 1; // Default user grid unit (0 = inch, 1 = mm)
wxRealPoint GridSize( 500, 500 ); // Default current grid size
if( config ) if( config )
{ {
double SizeX, SizeY; double SizeX, SizeY;
if( config->Read( PCB_CURR_GRID_X, &SizeX ) if( config->Read( PCB_USER_GRID_X, &SizeX )
&& config->Read( PCB_CURR_GRID_Y, &SizeY ) ) && config->Read( PCB_USER_GRID_Y, &SizeY ) )
{ {
GridSize.x = SizeX; g_UserGrid.x = SizeX;
GridSize.y = SizeY; g_UserGrid.y = SizeY;
} }
config->Read( PCB_USER_GRID_UNIT, &g_UserGrid_Unit );
config->Read( PCB_MAGNETIC_PADS_OPT, &g_MagneticPadOption ); config->Read( PCB_MAGNETIC_PADS_OPT, &g_MagneticPadOption );
config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption ); config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption );
} }
GetScreen()->AddGrid( g_UserGrid, g_UserGrid_Unit, ID_POPUP_GRID_USER );
GetScreen()->SetGrid( GridSize ); GetScreen()->SetGrid( GridSize );
if( DrawPanel ) if( DrawPanel )
...@@ -263,6 +275,9 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, ...@@ -263,6 +275,9 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
ReCreateVToolbar(); ReCreateVToolbar();
if( config ) if( config )
{ {
long gridselection = 1;
config->Read( PCB_CURR_GRID, &gridselection );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + gridselection );
long display_microwave_tools = 0; long display_microwave_tools = 0;
config->Read( SHOW_MICROWAVE_TOOLS, &display_microwave_tools ); config->Read( SHOW_MICROWAVE_TOOLS, &display_microwave_tools );
if ( display_microwave_tools ) if ( display_microwave_tools )
...@@ -328,7 +343,7 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -328,7 +343,7 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
} }
} }
while( screen ) // suppression flag modify pour eviter d'autres message while( screen ) // Remove modify flag, to avoi others messages
{ {
screen->ClrModify(); screen->ClrModify();
screen = screen->Next(); screen = screen->Next();
...@@ -342,8 +357,11 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -342,8 +357,11 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
if( config ) if( config )
{ {
wxRealPoint GridSize = GetScreen()->GetGrid(); wxRealPoint GridSize = GetScreen()->GetGrid();
config->Write( PCB_CURR_GRID_X, GridSize.x );
config->Write( PCB_CURR_GRID_Y, GridSize.y ); config->Write( PCB_USER_GRID_X, g_UserGrid.x );
config->Write( PCB_USER_GRID_Y, g_UserGrid.y );
config->Write( PCB_USER_GRID_UNIT, g_UserGrid_Unit );
config->Write( PCB_CURR_GRID, m_SelGridBox->GetSelection() );
config->Write( PCB_MAGNETIC_PADS_OPT, (long) g_MagneticPadOption ); config->Write( PCB_MAGNETIC_PADS_OPT, (long) g_MagneticPadOption );
config->Write( PCB_MAGNETIC_TRACKS_OPT, (long) g_MagneticTrackOption ); config->Write( PCB_MAGNETIC_TRACKS_OPT, (long) g_MagneticTrackOption );
config->Write( SHOW_MICROWAVE_TOOLS, (long) m_AuxVToolBar ? 1 : 0 ); config->Write( SHOW_MICROWAVE_TOOLS, (long) m_AuxVToolBar ? 1 : 0 );
......
...@@ -631,10 +631,7 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar() ...@@ -631,10 +631,7 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
msg.Printf( format.GetData(), value ); msg.Printf( format.GetData(), value );
} }
else else
{
msg = _( "User Grid" ); msg = _( "User Grid" );
}
m_SelGridBox->Append( msg ); m_SelGridBox->Append( msg );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment