Commit 92064f1d authored by stambaughw's avatar stambaughw

Fix save last grid size and other minor updates.

* Create single event handler for grid size events.
* Fix all frame windows to use new grid size event handler.
* Use offset relative to ID instead of ComboBox index to save last grid size.
* Move last grid size load/save setting into WinEDA_DrawFrame.
* Add equality and assignment operators the GRID_TYPE.
* Add current grid helper methods to BASE_SCREEN.
* Add GetPins helper to LIB_COMPONENT to replace GetNextPin where applicable.
* Add AppendMsgPanel helper to WinEDA_DrawFrame.
* Improve rounding for display of coordinates when millimeter units are selected.
parent 9250eb4e
...@@ -34,7 +34,8 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType ) ...@@ -34,7 +34,8 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType )
m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */ m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */
m_ZoomScalar = 10; m_ZoomScalar = 10;
m_Zoom = 32 * m_ZoomScalar; m_Zoom = 32 * m_ZoomScalar;
m_Grid = 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_UserGridIsON = FALSE; m_UserGridIsON = FALSE;
m_Center = true; m_Center = true;
m_CurrentSheetDesc = &g_Sheet_A4; m_CurrentSheetDesc = &g_Sheet_A4;
...@@ -357,25 +358,26 @@ void BASE_SCREEN::SetGrid( const wxRealPoint& size ) ...@@ -357,25 +358,26 @@ void BASE_SCREEN::SetGrid( const wxRealPoint& size )
size_t i; size_t i;
wxRealPoint nearest_grid = m_GridList[0].m_Size; GRID_TYPE nearest_grid = m_GridList[0];
for( i = 0; i < m_GridList.GetCount(); i++ ) for( i = 0; i < m_GridList.GetCount(); i++ )
{ {
if( m_GridList[i].m_Size == size ) if( m_GridList[i].m_Size == size )
{ {
m_Grid = m_GridList[i].m_Size; m_Grid = m_GridList[i];
return; return;
} }
// keep trace of the nearest grill size, if the exact size is not found // keep trace of the nearest grill size, if the exact size is not found
if ( size.x < m_GridList[i].m_Size.x ) if ( size.x < m_GridList[i].m_Size.x )
nearest_grid = m_GridList[i].m_Size; nearest_grid = m_GridList[i];
} }
m_Grid = nearest_grid; m_Grid = nearest_grid;
wxLogWarning( wxT( "Grid size( %f, %f ) not in grid list, falling back " ) \ wxLogWarning( wxT( "Grid size( %f, %f ) not in grid list, falling back " ) \
wxT( "to grid size( %f, %f )." ), wxT( "to grid size( %f, %f )." ),
size.x, size.y, m_Grid.x, m_Grid.y ); size.x, size.y, m_Grid.m_Size.x, m_Grid.m_Size.y );
} }
/* Set grid size from command ID. */ /* Set grid size from command ID. */
...@@ -389,15 +391,16 @@ void BASE_SCREEN::SetGrid( int id ) ...@@ -389,15 +391,16 @@ void BASE_SCREEN::SetGrid( int id )
{ {
if( m_GridList[i].m_Id == id ) if( m_GridList[i].m_Id == id )
{ {
m_Grid = m_GridList[i].m_Size; m_Grid = m_GridList[i];
return; return;
} }
} }
m_Grid = m_GridList[0].m_Size; m_Grid = m_GridList[0];
wxLogWarning( wxT( "Grid ID %d not in grid list, falling back to " ) \ wxLogWarning( wxT( "Grid ID %d not in grid list, falling back to " ) \
wxT( "grid size( %g, %g )." ), id, m_Grid.x, m_Grid.y ); wxT( "grid size( %g, %g )." ), id, m_Grid.m_Size.x,
m_Grid.m_Size.y );
} }
void BASE_SCREEN::AddGrid( const GRID_TYPE& grid ) void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
...@@ -406,8 +409,8 @@ void BASE_SCREEN::AddGrid( const GRID_TYPE& grid ) ...@@ -406,8 +409,8 @@ 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) && grid.m_Id != 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 );
...@@ -446,13 +449,13 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id ) ...@@ -446,13 +449,13 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id )
if( units == MILLIMETRE ) if( units == MILLIMETRE )
{ {
x = size.x / 25.4; x = size.x / 25.4000508001016;
y = size.y / 25.4; y = size.y / 25.4000508001016;
} }
else if( units == CENTIMETRE ) else if( units == CENTIMETRE )
{ {
x = size.x / 2.54; x = size.x / 2.54000508001016;
y = size.y / 2.54; y = size.y / 2.54000508001016;
} }
else else
{ {
...@@ -468,14 +471,25 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id ) ...@@ -468,14 +471,25 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id )
AddGrid( new_grid ); AddGrid( new_grid );
} }
/*********************************/
wxRealPoint BASE_SCREEN::GetGrid() GRID_TYPE BASE_SCREEN::GetGrid()
/*********************************/
{ {
return m_Grid; return m_Grid;
} }
wxRealPoint BASE_SCREEN::GetGridSize()
{
return m_Grid.m_Size;
}
int BASE_SCREEN::GetGridId()
{
return m_Grid.m_Id;
}
/*****************************************/ /*****************************************/
void BASE_SCREEN::ClearUndoRedoList() void BASE_SCREEN::ClearUndoRedoList()
/*****************************************/ /*****************************************/
......
...@@ -423,7 +423,7 @@ double To_User_Unit( bool is_metric, double val, int internal_unit_value ) ...@@ -423,7 +423,7 @@ double To_User_Unit( bool is_metric, double val, int internal_unit_value )
double value; double value;
if( is_metric ) if( is_metric )
value = val * 25.4 / internal_unit_value; value = val * 25.4000508001016 / internal_unit_value;
else else
value = val / internal_unit_value; value = val / internal_unit_value;
...@@ -441,7 +441,7 @@ int From_User_Unit( bool is_metric, double val, int internal_unit_value ) ...@@ -441,7 +441,7 @@ int From_User_Unit( bool is_metric, double val, int internal_unit_value )
double value; double value;
if( is_metric ) if( is_metric )
value = val * internal_unit_value / 25.4; value = val * internal_unit_value / 25.4000508001016;
else else
value = val * internal_unit_value; value = val * internal_unit_value;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* Configuration entry names. */ /* Configuration entry names. */
static const wxString CursorShapeEntry( wxT( "CuShape" ) ); static const wxString CursorShapeEntry( wxT( "CuShape" ) );
static const wxString ShowGridEntry( wxT( "ShGrid" ) ); static const wxString ShowGridEntry( wxT( "ShGrid" ) );
static const wxString LastGridSizeId( wxT( "_LastGridSize" ) );
BEGIN_EVENT_TABLE( WinEDA_DrawFrame, WinEDA_BasicFrame ) BEGIN_EVENT_TABLE( WinEDA_DrawFrame, WinEDA_BasicFrame )
...@@ -32,6 +33,8 @@ BEGIN_EVENT_TABLE( WinEDA_DrawFrame, WinEDA_BasicFrame ) ...@@ -32,6 +33,8 @@ BEGIN_EVENT_TABLE( WinEDA_DrawFrame, WinEDA_BasicFrame )
EVT_ACTIVATE( WinEDA_DrawFrame::OnActivate ) EVT_ACTIVATE( WinEDA_DrawFrame::OnActivate )
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE, EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
WinEDA_DrawFrame::OnZoom ) WinEDA_DrawFrame::OnZoom )
EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER,
WinEDA_DrawFrame::OnSelectGrid )
END_EVENT_TABLE() END_EVENT_TABLE()
...@@ -67,6 +70,7 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, ...@@ -67,6 +70,7 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
m_Draw_Auxiliary_Axis = FALSE; // TRUE pour avoir les axes auxiliares dessines m_Draw_Auxiliary_Axis = FALSE; // TRUE pour avoir les axes auxiliares dessines
m_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch m_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch
m_CursorShape = 0; m_CursorShape = 0;
m_LastGridSizeId = 0;
// Internal units per inch: = 1000 for schema, = 10000 for PCB // Internal units per inch: = 1000 for schema, = 10000 for PCB
m_InternalUnits = EESCHEMA_INTERNAL_UNIT; m_InternalUnits = EESCHEMA_INTERNAL_UNIT;
...@@ -191,23 +195,65 @@ void WinEDA_DrawFrame::ToolOnRightClick( wxCommandEvent& event ) ...@@ -191,23 +195,65 @@ void WinEDA_DrawFrame::ToolOnRightClick( wxCommandEvent& event )
} }
/********************************************************/
void WinEDA_DrawFrame::OnSelectGrid( wxCommandEvent& event )
/********************************************************/
// Virtual function // Virtual function
void WinEDA_DrawFrame::OnSelectGrid( wxCommandEvent& event )
{ {
if( m_SelGridBox == NULL ) int* clientData;
return; // Should not occurs int id = ID_POPUP_GRID_LEVEL_100;
if( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED )
{
if( m_SelGridBox == NULL )
return;
/*
* Don't use wxCommandEvent::GetClientData() here. It always
* returns NULL in GTK. This solution is not as elegant but
* it works.
*/
int index = m_SelGridBox->GetSelection();
wxASSERT( index != wxNOT_FOUND );
clientData = (int*) m_SelGridBox->GetClientData( index );
if( clientData != NULL )
id = *clientData;
}
else
{
id = event.GetId();
/* Update the grid select combobox if the grid size was changed
* by menu event.
*/
if( m_SelGridBox != NULL )
{
for( size_t i = 0; i < m_SelGridBox->GetCount(); i++ )
{
clientData = (int*) m_SelGridBox->GetClientData( i );
if( clientData && id == *clientData )
{
m_SelGridBox->SetSelection( i );
break;
}
}
}
}
BASE_SCREEN* screen = GetBaseScreen(); BASE_SCREEN* screen = GetBaseScreen();
screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); if( screen->GetGridId() == id )
wxRealPoint current_grid = screen->GetGrid(); return;
screen->SetGrid( event.GetSelection() + ID_POPUP_GRID_LEVEL_1000 );
wxRealPoint selected_grid = screen->GetGrid();
if( selected_grid != current_grid ) /*
Recadre_Trace( FALSE ); * This allows for saving non-sequential command ID offsets used that
* may be used in the grid size combobox. Do not use the selection
* index returned by GetSelection().
*/
m_LastGridSizeId = id - ID_POPUP_GRID_LEVEL_1000;
screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
screen->SetGrid( event.GetId() );
Refresh();
} }
...@@ -652,30 +698,43 @@ void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event ) ...@@ -652,30 +698,43 @@ void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event )
} }
} }
/* used in UpdateStatusBar() when coordinates are in mm /**
* try to approximate a coordinate (in 0.001 mm) to an easy to read number * Round to the nearest precision.
*
* Try to approximate a coordinate using a given precision to prevent
* rounding errors when converting from inches to mm.
*
* ie round the unit value to 0 if unit is 1 or 2, or 8 or 9 * ie round the unit value to 0 if unit is 1 or 2, or 8 or 9
*/ */
double Round_To_0(double x) double RoundTo0( double x, double precision )
{ {
long long ix = wxRound(x * 1000); // ix is in 0.001 mm assert( precision != 0 );
if ( x < 0 ) NEGATE(ix);
long long ix = wxRound( x * precision );
if ( x < 0.0 )
NEGATE( ix );
int remainder = ix % 10; // remainder is in precision mm
int remainder = ix%10; // remainder is in 0.001 mm
if ( remainder <= 2 ) if ( remainder <= 2 )
ix -= remainder; // truncate to the near number ix -= remainder; // truncate to the near number
else if (remainder >= 8 ) else if (remainder >= 8 )
ix += 10 - remainder; // round to near number ix += 10 - remainder; // round to near number
if ( x < 0 ) NEGATE(ix); if ( x < 0 )
return (double)ix/1000.0; NEGATE( ix );
return (double) ix / precision;
} }
/** Function UpdateStatusBar() /**
* Function UpdateStatusBar()
* Displays in the bottom of the main window a stust: * Displays in the bottom of the main window a stust:
* - Absolute Cursor coordinates * - Absolute Cursor coordinates
* - Relative Cursor coordinates (relative to the last coordinate stored when actiavte the space bar) * - Relative Cursor coordinates (relative to the last coordinate stored
* ( in this status is also displayed the zoom level, but this is not made by this function) * when actiavte the space bar)
* ( in this status is also displayed the zoom level, but this is not made
* by this function )
*/ */
void WinEDA_DrawFrame::UpdateStatusBar() void WinEDA_DrawFrame::UpdateStatusBar()
{ {
...@@ -690,21 +749,31 @@ void WinEDA_DrawFrame::UpdateStatusBar() ...@@ -690,21 +749,31 @@ void WinEDA_DrawFrame::UpdateStatusBar()
if ( (screen->GetZoom() % screen->m_ZoomScalar) == 0 ) if ( (screen->GetZoom() % screen->m_ZoomScalar) == 0 )
Line.Printf( wxT( "Z %d" ), screen->GetZoom() / screen->m_ZoomScalar ); Line.Printf( wxT( "Z %d" ), screen->GetZoom() / screen->m_ZoomScalar );
else else
Line.Printf( wxT( "Z %.1f" ), (float)screen->GetZoom() / screen->m_ZoomScalar ); Line.Printf( wxT( "Z %.1f" ),
(float)screen->GetZoom() / screen->m_ZoomScalar );
SetStatusText( Line, 1 ); SetStatusText( Line, 1 );
/* Display absolute coordinates: */ /* Display absolute coordinates: */
double dXpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.x, m_InternalUnits ); double dXpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.x,
double dYpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.y, m_InternalUnits ); m_InternalUnits );
/* When using mm the conversion from 1/10000 inch to mm can give some non easy to read numbers, double dYpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.y,
* like 1.999 or 2.001 that be better if displayed 2.000, so small diffs are filtered here. m_InternalUnits );
/*
* Converting from inches to mm can give some coordinates due to
* float point precision rounding errors, like 1.999 or 2.001 so
* round to the nearest drawing precision required by the application.
*/ */
if ( g_UnitMetric ) if ( g_UnitMetric )
{ {
dXpos = Round_To_0(dXpos); dXpos = RoundTo0( dXpos, (double)( m_InternalUnits / 10 ) );
dYpos = Round_To_0(dYpos); dYpos = RoundTo0( dYpos, (double)( m_InternalUnits / 10 ) );
} }
Line.Printf( g_UnitMetric ? wxT( "X %.3f Y %.3f" ) : wxT( "X %.4f Y %.4f" ), dXpos, dYpos ); if( m_InternalUnits == EESCHEMA_INTERNAL_UNIT )
Line.Printf( g_UnitMetric ? wxT( "X %.2f Y %.2f" ) :
wxT( "X %.3f Y %.3f" ), dXpos, dYpos );
else
Line.Printf( g_UnitMetric ? wxT( "X %.3f Y %.3f" ) :
wxT( "X %.4f Y %.4f" ), dXpos, dYpos );
SetStatusText( Line, 2 ); SetStatusText( Line, 2 );
/* Display relative coordinates: */ /* Display relative coordinates: */
...@@ -714,10 +783,15 @@ void WinEDA_DrawFrame::UpdateStatusBar() ...@@ -714,10 +783,15 @@ void WinEDA_DrawFrame::UpdateStatusBar()
dYpos = To_User_Unit( g_UnitMetric, dy, m_InternalUnits ); dYpos = To_User_Unit( g_UnitMetric, dy, m_InternalUnits );
if ( g_UnitMetric ) if ( g_UnitMetric )
{ {
dXpos = Round_To_0(dXpos); dXpos = RoundTo0( dXpos, (double)( m_InternalUnits / 10 ) );
dYpos = Round_To_0(dYpos); dYpos = RoundTo0( dYpos, (double)( m_InternalUnits / 10 ) );
} }
Line.Printf( g_UnitMetric ? wxT( "x %.3f y %.3f" ) : wxT( "x %.4f y %.4f" ), dXpos, dYpos ); if( m_InternalUnits == EESCHEMA_INTERNAL_UNIT )
Line.Printf( g_UnitMetric ? wxT( "X %.2f Y %.2f" ) :
wxT( "X %.3f Y %.3f" ), dXpos, dYpos );
else
Line.Printf( g_UnitMetric ? wxT( "x %.3f y %.3f" ) :
wxT( "x %.4f y %.4f" ), dXpos, dYpos );
SetStatusText( Line, 3 ); SetStatusText( Line, 3 );
} }
...@@ -737,6 +811,7 @@ void WinEDA_DrawFrame::LoadSettings() ...@@ -737,6 +811,7 @@ void WinEDA_DrawFrame::LoadSettings()
WinEDA_BasicFrame::LoadSettings(); WinEDA_BasicFrame::LoadSettings();
cfg->Read( m_FrameName + CursorShapeEntry, &m_CursorShape, ( long )0 ); cfg->Read( m_FrameName + CursorShapeEntry, &m_CursorShape, ( long )0 );
cfg->Read( m_FrameName + ShowGridEntry, &m_Draw_Grid, true ); cfg->Read( m_FrameName + ShowGridEntry, &m_Draw_Grid, true );
cfg->Read( m_FrameName + LastGridSizeId, &m_LastGridSizeId, 0L );
} }
...@@ -755,4 +830,25 @@ void WinEDA_DrawFrame::SaveSettings() ...@@ -755,4 +830,25 @@ void WinEDA_DrawFrame::SaveSettings()
WinEDA_BasicFrame::SaveSettings(); WinEDA_BasicFrame::SaveSettings();
cfg->Write( m_FrameName + CursorShapeEntry, m_CursorShape ); cfg->Write( m_FrameName + CursorShapeEntry, m_CursorShape );
cfg->Write( m_FrameName + ShowGridEntry, m_Draw_Grid ); cfg->Write( m_FrameName + ShowGridEntry, m_Draw_Grid );
cfg->Write( m_FrameName + LastGridSizeId, ( long ) m_LastGridSizeId );
}
void WinEDA_DrawFrame::AppendMsgPanel( const wxString& textUpper,
const wxString& textLower,
int color, int pad )
{
if( MsgPanel == NULL )
return;
MsgPanel->AppendMessage( textUpper, textLower, color, pad );
}
void WinEDA_DrawFrame::ClearMsgPanel( void )
{
if( MsgPanel == NULL )
return;
MsgPanel->EraseMsgBox();
} }
...@@ -38,9 +38,6 @@ BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow ) ...@@ -38,9 +38,6 @@ BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow )
EVT_ERASE_BACKGROUND( WinEDA_DrawPanel::OnEraseBackground ) EVT_ERASE_BACKGROUND( WinEDA_DrawPanel::OnEraseBackground )
EVT_SCROLLWIN( WinEDA_DrawPanel::OnScroll ) EVT_SCROLLWIN( WinEDA_DrawPanel::OnScroll )
EVT_ACTIVATE( WinEDA_DrawPanel::OnActivate ) EVT_ACTIVATE( WinEDA_DrawPanel::OnActivate )
EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER,
WinEDA_DrawPanel::OnPopupGridSelect )
EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, WinEDA_DrawPanel::OnPan ) EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, WinEDA_DrawPanel::OnPan )
END_EVENT_TABLE() END_EVENT_TABLE()
...@@ -186,7 +183,7 @@ void WinEDA_DrawPanel::SetZoom( int zoom ) ...@@ -186,7 +183,7 @@ void WinEDA_DrawPanel::SetZoom( int zoom )
wxRealPoint WinEDA_DrawPanel::GetGrid() wxRealPoint WinEDA_DrawPanel::GetGrid()
/************************************/ /************************************/
{ {
return GetScreen()->GetGrid(); return GetScreen()->GetGridSize();
} }
...@@ -763,7 +760,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) ...@@ -763,7 +760,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
*/ */
drawgrid = m_Parent->m_Draw_Grid; drawgrid = m_Parent->m_Draw_Grid;
screen_grid_size = screen->GetGrid(); screen_grid_size = screen->GetGridSize();
wxRealPoint dgrid = screen_grid_size; wxRealPoint dgrid = screen_grid_size;
screen->Scale( dgrid ); // dgrid = grid size in pixels screen->Scale( dgrid ); // dgrid = grid size in pixels
...@@ -797,7 +794,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) ...@@ -797,7 +794,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
screen->Unscale( size ); screen->Unscale( size );
#ifdef WX_ZOOM #ifdef WX_ZOOM
screen_grid_size = screen->GetGrid(); screen_grid_size = screen->GetGridSize();
if( DC->LogicalToDeviceXRel( (int) screen_grid_size.x ) < 5 if( DC->LogicalToDeviceXRel( (int) screen_grid_size.x ) < 5
|| DC->LogicalToDeviceYRel( (int) screen_grid_size.y ) < 5 ) || DC->LogicalToDeviceYRel( (int) screen_grid_size.y ) < 5 )
......
...@@ -47,7 +47,7 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord ) ...@@ -47,7 +47,7 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord )
* @param coord = coordinate to adjust * @param coord = coordinate to adjust
*/ */
{ {
wxRealPoint grid_size = GetBaseScreen()->GetGrid(); wxRealPoint grid_size = GetBaseScreen()->GetGridSize();
if( !GetBaseScreen()->m_UserGridIsON ) if( !GetBaseScreen()->m_UserGridIsON )
{ {
...@@ -183,11 +183,6 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) ...@@ -183,11 +183,6 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
UpdateStatusBar(); UpdateStatusBar();
} }
void WinEDA_DrawPanel::OnPopupGridSelect( wxCommandEvent& event )
{
GetScreen()->SetGrid( event.GetId() );
Refresh();
}
/*************************************************************/ /*************************************************************/
void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
...@@ -200,7 +195,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) ...@@ -200,7 +195,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
size_t i; size_t i;
int maxZoomIds; int maxZoomIds;
int zoom; int zoom;
wxRealPoint grid; wxRealPoint grid;
wxString msg; wxString msg;
GRID_TYPE tmp; GRID_TYPE tmp;
wxMenu* gridMenu; wxMenu* gridMenu;
...@@ -228,10 +223,12 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) ...@@ -228,10 +223,12 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
/* Populate zoom submenu. */ /* Populate zoom submenu. */
for( i = 0; i < (size_t) maxZoomIds; i++ ) for( i = 0; i < (size_t) maxZoomIds; i++ )
{ {
if ( (GetScreen()->m_ZoomList[i] % GetScreen()->m_ZoomScalar) == 0 ) if ( ( GetScreen()->m_ZoomList[i] % GetScreen()->m_ZoomScalar ) == 0 )
msg.Printf( wxT( "%u" ), GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar); msg.Printf( wxT( "%u" ),
GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar );
else else
msg.Printf(wxT("%.1f"),(float)GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar ); msg.Printf( wxT( "%.1f" ),
(float) GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar );
zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg, zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg,
wxEmptyString, wxITEM_CHECK ); wxEmptyString, wxITEM_CHECK );
...@@ -247,7 +244,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) ...@@ -247,7 +244,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
ID_POPUP_GRID_SELECT, _( "Grid Select" ), ID_POPUP_GRID_SELECT, _( "Grid Select" ),
grid_select_xpm ); grid_select_xpm );
grid = GetScreen()->GetGrid(); grid = GetScreen()->GetGridSize();
for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ ) for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ )
{ {
......
...@@ -199,7 +199,7 @@ void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -199,7 +199,7 @@ void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
curpos = DrawPanel->CursorRealPosition( Mouse ); curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGrid(); delta = GetScreen()->GetGridSize();
GetScreen()->Scale( delta ); GetScreen()->Scale( delta );
if( delta.x <= 0 ) if( delta.x <= 0 )
......
...@@ -327,7 +327,7 @@ void LIB_TEXT::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -327,7 +327,7 @@ void LIB_TEXT::DisplayInfo( WinEDA_DrawFrame* frame )
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
frame->MsgPanel->AppendMessage( _( "Line width" ), msg, BLUE ); frame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
} }
......
...@@ -698,10 +698,9 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame, ...@@ -698,10 +698,9 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
/***********************************************************/ /***********************************************************/
void DrawSheetStruct::DisplayInfo( WinEDA_DrawFrame* frame ) void DrawSheetStruct::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
WinEDA_MsgPanel *msgpanel = frame->MsgPanel; frame->ClearMsgPanel();
msgpanel->EraseMsgBox(); frame->AppendMsgPanel( _( "Sheet name" ), m_SheetName, CYAN );
msgpanel->AppendMessage( _( "Name" ), m_SheetName, CYAN ); frame->AppendMsgPanel( _( "File name" ), m_FileName, BROWN );
msgpanel->AppendMessage( _( "FileName" ), m_FileName, BROWN );
} }
......
...@@ -431,6 +431,20 @@ LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* item, ...@@ -431,6 +431,20 @@ LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* item,
} }
void LIB_COMPONENT::GetPins( LIB_PIN_LIST& pins, int unit, int convert )
{
BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
{
if( item.Type() != COMPONENT_PIN_DRAW_TYPE ||
( unit && item.m_Unit != unit ) ||
( convert && item.m_Convert != convert ) )
continue;
pins.push_back( (LIB_PIN*) &item );
}
}
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
......
...@@ -241,17 +241,46 @@ public: ...@@ -241,17 +241,46 @@ public:
* @param type - type of searched item (filter). * @param type - type of searched item (filter).
* if TYPE_NOT_INIT search for all items types * if TYPE_NOT_INIT search for all items types
* *
* @return - Pointer to the next drawing object in the list if found,
* otherwise NULL.
*/ */
LIB_DRAW_ITEM* GetNextDrawItem( LIB_DRAW_ITEM* item = NULL, LIB_DRAW_ITEM* GetNextDrawItem( LIB_DRAW_ITEM* item = NULL,
KICAD_T type = TYPE_NOT_INIT ); KICAD_T type = TYPE_NOT_INIT );
/**
* Return the next pin object from the draw list.
*
* This is just a pin object specific version of GetNextDrawItem().
*
* @param item - Pointer to the previous pin item, or NULL to get the
* first pin in the draw object list.
*
* @return - Pointer to the next pin object in the list if found,
* otherwise NULL.
*/
LIB_PIN* GetNextPin( LIB_PIN* item = NULL ) LIB_PIN* GetNextPin( LIB_PIN* item = NULL )
{ {
return (LIB_PIN*) GetNextDrawItem( (LIB_DRAW_ITEM*) item, return (LIB_PIN*) GetNextDrawItem( (LIB_DRAW_ITEM*) item,
COMPONENT_PIN_DRAW_TYPE ); COMPONENT_PIN_DRAW_TYPE );
} }
/**
* Return a list of pin object pointers from the draw item list.
*
* Note pin objects are owned by the draw list of the component.
* Deleting any of the objects will leave list in a unstable state
* and will likely segfault when the list is destroyed.
*
* @param list - Pin list to place pin object pointers into.
* @param unit - Unit number of pin to add to list. Set to 0 to
* get pins from any component part.
* @param convert - Convert number of pin to add to list. Set to 0 to
* get pins from any convert of component.
*/
void GetPins( LIB_PIN_LIST& pins, int unit = 0, int convert = 0 );
/** /**
* Move the component offset. * Move the component offset.
* *
......
...@@ -1182,17 +1182,17 @@ void LIB_PIN::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1182,17 +1182,17 @@ void LIB_PIN::DisplayInfo( WinEDA_DrawFrame* frame )
LIB_DRAW_ITEM::DisplayInfo( frame ); LIB_DRAW_ITEM::DisplayInfo( frame );
frame->MsgPanel->AppendMessage( _( "Pin name" ), m_PinName, DARKCYAN ); frame->AppendMsgPanel( _( "Pin name" ), m_PinName, DARKCYAN );
if( m_PinNum == 0 ) if( m_PinNum == 0 )
Text = wxT( "?" ); Text = wxT( "?" );
else else
ReturnPinStringNum( Text ); ReturnPinStringNum( Text );
frame->MsgPanel->AppendMessage( _( "Pin number" ), Text, DARKCYAN ); frame->AppendMsgPanel( _( "Pin number" ), Text, DARKCYAN );
ii = m_PinType; ii = m_PinType;
frame->MsgPanel->AppendMessage( _( "Pin type" ), MsgPinElectricType[ii], frame->AppendMsgPanel( _( "Pin type" ), MsgPinElectricType[ii],
RED ); RED );
ii = m_Attributs; ii = m_Attributs;
...@@ -1200,12 +1200,12 @@ void LIB_PIN::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1200,12 +1200,12 @@ void LIB_PIN::DisplayInfo( WinEDA_DrawFrame* frame )
Text = _( "Not visible" ); Text = _( "Not visible" );
else else
Text = _( "Visible" ); Text = _( "Visible" );
frame->MsgPanel->AppendMessage( _( "Display" ), Text, DARKGREEN ); frame->AppendMsgPanel( _( "Display" ), Text, DARKGREEN );
/* Display pin length */ /* Display pin length */
Text = ReturnStringFromValue( g_UnitMetric, m_PinLen, Text = ReturnStringFromValue( g_UnitMetric, m_PinLen,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
frame->MsgPanel->AppendMessage( _( "Length" ), Text, MAGENTA ); frame->AppendMsgPanel( _( "Length" ), Text, MAGENTA );
switch( m_Orient ) switch( m_Orient )
{ {
...@@ -1230,7 +1230,7 @@ void LIB_PIN::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1230,7 +1230,7 @@ void LIB_PIN::DisplayInfo( WinEDA_DrawFrame* frame )
break; break;
} }
frame->MsgPanel->AppendMessage( _( "Orientation" ), Text, MAGENTA ); frame->AppendMsgPanel( _( "Orientation" ), Text, MAGENTA );
} }
......
...@@ -1025,29 +1025,30 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1025,29 +1025,30 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( Entry == NULL )
return;
wxString msg; wxString msg;
WinEDA_MsgPanel *msgpanel = frame->MsgPanel;
msgpanel->EraseMsgBox(); frame->ClearMsgPanel();
msg = GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()); frame->AppendMsgPanel( _( "Reference" ),
msgpanel->AppendMessage( _( "Ref" ), msg, DARKCYAN ); GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()),
DARKCYAN );
if( Entry && Entry->m_Options == ENTRY_POWER ) if( Entry->m_Options == ENTRY_POWER )
msg = _( "Pwr Symb" ); msg = _( "Power symbol" );
else else
msg = _( "Val" ); msg = _( "Name" );
msgpanel->AppendMessage( msg, GetField( VALUE )->m_Text, DARKCYAN );
msgpanel->AppendMessage( _( "RefLib" ), m_ChipName.GetData(), BROWN ); frame->AppendMsgPanel( msg, GetField( VALUE )->m_Text, DARKCYAN );
frame->AppendMsgPanel( _( "Component" ), m_ChipName, BROWN );
msg = Entry->GetLibraryName(); msg = Entry->GetLibraryName();
msgpanel->AppendMessage( _( "Lib" ), msg, DARKRED ); frame->AppendMsgPanel( _( "Library" ), msg, DARKRED );
frame->AppendMsgPanel( _( "Description" ), Entry->m_Doc, DARKCYAN );
if( Entry ) frame->AppendMsgPanel( _( "Key words" ), Entry->m_KeyWord, DARKCYAN );
msgpanel->AppendMessage( Entry->m_Doc, Entry->m_KeyWord, DARKCYAN );
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
......
...@@ -53,6 +53,7 @@ static int SchematicZoomList[] = ...@@ -53,6 +53,7 @@ static int SchematicZoomList[] =
#define SCHEMATIC_ZOOM_LIST_CNT ( sizeof( SchematicZoomList ) / \ #define SCHEMATIC_ZOOM_LIST_CNT ( sizeof( SchematicZoomList ) / \
sizeof( int ) ) sizeof( int ) )
#define MM_TO_SCH_UNITS 1000.0 / 25.4000508001016
/* Default grid sizes for the schematic editor. */ /* Default grid sizes for the schematic editor. */
...@@ -62,7 +63,19 @@ static GRID_TYPE SchematicGridList[] = { ...@@ -62,7 +63,19 @@ static GRID_TYPE SchematicGridList[] = {
{ ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) }, { ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) },
{ ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) }, { ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) },
{ ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) }, { ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) },
{ ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) } { ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) },
// predefined grid list in mm
{ ID_POPUP_GRID_LEVEL_2_5MM, wxRealPoint( MM_TO_SCH_UNITS * 2.5,
MM_TO_SCH_UNITS * 2.5 ) },
{ ID_POPUP_GRID_LEVEL_1MM, wxRealPoint( MM_TO_SCH_UNITS,
MM_TO_SCH_UNITS ) },
{ ID_POPUP_GRID_LEVEL_0_5MM, wxRealPoint( MM_TO_SCH_UNITS * 0.5,
MM_TO_SCH_UNITS * 0.5 ) },
{ ID_POPUP_GRID_LEVEL_0_25MM, wxRealPoint( MM_TO_SCH_UNITS * 0.25,
MM_TO_SCH_UNITS * 0.25 ) },
{ ID_POPUP_GRID_LEVEL_0_1MM, wxRealPoint( MM_TO_SCH_UNITS * 0.1,
MM_TO_SCH_UNITS * 0.1 ) }
}; };
#define SCHEMATIC_GRID_LIST_CNT ( sizeof( SchematicGridList ) / \ #define SCHEMATIC_GRID_LIST_CNT ( sizeof( SchematicGridList ) / \
......
...@@ -58,16 +58,15 @@ void LIB_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -58,16 +58,15 @@ void LIB_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
wxString msg; wxString msg;
frame->MsgPanel->EraseMsgBox(); frame->ClearMsgPanel();
frame->AppendMsgPanel( _( "Type" ), m_typeName, CYAN );
frame->MsgPanel->AppendMessage( _( "Type" ), m_typeName, CYAN );
/* Affichage de l'appartenance */ /* Affichage de l'appartenance */
if( m_Unit == 0 ) if( m_Unit == 0 )
msg = _( "All" ); msg = _( "All" );
else else
msg.Printf( wxT( "%d" ), m_Unit ); msg.Printf( wxT( "%d" ), m_Unit );
frame->MsgPanel->AppendMessage( _( "Unit" ), msg, BROWN ); frame->AppendMsgPanel( _( "Unit" ), msg, BROWN );
if( m_Convert == 0 ) if( m_Convert == 0 )
msg = _( "All" ); msg = _( "All" );
...@@ -77,7 +76,7 @@ void LIB_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -77,7 +76,7 @@ void LIB_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame )
msg = _( "yes" ); msg = _( "yes" );
else else
msg = wxT( "?" ); msg = wxT( "?" );
frame->MsgPanel->AppendMessage( _( "Convert" ), msg, BROWN ); frame->AppendMsgPanel( _( "Convert" ), msg, BROWN );
} }
...@@ -525,12 +524,12 @@ void LIB_ARC::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -525,12 +524,12 @@ void LIB_ARC::DisplayInfo( WinEDA_DrawFrame* frame )
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
frame->MsgPanel->AppendMessage( _( "Line width" ), msg, BLUE ); frame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
frame->MsgPanel->AppendMessage( _( "Bounding box" ), msg, BROWN ); frame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN );
} }
...@@ -785,16 +784,16 @@ void LIB_CIRCLE::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -785,16 +784,16 @@ void LIB_CIRCLE::DisplayInfo( WinEDA_DrawFrame* frame )
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
frame->MsgPanel->AppendMessage( _( "Line width" ), msg, BLUE ); frame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
msg = ReturnStringFromValue( g_UnitMetric, m_Radius, msg = ReturnStringFromValue( g_UnitMetric, m_Radius,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
frame->MsgPanel->AppendMessage( _( "Radius" ), msg, RED ); frame->AppendMsgPanel( _( "Radius" ), msg, RED );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
frame->MsgPanel->AppendMessage( _( "Bounding box" ), msg, BROWN ); frame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN );
} }
...@@ -1009,7 +1008,7 @@ void LIB_RECTANGLE::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1009,7 +1008,7 @@ void LIB_RECTANGLE::DisplayInfo( WinEDA_DrawFrame* frame )
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
frame->MsgPanel->AppendMessage( _( "Line width" ), msg, BLUE ); frame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
} }
...@@ -1260,12 +1259,12 @@ void LIB_SEGMENT::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1260,12 +1259,12 @@ void LIB_SEGMENT::DisplayInfo( WinEDA_DrawFrame* frame )
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
frame->MsgPanel->AppendMessage( _( "Line width" ), msg, BLUE ); frame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
frame->MsgPanel->AppendMessage( _( "Bounding box" ), msg, BROWN ); frame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN );
} }
...@@ -1670,12 +1669,12 @@ void LIB_POLYLINE::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1670,12 +1669,12 @@ void LIB_POLYLINE::DisplayInfo( WinEDA_DrawFrame* frame )
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
frame->MsgPanel->AppendMessage( _( "Line width" ), msg, BLUE ); frame->AppendMsgPanel(_( "Line width" ), msg, BLUE );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
frame->MsgPanel->AppendMessage( _( "Bounding box" ), msg, BROWN ); frame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN );
} }
/***************************/ /***************************/
...@@ -2038,10 +2037,10 @@ void LIB_BEZIER::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -2038,10 +2037,10 @@ void LIB_BEZIER::DisplayInfo( WinEDA_DrawFrame* frame )
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
frame->MsgPanel->AppendMessage( _( "Line width" ), msg, BLUE ); frame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
frame->MsgPanel->AppendMessage( _( "Bounding box" ), msg, BROWN ); frame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN );
} }
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
class LIB_COMPONENT; class LIB_COMPONENT;
class PLOTTER; class PLOTTER;
class LIB_DRAW_ITEM; class LIB_DRAW_ITEM;
class LIB_PIN;
#define TARGET_PIN_DIAM 12 /* Circle diameter drawn at the active end of #define TARGET_PIN_DIAM 12 /* Circle diameter drawn at the active end of
...@@ -87,6 +88,23 @@ enum DrawPinOrient ...@@ -87,6 +88,23 @@ enum DrawPinOrient
}; };
/**
* Helper for defining a list of library draw object pointers. The Boost
* pointer containers are responsible for deleting object pointers placed
* in them. If you access a object pointer from the list, do not delete
* it directly.
*/
typedef boost::ptr_vector< LIB_DRAW_ITEM > LIB_DRAW_ITEM_LIST;
/**
* Helper for defining a list of pin object pointers. The list does not
* use a Boost pointer class so the ojbect pointers do not accidently get
* deleted when the container is deleted.
*/
typedef std::vector< LIB_PIN* > LIB_PIN_LIST;
/****************************************************************************/ /****************************************************************************/
/* Classes for handle the body items of a component: pins add graphic items */ /* Classes for handle the body items of a component: pins add graphic items */
/****************************************************************************/ /****************************************************************************/
...@@ -311,12 +329,6 @@ protected: ...@@ -311,12 +329,6 @@ protected:
}; };
/**
* Helper for defining a list of library draw object pointers.
*/
typedef boost::ptr_vector< LIB_DRAW_ITEM > LIB_DRAW_ITEM_LIST;
/********/ /********/
/* Pins */ /* Pins */
/********/ /********/
......
...@@ -48,7 +48,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include ...@@ -48,7 +48,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
DrawStruct = SchematicGeneralLocateAndDisplay( mouse_position, IncludePin ); DrawStruct = SchematicGeneralLocateAndDisplay( mouse_position, IncludePin );
if( !DrawStruct && ( mouse_position != GetScreen()->m_Curseur) ) if( !DrawStruct && ( mouse_position != GetScreen()->m_Curseur) )
{ {
DrawStruct = SchematicGeneralLocateAndDisplay( GetScreen()->m_Curseur, IncludePin ); DrawStruct = SchematicGeneralLocateAndDisplay( GetScreen()->m_Curseur,
IncludePin );
} }
if( !DrawStruct ) if( !DrawStruct )
return NULL; return NULL;
...@@ -63,7 +64,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include ...@@ -63,7 +64,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
break; break;
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem ); Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur,
&LibItem );
if( Pin ) if( Pin )
break; // Priority is probing a pin first break; // Priority is probing a pin first
LibItem = (SCH_COMPONENT*) DrawStruct; LibItem = (SCH_COMPONENT*) DrawStruct;
...@@ -71,7 +73,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include ...@@ -71,7 +73,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
break; break;
default: default:
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem ); Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur,
&LibItem );
break; break;
case COMPONENT_PIN_DRAW_TYPE: case COMPONENT_PIN_DRAW_TYPE:
...@@ -81,16 +84,15 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include ...@@ -81,16 +84,15 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
if( Pin ) if( Pin )
{ {
/* Force display pin infos (the previous display could be a component info) */ /* Force display pin information (the previous display could be a
* component info) */
Pin->DisplayInfo( this ); Pin->DisplayInfo( this );
if( LibItem ) if( LibItem )
{ AppendMsgPanel( LibItem->GetRef( GetSheet() ),
MsgPanel->AppendMessage( LibItem->GetRef( GetSheet() ), LibItem->GetField( VALUE )->m_Text, DARKCYAN );
LibItem->GetField( VALUE )->m_Text,
DARKCYAN );
}
// Cross probing:2 - pin found, and send a locate pin command to pcbnew (hightlight net) // Cross probing:2 - pin found, and send a locate pin command to
// pcbnew (hightlight net)
SendMessageToPCBNEW( Pin, LibItem ); SendMessageToPCBNEW( Pin, LibItem );
} }
return DrawStruct; return DrawStruct;
...@@ -98,7 +100,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include ...@@ -98,7 +100,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
/********************************************************************************************/ /********************************************************************************************/
SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint& refpoint,
bool IncludePin ) bool IncludePin )
/********************************************************************************************/ /********************************************************************************************/
...@@ -129,20 +131,20 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin ...@@ -129,20 +131,20 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), MARKERITEM ); DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), MARKERITEM );
if( DrawStruct ) if( DrawStruct )
{ {
MsgPanel->EraseMsgBox(); ClearMsgPanel();
return DrawStruct; return DrawStruct;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), NOCONNECTITEM ); DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), NOCONNECTITEM );
if( DrawStruct ) if( DrawStruct )
{ {
MsgPanel->EraseMsgBox(); ClearMsgPanel();
return DrawStruct; return DrawStruct;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), JUNCTIONITEM ); DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), JUNCTIONITEM );
if( DrawStruct ) if( DrawStruct )
{ {
MsgPanel->EraseMsgBox(); ClearMsgPanel();
return DrawStruct; return DrawStruct;
} }
...@@ -154,14 +156,11 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin ...@@ -154,14 +156,11 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
{ {
Pin->DisplayInfo( this ); Pin->DisplayInfo( this );
if( LibItem ) if( LibItem )
{ AppendMsgPanel( LibItem->GetRef( GetSheet() ),
MsgPanel->AppendMessage( LibItem->GetRef( GetSheet() ), LibItem->GetField( VALUE )->m_Text, DARKCYAN );
LibItem->GetField( VALUE )->m_Text,
DARKCYAN );
}
} }
else else
MsgPanel->EraseMsgBox(); ClearMsgPanel();
return DrawStruct; return DrawStruct;
} }
...@@ -176,16 +175,14 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin ...@@ -176,16 +175,14 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
} }
/* search for a pin */ /* search for a pin */
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint, &LibItem ); Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint,
&LibItem );
if( Pin ) if( Pin )
{ {
Pin->DisplayInfo( this ); Pin->DisplayInfo( this );
if( LibItem ) if( LibItem )
{ AppendMsgPanel( LibItem->GetRef( GetSheet() ),
MsgPanel->AppendMessage( LibItem->GetRef( GetSheet() ), LibItem->GetField( VALUE )->m_Text, DARKCYAN );
LibItem->GetField( VALUE )->m_Text,
DARKCYAN );
}
if( IncludePin ) if( IncludePin )
return LibItem; return LibItem;
} }
...@@ -213,7 +210,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin ...@@ -213,7 +210,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
return DrawStruct; return DrawStruct;
} }
MsgPanel->EraseMsgBox(); ClearMsgPanel();
return NULL; return NULL;
} }
...@@ -231,7 +228,7 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, ...@@ -231,7 +228,7 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
curpos = screen->m_MousePosition; curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur; oldpos = screen->m_Curseur;
delta = screen->GetGrid(); delta = screen->GetGridSize();
screen->Scale( delta ); screen->Scale( delta );
if( delta.x <= 0 ) if( delta.x <= 0 )
...@@ -324,7 +321,7 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, ...@@ -324,7 +321,7 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
curpos = screen->m_MousePosition; curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur; oldpos = screen->m_Curseur;
delta = screen->GetGrid(); delta = screen->GetGridSize();
screen->Scale( delta ); screen->Scale( delta );
if( delta.x <= 0 ) if( delta.x <= 0 )
...@@ -416,7 +413,7 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, ...@@ -416,7 +413,7 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
curpos = screen->m_MousePosition; curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur; oldpos = screen->m_Curseur;
delta = screen->GetGrid(); delta = screen->GetGridSize();
screen->Scale( delta ); screen->Scale( delta );
if( delta.x <= 0 ) if( delta.x <= 0 )
......
...@@ -92,7 +92,7 @@ WinEDA_SetOptionsFrame::WinEDA_SetOptionsFrame( WinEDA_SchematicFrame* parent, ...@@ -92,7 +92,7 @@ WinEDA_SetOptionsFrame::WinEDA_SetOptionsFrame( WinEDA_SchematicFrame* parent,
/* Init options */ /* Init options */
if( screen ) if( screen )
{ {
switch( (int)screen->GetGrid().x ) switch( (int)screen->GetGridSize().x )
{ {
case 50: case 50:
m_SelGridSize->SetSelection( 0 ); m_SelGridSize->SetSelection( 0 );
......
...@@ -301,7 +301,7 @@ bool EDA_Printout::OnPrintPage( int page ) ...@@ -301,7 +301,7 @@ bool EDA_Printout::OnPrintPage( int page )
wxString msg; wxString msg;
msg.Printf( _( "Print page %d" ), page ); msg.Printf( _( "Print page %d" ), page );
m_Parent->Affiche_Message( msg ); m_Parent->AppendMsgPanel( msg, wxEmptyString, CYAN );
WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent; WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent;
SCH_SCREEN* screen = schframe->GetScreen(); SCH_SCREEN* screen = schframe->GetScreen();
......
...@@ -263,6 +263,7 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName, ...@@ -263,6 +263,7 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName,
SetDrawBgColor( g_DrawBgColor ); SetDrawBgColor( g_DrawBgColor );
LoadLibraries(); LoadLibraries();
GetBaseScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
return IsRead; return IsRead;
} }
......
...@@ -99,7 +99,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, ...@@ -99,7 +99,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
GetScreen()->m_FileName = FullFileName; GetScreen()->m_FileName = FullFileName;
g_RootSheet->SetFileName( FullFileName ); g_RootSheet->SetFileName( FullFileName );
Affiche_Message( wxEmptyString ); Affiche_Message( wxEmptyString );
MsgPanel->EraseMsgBox(); ClearMsgPanel();
memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) ); memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) );
...@@ -111,6 +111,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, ...@@ -111,6 +111,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
{ {
screen->m_CurrentSheetDesc = &g_Sheet_A4; screen->m_CurrentSheetDesc = &g_Sheet_A4;
screen->SetZoom( 32 ); screen->SetZoom( 32 );
screen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
screen->m_Title = wxT( "noname.sch" ); screen->m_Title = wxT( "noname.sch" );
GetScreen()->m_FileName = screen->m_Title; GetScreen()->m_FileName = screen->m_Title;
screen->m_Company.Empty(); screen->m_Company.Empty();
...@@ -213,6 +214,7 @@ Error: %s" ), ...@@ -213,6 +214,7 @@ Error: %s" ),
/* Reaffichage ecran de base (ROOT) si necessaire */ /* Reaffichage ecran de base (ROOT) si necessaire */
ActiveScreen = GetScreen(); ActiveScreen = GetScreen();
ActiveScreen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
Zoom_Automatique( FALSE ); Zoom_Automatique( FALSE );
SetSheetNumberAndCount(); SetSheetNumberAndCount();
DrawPanel->Refresh( true ); DrawPanel->Refresh( true );
......
...@@ -235,7 +235,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC, ...@@ -235,7 +235,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
DrawStructsInGhost( DrawPanel, DC, Component, wxPoint(0,0) ); DrawStructsInGhost( DrawPanel, DC, Component, wxPoint(0,0) );
MsgPanel->EraseMsgBox(); ClearMsgPanel();
Component->DisplayInfo( this ); Component->DisplayInfo( this );
return Component; return Component;
......
...@@ -264,7 +264,7 @@ void WinEDA_SchematicFrame::InstallPreviousSheet() ...@@ -264,7 +264,7 @@ void WinEDA_SchematicFrame::InstallPreviousSheet()
return; return;
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
MsgPanel->EraseMsgBox(); ClearMsgPanel();
//make a copy for testing purposes. //make a copy for testing purposes.
DrawSheetPath listtemp = *m_CurrentSheet; DrawSheetPath listtemp = *m_CurrentSheet;
...@@ -296,7 +296,7 @@ void WinEDA_SchematicFrame::InstallNextScreen( DrawSheetStruct* Sheet ) ...@@ -296,7 +296,7 @@ void WinEDA_SchematicFrame::InstallNextScreen( DrawSheetStruct* Sheet )
} }
m_CurrentSheet->Push( Sheet ); m_CurrentSheet->Push( Sheet );
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
MsgPanel->EraseMsgBox(); ClearMsgPanel();
UpdateScreenFromSheet( this ); UpdateScreenFromSheet( this );
} }
...@@ -321,7 +321,7 @@ static bool UpdateScreenFromSheet( WinEDA_SchematicFrame* frame ) ...@@ -321,7 +321,7 @@ static bool UpdateScreenFromSheet( WinEDA_SchematicFrame* frame )
// Reinit des parametres d'affichage du nouvel ecran // Reinit des parametres d'affichage du nouvel ecran
// assumes m_CurrentSheet has already been updated. // assumes m_CurrentSheet has already been updated.
frame->MsgPanel->EraseMsgBox(); frame->ClearMsgPanel();
frame->DrawPanel->SetScrollbars( NewScreen->m_ZoomScalar, frame->DrawPanel->SetScrollbars( NewScreen->m_ZoomScalar,
NewScreen->m_ZoomScalar, NewScreen->m_ZoomScalar,
NewScreen->m_ScrollbarNumber.x, NewScreen->m_ScrollbarNumber.x,
......
...@@ -268,13 +268,13 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event ) ...@@ -268,13 +268,13 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
bool success = m_library->Save( fn.GetFullPath(), true ); bool success = m_library->Save( fn.GetFullPath(), true );
MsgPanel->EraseMsgBox(); ClearMsgPanel();
if( !success ) if( !success )
{ {
msg = _( "Error while saving library file \"" ) + fn.GetFullPath() + msg = _( "Error while saving library file \"" ) + fn.GetFullPath() +
_( "\"." ); _( "\"." );
MsgPanel->AppendMessage( wxT( "*** ERROR: ***" ), msg, RED ); AppendMsgPanel( _( "*** ERROR: ***" ), msg, RED );
DisplayError( this, msg ); DisplayError( this, msg );
} }
else else
...@@ -283,7 +283,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event ) ...@@ -283,7 +283,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
fn.SetExt( DOC_EXT ); fn.SetExt( DOC_EXT );
wxString msg1 = _( "Document file \"" ) + fn.GetFullPath() + wxString msg1 = _( "Document file \"" ) + fn.GetFullPath() +
wxT( "\" Ok" ); wxT( "\" Ok" );
MsgPanel->AppendMessage( msg, msg1, BLUE ); AppendMsgPanel( msg, msg1, BLUE );
} }
} }
...@@ -297,14 +297,14 @@ void WinEDA_LibeditFrame::DisplayCmpDoc() ...@@ -297,14 +297,14 @@ void WinEDA_LibeditFrame::DisplayCmpDoc()
wxString msg; wxString msg;
LIB_ALIAS* alias = NULL; LIB_ALIAS* alias = NULL;
MsgPanel->EraseMsgBox(); ClearMsgPanel();
if( m_library == NULL || m_component == NULL ) if( m_library == NULL || m_component == NULL )
return; return;
msg = m_component->GetName(); msg = m_component->GetName();
MsgPanel->AppendMessage( _( "Part" ), msg, BLUE, 8 ); AppendMsgPanel( _( "Part" ), msg, BLUE, 8 );
if( m_aliasName.IsEmpty() ) if( m_aliasName.IsEmpty() )
{ {
...@@ -316,40 +316,40 @@ void WinEDA_LibeditFrame::DisplayCmpDoc() ...@@ -316,40 +316,40 @@ void WinEDA_LibeditFrame::DisplayCmpDoc()
alias = m_library->FindAlias( m_aliasName ); alias = m_library->FindAlias( m_aliasName );
} }
MsgPanel->AppendMessage( _( "Alias" ), msg, RED, 8 ); AppendMsgPanel( _( "Alias" ), msg, RED, 8 );
static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
msg = UnitLetter[m_unit]; msg = UnitLetter[m_unit];
MsgPanel->AppendMessage( _( "Unit" ), msg, BROWN, 8 ); AppendMsgPanel( _( "Unit" ), msg, BROWN, 8 );
if( m_convert > 1 ) if( m_convert > 1 )
msg = _( "Convert" ); msg = _( "Convert" );
else else
msg = _( "Normal" ); msg = _( "Normal" );
MsgPanel->AppendMessage( _( "Body" ), msg, GREEN, 8 ); AppendMsgPanel( _( "Body" ), msg, GREEN, 8 );
if( m_component->m_Options == ENTRY_POWER ) if( m_component->m_Options == ENTRY_POWER )
msg = _( "Power Symbol" ); msg = _( "Power Symbol" );
else else
msg = _( "Component" ); msg = _( "Component" );
MsgPanel->AppendMessage( _( "Type" ), msg, MAGENTA, 8 ); AppendMsgPanel( _( "Type" ), msg, MAGENTA, 8 );
if( alias != NULL ) if( alias != NULL )
msg = alias->m_Doc; msg = alias->m_Doc;
else else
msg = m_component->m_Doc; msg = m_component->m_Doc;
MsgPanel->AppendMessage( _( "Description" ), msg, CYAN, 8 ); AppendMsgPanel( _( "Description" ), msg, CYAN, 8 );
if( alias != NULL ) if( alias != NULL )
msg = alias->m_KeyWord; msg = alias->m_KeyWord;
else else
msg = m_component->m_KeyWord; msg = m_component->m_KeyWord;
MsgPanel->AppendMessage( _( "Key words" ), msg, DARKDARKGRAY ); AppendMsgPanel( _( "Key words" ), msg, DARKDARKGRAY );
} }
......
...@@ -162,6 +162,8 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father, ...@@ -162,6 +162,8 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
GetScreen()->m_Center = true; GetScreen()->m_Center = true;
LoadSettings(); LoadSettings();
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 );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
if( DrawPanel ) if( DrawPanel )
DrawPanel->m_Block_Enable = true; DrawPanel->m_Block_Enable = true;
ReCreateHToolbar(); ReCreateHToolbar();
......
...@@ -160,17 +160,16 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( EDA_BaseStruct* DrawList ...@@ -160,17 +160,16 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( EDA_BaseStruct* DrawList
if( Entry->GetPartCount() <= 1 ) // One part per package if( Entry->GetPartCount() <= 1 ) // One part per package
{ {
for( Pin = Entry->GetNextPin(); Pin != NULL; LIB_PIN_LIST pins;
Pin = Entry->GetNextPin( Pin ) )
Entry->GetPins( pins, Component->GetUnitSelection( sheet ),
Component->m_Convert );
for( size_t i = 0; i < pins.size(); i++ )
{ {
wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ); Pin = pins[i];
if( Pin->m_Unit wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
&& ( Pin->m_Unit != Component->GetUnitSelection( sheet ) ) )
continue;
if( Pin->m_Convert
&& ( Pin->m_Convert != Component->m_Convert ) )
continue;
AddPinToComponentPinList( Component, sheet, Pin ); AddPinToComponentPinList( Component, sheet, Pin );
} }
......
...@@ -482,7 +482,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event ) ...@@ -482,7 +482,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; return;
m_Parent->MsgPanel->EraseMsgBox(); m_Parent->ClearMsgPanel();
ReAnnotatePowerSymbolsOnly(); ReAnnotatePowerSymbolsOnly();
if( m_Parent->CheckAnnotate( NULL, 0 ) ) if( m_Parent->CheckAnnotate( NULL, 0 ) )
......
...@@ -295,11 +295,13 @@ void WinEDA_SchematicFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -295,11 +295,13 @@ void WinEDA_SchematicFrame::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SELECT_UNIT_MM: case ID_TB_OPTIONS_SELECT_UNIT_MM:
g_UnitMetric = MILLIMETRE; g_UnitMetric = MILLIMETRE;
UpdateStatusBar(); /* Reaffichage des coord curseur */ UpdateStatusBar(); /* Reaffichage des coord curseur */
DrawPanel->Refresh();
break; break;
case ID_TB_OPTIONS_SELECT_UNIT_INCH: case ID_TB_OPTIONS_SELECT_UNIT_INCH:
g_UnitMetric = INCHES; g_UnitMetric = INCHES;
UpdateStatusBar(); /* Reaffichage des coord curseur */ UpdateStatusBar(); /* Reaffichage des coord curseur */
DrawPanel->Refresh();
break; break;
case ID_TB_OPTIONS_SELECT_CURSOR: case ID_TB_OPTIONS_SELECT_CURSOR:
......
...@@ -102,6 +102,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, ...@@ -102,6 +102,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
GetScreen()->m_Center = true; // set to true to have the coordinates origine -0,0) centered on screen GetScreen()->m_Center = true; // set to true to have the coordinates origine -0,0) centered on screen
LoadSettings(); LoadSettings();
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 );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
ReCreateHToolbar(); ReCreateHToolbar();
ReCreateVToolbar(); ReCreateVToolbar();
......
...@@ -310,11 +310,11 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -310,11 +310,11 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( !tmp.IsEmpty() ) if( !tmp.IsEmpty() )
component->m_Name.m_Text = tmp; component->m_Name.m_Text = tmp;
MsgPanel->EraseMsgBox(); ClearMsgPanel();
MsgPanel->AppendMessage( _( "Part" ), component->GetName(), BLUE, 6 ); AppendMsgPanel( _( "Part" ), component->GetName(), BLUE, 6 );
MsgPanel->AppendMessage( _( "Alias" ), msg, RED, 6 ); AppendMsgPanel( _( "Alias" ), msg, RED, 6 );
MsgPanel->AppendMessage( _( "Description" ), entry->m_Doc, CYAN, 6 ); AppendMsgPanel( _( "Description" ), entry->m_Doc, CYAN, 6 );
MsgPanel->AppendMessage( _( "Key words" ), entry->m_KeyWord, DARKDARKGRAY ); AppendMsgPanel( _( "Key words" ), entry->m_KeyWord, DARKDARKGRAY );
DrawPanel->Trace_Curseur( DC ); DrawPanel->Trace_Curseur( DC );
} }
...@@ -58,7 +58,7 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -58,7 +58,7 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
curpos = DrawPanel->CursorRealPosition( Mouse ); curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGrid(); delta = GetScreen()->GetGridSize();
GetScreen()->Scale( delta ); GetScreen()->Scale( delta );
if( delta.x == 0 ) if( delta.x == 0 )
......
...@@ -147,6 +147,7 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, ...@@ -147,6 +147,7 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
LoadSettings(); LoadSettings();
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 );
ActiveScreen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
ReCreateVToolbar(); ReCreateVToolbar();
...@@ -299,9 +300,9 @@ int WinEDA_GerberFrame::BestZoom() ...@@ -299,9 +300,9 @@ int WinEDA_GerberFrame::BestZoom()
GetBoard()->ComputeBoundaryBox(); GetBoard()->ComputeBoundaryBox();
size = DrawPanel->GetClientSize(); size = DrawPanel->GetClientSize();
x = ( (double) GetBoard()->m_BoundaryBox.GetWidth() + x = ( (double) GetBoard()->m_BoundaryBox.GetWidth() +
GetScreen()->GetGrid().x ) / (double) size.x; GetScreen()->GetGridSize().x ) / (double) size.x;
y = ( (double) GetBoard()->m_BoundaryBox.GetHeight() + y = ( (double) GetBoard()->m_BoundaryBox.GetHeight() +
GetScreen()->GetGrid().y ) / (double) size.y; GetScreen()->GetGridSize().y ) / (double) size.y;
GetScreen()->m_Curseur = GetBoard()->m_BoundaryBox.Centre(); GetScreen()->m_Curseur = GetBoard()->m_BoundaryBox.Centre();
return wxRound( MAX( x, y ) * (double)GetScreen()->m_ZoomScalar ); return wxRound( MAX( x, y ) * (double)GetScreen()->m_ZoomScalar );
......
...@@ -25,6 +25,22 @@ class GRID_TYPE ...@@ -25,6 +25,22 @@ class GRID_TYPE
public: public:
int m_Id; int m_Id;
wxRealPoint m_Size; wxRealPoint m_Size;
GRID_TYPE& operator=( const GRID_TYPE& item )
{
if( this != &item )
{
m_Id = item.m_Id;
m_Size = item.m_Size;
}
return *this;
}
const bool operator==( const GRID_TYPE& item ) const
{
return ( m_Size == item.m_Size && m_Id == item.m_Id );
}
}; };
...@@ -57,7 +73,7 @@ public: ...@@ -57,7 +73,7 @@ public:
* navigation dans la hierarchie */ * navigation dans la hierarchie */
bool m_Center; /* fix the coordinate (0,0) position on bool m_Center; /* fix the coordinate (0,0) position on
* screen : if TRUE (0,0) in centered on screen * screen : if TRUE (0,0) in centered on screen
* TRUE: when coordiantaes can be < 0 and * TRUE: when coordinates can be < 0 and
* > 0 all but schematic * > 0 all but schematic
* FALSE: when coordinates can be only >= 0 * FALSE: when coordinates can be only >= 0
* Schematic */ * Schematic */
...@@ -94,11 +110,11 @@ private: ...@@ -94,11 +110,11 @@ private:
char m_FlagModified; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde char m_FlagModified; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde
char m_FlagSave; // indique sauvegarde auto faite char m_FlagSave; // indique sauvegarde auto faite
EDA_BaseStruct* m_CurrentItem; ///< Currently selected object EDA_BaseStruct* m_CurrentItem; ///< Currently selected object
GRID_TYPE m_Grid; ///< Current grid selection.
/* Valeurs du pas de grille et du zoom */ /* Valeurs du pas de grille et du zoom */
public: public:
wxRealPoint m_Grid; /* Current grid. */ GridArray m_GridList;
GridArray m_GridList;
bool m_UserGridIsON; bool m_UserGridIsON;
wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */ wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */
...@@ -137,7 +153,7 @@ public: ...@@ -137,7 +153,7 @@ public:
/** function ClearUndoORRedoList (virtual). /** function ClearUndoORRedoList (virtual).
* this function must remove the aItemCount old commands from aList * this function must remove the aItemCount old commands from aList
* and delete commmands, pickers and picked items if needed * and delete commands, pickers and picked items if needed
* Because picked items must be deleted only if they are not in use, this is a virtual pure * Because picked items must be deleted only if they are not in use, this is a virtual pure
* function that must be created for SCH_SCREEN and PCB_SCREEN * function that must be created for SCH_SCREEN and PCB_SCREEN
* @param aList = the UNDO_REDO_CONTAINER of commands * @param aList = the UNDO_REDO_CONTAINER of commands
...@@ -257,9 +273,30 @@ public: ...@@ -257,9 +273,30 @@ public:
bool SetLastZoom(); /* ajuste le coeff de zoom au max */ bool SetLastZoom(); /* ajuste le coeff de zoom au max */
//----<grid stuff>---------------------------------------------------------- //----<grid stuff>----------------------------------------------------------
wxRealPoint GetGrid(); /* retourne la grille */
/**
* Return the command ID of the currently selected grid.
*
* @return int - Currently selected grid command ID.
*/
int GetGridId();
/**
* Return the grid size of the currently selected grid.
*
* @return wxRealPoint - The currently selected grid size.
*/
wxRealPoint GetGridSize();
/**
* Return the grid object of the currently selected grid.
*
* @return GRID_TYPE - The currently selected grid.
*/
GRID_TYPE GetGrid();
void SetGrid( const wxRealPoint& size ); void SetGrid( const wxRealPoint& size );
void SetGrid( int ); void SetGrid( int id );
void SetGridList( GridArray& sizelist ); void SetGridList( GridArray& sizelist );
void AddGrid( const GRID_TYPE& grid ); void AddGrid( const GRID_TYPE& grid );
void AddGrid( const wxRealPoint& size, int id ); void AddGrid( const wxRealPoint& size, int id );
...@@ -268,11 +305,13 @@ public: ...@@ -268,11 +305,13 @@ public:
/** /**
* Function RefPos * Function RefPos
* returns the reference position, coming from either the mouse position or the * Return the reference position, coming from either the mouse position
* the cursor position. * or the cursor position.
*
* @param useMouse If true, return mouse position, else cursor's. * @param useMouse If true, return mouse position, else cursor's.
*
* @return wxPoint - The reference point, either the mouse position or * @return wxPoint - The reference point, either the mouse position or
* the cursor position. * the cursor position.
*/ */
wxPoint RefPos( bool useMouse ) wxPoint RefPos( bool useMouse )
{ {
......
...@@ -96,7 +96,6 @@ public: ...@@ -96,7 +96,6 @@ public:
void AddMenuZoom( wxMenu* MasterMenu ); void AddMenuZoom( wxMenu* MasterMenu );
bool OnRightClick( wxMouseEvent& event ); bool OnRightClick( wxMouseEvent& event );
void OnPopupGridSelect( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
/** Function CursorRealPosition /** Function CursorRealPosition
......
...@@ -174,11 +174,16 @@ enum main_id ...@@ -174,11 +174,16 @@ enum main_id
ID_POPUP_GRID_LEVEL_5, ID_POPUP_GRID_LEVEL_5,
ID_POPUP_GRID_LEVEL_2, ID_POPUP_GRID_LEVEL_2,
ID_POPUP_GRID_LEVEL_1, // id for last predefined grid in inches ( 0.0001 inch) ID_POPUP_GRID_LEVEL_1, // id for last predefined grid in inches ( 0.0001 inch)
ID_POPUP_GRID_LEVEL_5MM,
ID_POPUP_GRID_LEVEL_2_5MM,
ID_POPUP_GRID_LEVEL_1MM, // id for first predefined grid in mm (1mm) ID_POPUP_GRID_LEVEL_1MM, // id for first predefined grid in mm (1mm)
ID_POPUP_GRID_LEVEL_0_5MM, ID_POPUP_GRID_LEVEL_0_5MM,
ID_POPUP_GRID_LEVEL_0_25MM, ID_POPUP_GRID_LEVEL_0_25MM,
ID_POPUP_GRID_LEVEL_0_2MM, ID_POPUP_GRID_LEVEL_0_2MM,
ID_POPUP_GRID_LEVEL_0_1MM, ID_POPUP_GRID_LEVEL_0_1MM,
ID_POPUP_GRID_LEVEL_0_0_5MM,
ID_POPUP_GRID_LEVEL_0_0_25MM,
ID_POPUP_GRID_LEVEL_0_0_1MM,
ID_POPUP_GRID_USER, ID_POPUP_GRID_USER,
ID_SHEET_SET, ID_SHEET_SET,
......
...@@ -310,24 +310,29 @@ public: ...@@ -310,24 +310,29 @@ public:
* add a picker to handle aItemToCopy * add a picker to handle aItemToCopy
* @param aItemToCopy = the board item modified by the command to undo * @param aItemToCopy = the board item modified by the command to undo
* @param aTypeCommand = command type (see enum UndoRedoOpType) * @param aTypeCommand = command type (see enum UndoRedoOpType)
* @param aTransformPoint = the reference point of the transformation, for commands like move * @param aTransformPoint = the reference point of the transformation, for
* commands like move
*/ */
virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy, UndoRedoOpType aTypeCommand, virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0; UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
/** Function SaveCopyInUndoList (virtual pure, overloaded). /** Function SaveCopyInUndoList (virtual pure, overloaded).
* Creates a new entry in undo list of commands. * Creates a new entry in undo list of commands.
* add a list of pickers to handle a list of items * add a list of pickers to handle a list of items
* @param aItemsList = the list of items modified by the command to undo * @param aItemsList = the list of items modified by the command to undo
* @param aTypeCommand = command type (see enum UndoRedoOpType) * @param aTypeCommand = command type (see enum UndoRedoOpType)
* @param aTransformPoint = the reference point of the transformation, for commands like move * @param aTransformPoint = the reference point of the transformation,
* for commands like move
*/ */
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand, virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0; UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
// layerhandling: // layerhandling:
// (See pcbnew/sel_layer.cpp for description of why null_layer parameter is provided) // (See pcbnew/sel_layer.cpp for description of why null_layer parameter
// is provided)
int SelectLayer( int default_layer, int min_layer, int max_layer, int SelectLayer( int default_layer, int min_layer, int max_layer,
bool null_layer = false ); bool null_layer = false );
void SelectLayerPair(); void SelectLayerPair();
...@@ -336,7 +341,28 @@ public: ...@@ -336,7 +341,28 @@ public:
// divers // divers
void InstallGridFrame( const wxPoint& pos ); void InstallGridFrame( const wxPoint& pos );
/**
* Load applications settings common to PCB draw frame objects.
*
* This overrides the base class WinEDA_DrawFrame::LoadSettings() to
* handle settings common to the PCB layout application and footprint
* editor main windows. It calls down to the base class to load
* settings common to all drawing frames. Please put your application
* settings common to all pcb drawing frames here to avoid having
* application settings loaded all over the place.
*/
virtual void LoadSettings(); virtual void LoadSettings();
/**
* Save applications settings common to PCB draw frame objects.
*
* This overrides the base class WinEDA_DrawFrame::SaveSettings() to
* save settings common to the PCB layout application and footprint
* editor main windows. It calls down to the base class to save
* settings common to all drawing frames. Please put your application
* settings common to all pcb drawing frames here to avoid having
* application settings saved all over the place.
*/
virtual void SaveSettings(); virtual void SaveSettings();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
......
...@@ -58,6 +58,8 @@ public: ...@@ -58,6 +58,8 @@ public:
wxTextCtrl* m_NetClassSelectedBox; // a text ctrl to display the current NetClass wxTextCtrl* m_NetClassSelectedBox; // a text ctrl to display the current NetClass
bool m_TrackAndViasSizesList_Changed; bool m_TrackAndViasSizesList_Changed;
bool m_show_microwave_tools;
private: private:
DRC* m_drc; ///< the DRC controller, see drc.cpp DRC* m_drc; ///< the DRC controller, see drc.cpp
...@@ -670,6 +672,28 @@ public: ...@@ -670,6 +672,28 @@ public:
void Begin_Self( wxDC* DC ); void Begin_Self( wxDC* DC );
MODULE* Genere_Self( wxDC* DC ); MODULE* Genere_Self( wxDC* DC );
/**
* Load applications settings specific to the PCBNew.
*
* This overrides the base class WinEDA_BasePcbFrame::LoadSettings() to
* handle settings specific common to the PCB layout application. It
* calls down to the base class to load settings common to all PCB type
* drawing frames. Please put your application settings for PCBNew here
* to avoid having application settings loaded all over the place.
*/
virtual void LoadSettings();
/**
* Save applications settings common to PCB draw frame objects.
*
* This overrides the base class WinEDA_BasePcbFrame::SaveSettings() to
* save settings specific to the PCB layout application main window. It
* calls down to the base class to save settings common to all PCB type
* drawing frames. Please put your application settings for PCBNew here
* to avoid having application settings saved all over the place.
*/
virtual void SaveSettings();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
...@@ -712,7 +736,6 @@ public: ...@@ -712,7 +736,6 @@ public:
void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct ); void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
void Show3D_Frame( wxCommandEvent& event ); void Show3D_Frame( wxCommandEvent& event );
void GeneralControle( wxDC* DC, wxPoint Mouse ); void GeneralControle( wxDC* DC, wxPoint Mouse );
virtual void OnSelectGrid( wxCommandEvent& event );
void LoadModuleFromBoard( wxCommandEvent& event ); void LoadModuleFromBoard( wxCommandEvent& event );
// BOARD handling // BOARD handling
......
...@@ -172,6 +172,9 @@ public: ...@@ -172,6 +172,9 @@ public:
*/ */
wxPoint m_Auxiliary_Axis_Position; /* position of the auxiliary axis */ wxPoint m_Auxiliary_Axis_Position; /* position of the auxiliary axis */
protected:
int m_LastGridSizeId;
private: private:
BASE_SCREEN* m_CurrentScreen; ///< current used SCREEN BASE_SCREEN* m_CurrentScreen; ///< current used SCREEN
...@@ -215,6 +218,16 @@ public: ...@@ -215,6 +218,16 @@ public:
virtual void SetToolID( int id, int new_cursor_id, virtual void SetToolID( int id, int new_cursor_id,
const wxString& title ); const wxString& title );
/**
* Command event handler for selecting grid sizes.
*
* All commands that set the grid size should eventually end up here.
* This is where the application setting is saved. If you override
* this method, make sure you call down to the base class.
*
* @param event - Command event passed by selecting grid size from the
* grid size combobox on the toolbar.
*/
virtual void OnSelectGrid( wxCommandEvent& event ); virtual void OnSelectGrid( wxCommandEvent& event );
virtual void OnSelectZoom( wxCommandEvent& event ); virtual void OnSelectZoom( wxCommandEvent& event );
...@@ -297,6 +310,26 @@ public: ...@@ -297,6 +310,26 @@ public:
virtual void LoadSettings(); virtual void LoadSettings();
virtual void SaveSettings(); virtual void SaveSettings();
/**
* Append a message to the message panel.
*
* This helper method checks to make sure the message panel exists in
* the frame and appends a message to it using the message panel
* AppendMessage() method.
*
* @param textUpper - The message upper text.
* @param textLower - The message lower text.
* @param color - A color ID from the Kicad color list (see colors.h).
* @param pad - Number of spaces to pad between messages (default = 4).
*/
void AppendMsgPanel( const wxString& textUpper, const wxString& textLower,
int color, int pad = 6 );
/**
* Clear all messages from the message panel.
*/
void ClearMsgPanel( void );
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
}; };
...@@ -404,7 +437,7 @@ public: ...@@ -404,7 +437,7 @@ public:
* @param pad - Number of spaces to pad between messages (default = 4). * @param pad - Number of spaces to pad between messages (default = 4).
*/ */
void AppendMessage( const wxString& textUpper, const wxString& textLower, void AppendMessage( const wxString& textUpper, const wxString& textLower,
int color, int pad = 4 ); int color, int pad = 6 );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
......
...@@ -203,7 +203,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( wxDC* DC, bool PlaceModulesHorsPcb ) ...@@ -203,7 +203,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( wxDC* DC, bool PlaceModulesHorsPcb )
MODULE* Module; MODULE* Module;
wxPoint start, current; wxPoint start, current;
int Ymax_size, Xsize_allowed; int Ymax_size, Xsize_allowed;
int pas_grille = (int)GetScreen()->GetGrid().x; int pas_grille = (int)GetScreen()->GetGridSize().x;
bool EdgeExists; bool EdgeExists;
float surface; float surface;
......
...@@ -117,7 +117,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ...@@ -117,7 +117,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC
lay_tmp_TOP = Route_Layer_TOP; lay_tmp_TOP = Route_Layer_TOP;
OldPasRoute = g_GridRoutingSize; OldPasRoute = g_GridRoutingSize;
g_GridRoutingSize = (int)GetScreen()->GetGrid().x; g_GridRoutingSize = (int)GetScreen()->GetGridSize().x;
// Ensure g_GridRoutingSize has a reasonnable value: // Ensure g_GridRoutingSize has a reasonnable value:
if( g_GridRoutingSize < 10 ) if( g_GridRoutingSize < 10 )
......
...@@ -133,7 +133,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) ...@@ -133,7 +133,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
start = time( NULL ); start = time( NULL );
/* Calcul du pas de routage fixe a 5 mils et plus */ /* Calcul du pas de routage fixe a 5 mils et plus */
g_GridRoutingSize = (int)GetScreen()->GetGrid().x; g_GridRoutingSize = (int)GetScreen()->GetGridSize().x;
if( g_GridRoutingSize < 50 ) if( g_GridRoutingSize < 50 )
g_GridRoutingSize = 50; g_GridRoutingSize = 50;
E_scale = g_GridRoutingSize / 50; if( E_scale < 1 ) E_scale = g_GridRoutingSize / 50; if( E_scale < 1 )
......
...@@ -70,7 +70,6 @@ WinEDA_BasePcbFrame::WinEDA_BasePcbFrame( wxWindow* father, ...@@ -70,7 +70,6 @@ WinEDA_BasePcbFrame::WinEDA_BasePcbFrame( wxWindow* father,
m_UserGridSize = wxRealPoint( 100.0, 100.0 ); m_UserGridSize = wxRealPoint( 100.0, 100.0 );
m_UserGridUnits = INCHES; m_UserGridUnits = INCHES;
m_Collector = new GENERAL_COLLECTOR(); m_Collector = new GENERAL_COLLECTOR();
} }
......
...@@ -28,32 +28,37 @@ static const int PcbZoomList[] = ...@@ -28,32 +28,37 @@ static const int PcbZoomList[] =
}; };
#define PCB_ZOOM_LIST_CNT ( sizeof( PcbZoomList ) / sizeof( int ) ) #define PCB_ZOOM_LIST_CNT ( sizeof( PcbZoomList ) / sizeof( int ) )
#define MM_TO_PCB_UNITS 10000.0 / 25.4000508001016
/* Default grid sizes for PCB editor screens. */ /* Default grid sizes for PCB editor screens. */
#define MM_TO_PCB_UNITS 10000.0 / 25.4
static GRID_TYPE PcbGridList[] = static GRID_TYPE PcbGridList[] =
{ {
// predefined grid list in 0.0001 inches // predefined grid list in 0.0001 inches
{ ID_POPUP_GRID_LEVEL_1000, wxRealPoint( 1000, 1000 ) }, { ID_POPUP_GRID_LEVEL_1000, wxRealPoint( 1000, 1000 ) },
{ ID_POPUP_GRID_LEVEL_500, wxRealPoint( 500, 500 ) }, { ID_POPUP_GRID_LEVEL_500, wxRealPoint( 500, 500 ) },
{ ID_POPUP_GRID_LEVEL_250, wxRealPoint( 250, 250 ) }, { ID_POPUP_GRID_LEVEL_250, wxRealPoint( 250, 250 ) },
{ ID_POPUP_GRID_LEVEL_200, wxRealPoint( 200, 200 ) }, { ID_POPUP_GRID_LEVEL_200, wxRealPoint( 200, 200 ) },
{ ID_POPUP_GRID_LEVEL_100, wxRealPoint( 100, 100 ) }, { ID_POPUP_GRID_LEVEL_100, wxRealPoint( 100, 100 ) },
{ ID_POPUP_GRID_LEVEL_50, wxRealPoint( 50, 50 ) }, { ID_POPUP_GRID_LEVEL_50, wxRealPoint( 50, 50 ) },
{ ID_POPUP_GRID_LEVEL_25, wxRealPoint( 25, 25 ) }, { ID_POPUP_GRID_LEVEL_25, wxRealPoint( 25, 25 ) },
{ ID_POPUP_GRID_LEVEL_20, wxRealPoint( 20, 20 ) }, { ID_POPUP_GRID_LEVEL_20, wxRealPoint( 20, 20 ) },
{ ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) }, { ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) },
{ ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) }, { ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) },
{ ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) }, { ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) },
{ ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) }, { ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) },
// predefined grid list in mm // predefined grid list in mm
{ ID_POPUP_GRID_LEVEL_1MM, wxRealPoint( MM_TO_PCB_UNITS, MM_TO_PCB_UNITS ) }, { ID_POPUP_GRID_LEVEL_5MM, wxRealPoint( MM_TO_PCB_UNITS * 5.0, MM_TO_PCB_UNITS * 5.0 ) },
{ ID_POPUP_GRID_LEVEL_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.5, MM_TO_PCB_UNITS * 0.5 ) }, { ID_POPUP_GRID_LEVEL_2_5MM, wxRealPoint( MM_TO_PCB_UNITS * 2.5, MM_TO_PCB_UNITS * 2.5 ) },
{ ID_POPUP_GRID_LEVEL_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.25, MM_TO_PCB_UNITS * 0.25 ) }, { ID_POPUP_GRID_LEVEL_1MM, wxRealPoint( MM_TO_PCB_UNITS, MM_TO_PCB_UNITS ) },
{ ID_POPUP_GRID_LEVEL_0_2MM, wxRealPoint( MM_TO_PCB_UNITS * 0.2, MM_TO_PCB_UNITS * 0.2 ) }, { ID_POPUP_GRID_LEVEL_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.5, MM_TO_PCB_UNITS * 0.5 ) },
{ ID_POPUP_GRID_LEVEL_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.1, MM_TO_PCB_UNITS * 0.1 ) } { ID_POPUP_GRID_LEVEL_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.25, MM_TO_PCB_UNITS * 0.25 ) },
{ ID_POPUP_GRID_LEVEL_0_2MM, wxRealPoint( MM_TO_PCB_UNITS * 0.2, MM_TO_PCB_UNITS * 0.2 ) },
{ ID_POPUP_GRID_LEVEL_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.1, MM_TO_PCB_UNITS * 0.1 ) },
{ ID_POPUP_GRID_LEVEL_0_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.05, MM_TO_PCB_UNITS * 0.05 ) },
{ ID_POPUP_GRID_LEVEL_0_0_25MM, wxRealPoint( MM_TO_PCB_UNITS * 0.025, MM_TO_PCB_UNITS * 0.025 ) },
{ ID_POPUP_GRID_LEVEL_0_0_1MM, wxRealPoint( MM_TO_PCB_UNITS * 0.01, MM_TO_PCB_UNITS * 0.01 ) }
}; };
#define PCB_GRID_LIST_CNT ( sizeof( PcbGridList ) / sizeof( GRID_TYPE ) ) #define PCB_GRID_LIST_CNT ( sizeof( PcbGridList ) / sizeof( GRID_TYPE ) )
......
...@@ -261,7 +261,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -261,7 +261,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
curpos = DrawPanel->CursorRealPosition( Mouse ); curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGrid(); delta = GetScreen()->GetGridSize();
GetScreen()->Scale( delta ); GetScreen()->Scale( delta );
if( delta.x <= 0 ) if( delta.x <= 0 )
...@@ -326,10 +326,10 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -326,10 +326,10 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
PutOnGrid( &on_grid ); PutOnGrid( &on_grid );
wxSize grid; wxSize grid;
grid.x = (int) GetScreen()->GetGrid().x; grid.x = (int) GetScreen()->GetGridSize().x;
grid.y = (int) GetScreen()->GetGrid().y; grid.y = (int) GetScreen()->GetGridSize().y;
if( Magnetize(m_Pcb, (WinEDA_PcbFrame *) this, m_ID_current_state, if( Magnetize(m_Pcb, (WinEDA_PcbFrame *) this, m_ID_current_state,
grid, on_grid, &curpos) ) grid, on_grid, &curpos) )
{ {
GetScreen()->m_Curseur = curpos; GetScreen()->m_Curseur = curpos;
} }
......
...@@ -310,9 +310,9 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC ) ...@@ -310,9 +310,9 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
return false; return false;
} }
pas_45 = (int) GetScreen()->GetGrid().x / 2; pas_45 = (int) GetScreen()->GetGridSize().x / 2;
if( pas_45 < curTrack->m_Width ) if( pas_45 < curTrack->m_Width )
pas_45 = (int) GetScreen()->GetGrid().x; pas_45 = (int) GetScreen()->GetGridSize().x;
while( pas_45 < curTrack->m_Width ) while( pas_45 < curTrack->m_Width )
pas_45 *= 2; pas_45 *= 2;
......
...@@ -170,7 +170,7 @@ bool WinEDA_PcbFrame::Clear_Pcb( bool aQuery ) ...@@ -170,7 +170,7 @@ bool WinEDA_PcbFrame::Clear_Pcb( bool aQuery )
GetScreen()->m_FileName.Empty(); GetScreen()->m_FileName.Empty();
/* Init new grid size */ /* Init new grid size */
wxRealPoint gridsize = GetScreen()->GetGrid(); wxRealPoint gridsize = GetScreen()->GetGridSize();
GetScreen()->Init(); GetScreen()->Init();
GetScreen()->SetGrid( gridsize ); GetScreen()->SetGrid( gridsize );
...@@ -218,7 +218,7 @@ bool WinEDA_ModuleEditFrame::Clear_Pcb( bool aQuery ) ...@@ -218,7 +218,7 @@ bool WinEDA_ModuleEditFrame::Clear_Pcb( bool aQuery )
SetCurItem( NULL ); SetCurItem( NULL );
/* Init parametres de gestion */ /* Init parametres de gestion */
wxRealPoint gridsize = GetScreen()->GetGrid(); wxRealPoint gridsize = GetScreen()->GetGridSize();
GetScreen()->Init(); GetScreen()->Init();
GetScreen()->SetGrid( gridsize ); GetScreen()->SetGrid( gridsize );
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
#include "3d_viewer.h" #include "3d_viewer.h"
// Keys used in read/write config
#define MODEDIT_CURR_GRID wxT( "ModEditCurrGrid" )
// local variables: // local variables:
static PCB_SCREEN* s_screenModule = NULL; // the PCB_SCREEN used by the footprint editor static PCB_SCREEN* s_screenModule = NULL; // the PCB_SCREEN used by the footprint editor
...@@ -36,8 +34,8 @@ EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ...@@ -36,8 +34,8 @@ EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START,
EVT_CLOSE( WinEDA_ModuleEditFrame::OnCloseWindow ) EVT_CLOSE( WinEDA_ModuleEditFrame::OnCloseWindow )
EVT_SIZE( WinEDA_ModuleEditFrame::OnSize ) EVT_SIZE( WinEDA_ModuleEditFrame::OnSize )
EVT_KICAD_CHOICEBOX( ID_ON_ZOOM_SELECT, WinEDA_PcbFrame::OnSelectZoom ) EVT_KICAD_CHOICEBOX( ID_ON_ZOOM_SELECT, WinEDA_ModuleEditFrame::OnSelectZoom )
EVT_KICAD_CHOICEBOX( ID_ON_GRID_SELECT, WinEDA_PcbFrame::OnSelectGrid ) EVT_KICAD_CHOICEBOX( ID_ON_GRID_SELECT, WinEDA_ModuleEditFrame::OnSelectGrid )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_ModuleEditFrame::OnZoom ) EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_ModuleEditFrame::OnZoom )
...@@ -156,8 +154,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, ...@@ -156,8 +154,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
WinEDA_BasePcbFrame( father, MODULE_EDITOR_FRAME, WinEDA_BasePcbFrame( father, MODULE_EDITOR_FRAME,
wxEmptyString, pos, size, style ) wxEmptyString, pos, size, style )
{ {
wxConfig* config = wxGetApp().m_EDA_Config;
m_FrameName = wxT( "ModEditFrame" ); m_FrameName = wxT( "ModEditFrame" );
m_Draw_Sheet_Ref = false; // true to show the frame references m_Draw_Sheet_Ref = false; // true to show the frame references
m_Draw_Axis = true; // true to show X and Y axis on screen m_Draw_Axis = true; // true to show X and Y axis on screen
...@@ -181,6 +177,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, ...@@ -181,6 +177,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
LoadSettings(); LoadSettings();
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
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();
...@@ -189,13 +186,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, ...@@ -189,13 +186,6 @@ 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;
} }
...@@ -222,8 +212,6 @@ WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame() ...@@ -222,8 +212,6 @@ WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame()
void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event ) void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event )
/**************************************************************/ /**************************************************************/
{ {
wxConfig* config = wxGetApp().m_EDA_Config;
if( GetScreen()->IsModify() ) if( GetScreen()->IsModify() )
{ {
if( !IsOK( this, _( "Module Editor: Module modified! Continue?" ) ) ) if( !IsOK( this, _( "Module Editor: Module modified! Continue?" ) ) )
...@@ -233,19 +221,12 @@ void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -233,19 +221,12 @@ void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event )
} }
SaveSettings(); SaveSettings();
if( config )
{
config->Write( MODEDIT_CURR_GRID, m_SelGridBox->GetSelection() );
}
Destroy(); Destroy();
} }
/*********************************************/
void WinEDA_ModuleEditFrame::SetToolbars() void WinEDA_ModuleEditFrame::SetToolbars()
/*********************************************/
{ {
size_t i;
bool active, islib = TRUE; bool active, islib = TRUE;
WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) wxGetApp().GetTopWindow(); WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) wxGetApp().GetTopWindow();
...@@ -382,19 +363,10 @@ void WinEDA_ModuleEditFrame::SetToolbars() ...@@ -382,19 +363,10 @@ void WinEDA_ModuleEditFrame::SetToolbars()
m_SelZoomBox->SetSelection( -1 ); m_SelZoomBox->SetSelection( -1 );
} }
if( m_SelGridBox && GetScreen() ) if( m_SelGridBox )
{ {
int kk = m_SelGridBox->GetChoice(); m_SelGridBox->SetSelection( ID_POPUP_GRID_LEVEL_1000 +
for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ ) m_LastGridSizeId );
{
if( ( GetScreen()->GetGrid() == GetScreen()->m_GridList[i].m_Size ) )
{
if( kk != (int) i )
m_SelGridBox->SetSelection( (int) i );
kk = (int) i;
break;
}
}
} }
} }
...@@ -441,7 +413,7 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -441,7 +413,7 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
curpos = DrawPanel->CursorRealPosition( Mouse ); curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGrid(); delta = GetScreen()->GetGridSize();
GetScreen()->Scale( delta ); GetScreen()->Scale( delta );
if( delta.x == 0 ) if( delta.x == 0 )
...@@ -514,26 +486,3 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -514,26 +486,3 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
SetToolbars(); SetToolbars();
UpdateStatusBar(); /* Affichage des coord curseur */ UpdateStatusBar(); /* Affichage des coord curseur */
} }
/*****************************************************************/
void WinEDA_ModuleEditFrame::OnSelectGrid( wxCommandEvent& event )
/******************************************************************/
// Virtual function
{
if( m_SelGridBox == NULL )
return; // Should not occurs
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER );
WinEDA_DrawFrame::OnSelectGrid( event );
// If the user grid is the current selection , ensure grid size value = new user grid value
int ii = m_SelGridBox->GetSelection();
if( ii == (int) ( m_SelGridBox->GetCount() - 1 ) )
{
GetScreen()->SetGrid( ID_POPUP_GRID_USER );
DrawPanel->Refresh();
}
}
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "dialog_design_rules.h" #include "dialog_design_rules.h"
// Keys used in read/write config // Keys used in read/write config
#define PCB_CURR_GRID wxT( "PcbCurrGrid" )
#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" )
...@@ -220,8 +219,6 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, ...@@ -220,8 +219,6 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
long style ) : long style ) :
WinEDA_BasePcbFrame( father, PCB_FRAME, title, pos, size, style ) WinEDA_BasePcbFrame( father, PCB_FRAME, title, pos, size, style )
{ {
wxConfig* config = wxGetApp().m_EDA_Config;
m_FrameName = wxT( "PcbFrame" ); m_FrameName = wxT( "PcbFrame" );
m_Draw_Sheet_Ref = true; // true to display sheet references m_Draw_Sheet_Ref = true; // true to display sheet references
m_Draw_Auxiliary_Axis = true; m_Draw_Auxiliary_Axis = true;
...@@ -229,6 +226,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, ...@@ -229,6 +226,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
m_SelViaSizeBox = NULL; m_SelViaSizeBox = NULL;
m_SelLayerBox = NULL; m_SelLayerBox = NULL;
m_TrackAndViasSizesList_Changed = false; m_TrackAndViasSizesList_Changed = false;
m_show_microwave_tools = false;
SetBoard( new BOARD( NULL, this ) ); SetBoard( new BOARD( NULL, this ) );
m_TrackAndViasSizesList_Changed = true; m_TrackAndViasSizesList_Changed = true;
...@@ -251,16 +249,8 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, ...@@ -251,16 +249,8 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
LoadSettings(); LoadSettings();
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 ); // Default current grid size
if( config )
{
config->Read( PCB_MAGNETIC_PADS_OPT, &g_MagneticPadOption );
config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption );
}
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER );
GetScreen()->SetGrid( GridSize ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
if( DrawPanel ) if( DrawPanel )
DrawPanel->m_Block_Enable = true; DrawPanel->m_Block_Enable = true;
...@@ -268,17 +258,10 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, ...@@ -268,17 +258,10 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
ReCreateHToolbar(); ReCreateHToolbar();
ReCreateAuxiliaryToolbar(); ReCreateAuxiliaryToolbar();
ReCreateVToolbar(); ReCreateVToolbar();
if( config )
{
long gridselection = 1;
config->Read( PCB_CURR_GRID, &gridselection );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + gridselection );
long display_microwave_tools = 0;
config->Read( SHOW_MICROWAVE_TOOLS, &display_microwave_tools );
if( display_microwave_tools )
ReCreateAuxVToolbar();
}
ReCreateOptToolbar(); ReCreateOptToolbar();
if( m_show_microwave_tools )
ReCreateAuxVToolbar();
} }
...@@ -297,8 +280,6 @@ WinEDA_PcbFrame::~WinEDA_PcbFrame() ...@@ -297,8 +280,6 @@ WinEDA_PcbFrame::~WinEDA_PcbFrame()
void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event ) void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
/********************************************************/ /********************************************************/
{ {
wxConfig* config = wxGetApp().m_EDA_Config;
DrawPanel->m_AbortRequest = true; DrawPanel->m_AbortRequest = true;
if( ScreenPcb->IsModify() ) if( ScreenPcb->IsModify() )
...@@ -327,17 +308,7 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -327,17 +308,7 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
} }
} }
SaveSettings(); SaveSettings();
if( config )
{
wxRealPoint GridSize = GetScreen()->GetGrid();
config->Write( PCB_CURR_GRID, m_SelGridBox->GetSelection() );
config->Write( PCB_MAGNETIC_PADS_OPT, (long) g_MagneticPadOption );
config->Write( PCB_MAGNETIC_TRACKS_OPT, (long) g_MagneticTrackOption );
config->Write( SHOW_MICROWAVE_TOOLS, (long) m_AuxVToolBar ? 1 : 0 );
}
// do not show the window because ScreenPcb will be deleted and we do not want any paint event // do not show the window because ScreenPcb will be deleted and we do not want any paint event
Show( false ); Show( false );
...@@ -376,3 +347,35 @@ void WinEDA_PcbFrame::ShowDesignRulesEditor( wxCommandEvent& event ) ...@@ -376,3 +347,35 @@ void WinEDA_PcbFrame::ShowDesignRulesEditor( wxCommandEvent& event )
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
} }
void WinEDA_PcbFrame::LoadSettings()
{
wxConfig* config = wxGetApp().m_EDA_Config;
if( config == NULL )
return;
WinEDA_BasePcbFrame::LoadSettings();
config->Read( PCB_MAGNETIC_PADS_OPT, &g_MagneticPadOption );
config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption );
config->Read( SHOW_MICROWAVE_TOOLS, &m_show_microwave_tools );
}
void WinEDA_PcbFrame::SaveSettings()
{
wxConfig* config = wxGetApp().m_EDA_Config;
if( config == NULL )
return;
WinEDA_BasePcbFrame::SaveSettings();
wxRealPoint GridSize = GetScreen()->GetGridSize();
config->Write( PCB_MAGNETIC_PADS_OPT, (long) g_MagneticPadOption );
config->Write( PCB_MAGNETIC_TRACKS_OPT, (long) g_MagneticTrackOption );
config->Write( SHOW_MICROWAVE_TOOLS, ( m_AuxVToolBar ) ? true : false );
}
...@@ -233,11 +233,13 @@ void WinEDA_ModuleEditFrame::ReCreateOptToolbar() ...@@ -233,11 +233,13 @@ void WinEDA_ModuleEditFrame::ReCreateOptToolbar()
wxBitmap( via_sketch_xpm ), wxBitmap( via_sketch_xpm ),
_( "Show Vias Sketch" ) ); _( "Show Vias Sketch" ) );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
wxEmptyString,
wxBitmap( text_sketch_xpm ), wxBitmap( text_sketch_xpm ),
_( "Show Texts Sketch" ) ); _( "Show Texts Sketch" ) );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH,
wxEmptyString,
wxBitmap( show_mod_edge_xpm ), wxBitmap( show_mod_edge_xpm ),
_( "Show Edges Sketch" ) ); _( "Show Edges Sketch" ) );
...@@ -280,12 +282,14 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar() ...@@ -280,12 +282,14 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
for( int i = 0; i < (int)GetScreen()->m_ZoomList.GetCount(); i++ ) for( int i = 0; i < (int)GetScreen()->m_ZoomList.GetCount(); i++ )
{ {
msg = _( "Zoom " ); msg = _( "Zoom " );
if ( (GetScreen()->m_ZoomList[i] % GetScreen()->m_ZoomScalar) == 0 ) if ( GetScreen()->m_ZoomList[i] % GetScreen()->m_ZoomScalar == 0 )
msg << GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar; msg << GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar;
else else
{ {
wxString value; wxString value;
value.Printf(wxT("%.1f"),(float)GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar ); value.Printf( wxT( "%.1f" ),
(float)GetScreen()->m_ZoomList[i] /
GetScreen()->m_ZoomScalar );
msg += value; msg += value;
} }
m_SelZoomBox->Append( msg ); m_SelZoomBox->Append( msg );
...@@ -293,8 +297,8 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar() ...@@ -293,8 +297,8 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
m_AuxiliaryToolBar->AddControl( m_SelZoomBox ); m_AuxiliaryToolBar->AddControl( m_SelZoomBox );
// after adding the buttons to the toolbar, must call Realize() to reflect // after adding the buttons to the toolbar, must call Realize() to
// the changes // reflect the changes
m_AuxiliaryToolBar->Realize(); m_AuxiliaryToolBar->Realize();
} }
...@@ -317,7 +321,11 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar() ...@@ -317,7 +321,11 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
msg = _( "User Grid" ); msg = _( "User Grid" );
} }
m_SelGridBox->Append( msg ); m_SelGridBox->Append( msg, (void*) &GetScreen()->m_GridList[i].m_Id );
if( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ==
GetScreen()->m_GridList[i].m_Id )
m_SelGridBox->SetSelection( i );
} }
SetToolbars(); SetToolbars();
......
...@@ -59,7 +59,7 @@ static const char s_BitmapLayerIcon[16][16] = { ...@@ -59,7 +59,7 @@ static const char s_BitmapLayerIcon[16][16] = {
void WinEDA_PcbFrame::PrepareLayerIndicator() void WinEDA_PcbFrame::PrepareLayerIndicator()
/************************************************************/ /************************************************************/
/* Draw the icon for the "Select layet pair" bitmap tool /* Draw the icon for the "Select layer pair" bitmap tool
*/ */
{ {
int ii, jj; int ii, jj;
...@@ -99,7 +99,7 @@ void WinEDA_PcbFrame::PrepareLayerIndicator() ...@@ -99,7 +99,7 @@ void WinEDA_PcbFrame::PrepareLayerIndicator()
if( !change && (LayerPairBitmap != NULL) ) if( !change && (LayerPairBitmap != NULL) )
return; return;
/* Creat the bitmap too and its Memory DC, if not already made */ /* Create the bitmap too and its Memory DC, if not already made */
if( LayerPairBitmap == NULL ) if( LayerPairBitmap == NULL )
{ {
LayerPairBitmap = new wxBitmap( 16, 16 ); LayerPairBitmap = new wxBitmap( 16, 16 );
...@@ -276,7 +276,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar() ...@@ -276,7 +276,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
ReCreateLayerBox( m_HToolBar ); ReCreateLayerBox( m_HToolBar );
PrepareLayerIndicator(); // Initialise the bitmap with current active layer colors for the next tool PrepareLayerIndicator(); // Initialize the bitmap with current active layer colors for the next tool
m_HToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString, m_HToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString,
*LayerPairBitmap, SEL_LAYER_HELP ); *LayerPairBitmap, SEL_LAYER_HELP );
...@@ -495,7 +495,7 @@ void WinEDA_PcbFrame::ReCreateVToolbar() ...@@ -495,7 +495,7 @@ void WinEDA_PcbFrame::ReCreateVToolbar()
void WinEDA_PcbFrame::ReCreateAuxVToolbar() void WinEDA_PcbFrame::ReCreateAuxVToolbar()
/*********************************************/ /*********************************************/
/* Create the auxiliary vertical right toolbar, showing tools fo microwave applications /* Create the auxiliary vertical right toolbar, showing tools for microwave applications
*/ */
{ {
if( m_AuxVToolBar ) if( m_AuxVToolBar )
...@@ -566,6 +566,7 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar() ...@@ -566,6 +566,7 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
wxPoint( -1, -1 ), wxPoint( -1, -1 ),
wxSize( LISTBOX_WIDTH + 10, -1 ) ); wxSize( LISTBOX_WIDTH + 10, -1 ) );
m_AuxiliaryToolBar->AddControl( m_SelTrackWidthBox ); m_AuxiliaryToolBar->AddControl( m_SelTrackWidthBox );
m_AuxiliaryToolBar->AddSeparator();
// Creates box to display and choose vias diameters: // Creates box to display and choose vias diameters:
m_SelViaSizeBox = new WinEDAChoiceBox( m_AuxiliaryToolBar, m_SelViaSizeBox = new WinEDAChoiceBox( m_AuxiliaryToolBar,
...@@ -573,32 +574,33 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar() ...@@ -573,32 +574,33 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
wxPoint( -1, -1 ), wxPoint( -1, -1 ),
wxSize( LISTBOX_WIDTH + 10, -1 ) ); wxSize( LISTBOX_WIDTH + 10, -1 ) );
m_AuxiliaryToolBar->AddControl( m_SelViaSizeBox ); m_AuxiliaryToolBar->AddControl( m_SelViaSizeBox );
m_AuxiliaryToolBar->AddSeparator();
// Creates box to display tracks and vias clearance: // Creates box to display tracks and vias clearance:
m_ClearanceBox = new wxTextCtrl( m_AuxiliaryToolBar, m_ClearanceBox = new wxTextCtrl( m_AuxiliaryToolBar, -1,
-1, wxEmptyString, wxPoint( -1, -1 ),
wxEmptyString, wxSize( LISTBOX_WIDTH + 20, -1 ),
wxPoint( -1, -1 ), wxTE_READONLY );
wxSize( LISTBOX_WIDTH + 20, -1 ),
wxTE_READONLY );
m_AuxiliaryToolBar->AddControl( m_ClearanceBox );
m_ClearanceBox->SetToolTip(_("Current NetClass clearance value") ); m_ClearanceBox->SetToolTip(_("Current NetClass clearance value") );
m_AuxiliaryToolBar->AddControl( m_ClearanceBox );
m_AuxiliaryToolBar->AddSeparator();
// Creates box to display the current NetClass: // Creates box to display the current NetClass:
m_NetClassSelectedBox = new wxTextCtrl( m_AuxiliaryToolBar, m_NetClassSelectedBox = new wxTextCtrl( m_AuxiliaryToolBar, -1,
-1, wxEmptyString, wxPoint( -1, -1 ),
wxEmptyString, wxSize( LISTBOX_WIDTH, -1 ),
wxPoint( -1, -1 ), wxTE_READONLY );
wxSize( LISTBOX_WIDTH, -1 ),
wxTE_READONLY );
m_AuxiliaryToolBar->AddControl( m_NetClassSelectedBox );
m_NetClassSelectedBox->SetToolTip(_("Name of the current NetClass") ); m_NetClassSelectedBox->SetToolTip(_("Name of the current NetClass") );
m_AuxiliaryToolBar->AddControl( m_NetClassSelectedBox );
m_AuxiliaryToolBar->AddSeparator();
// Creates box to display and choose strategy to handle tracks an vias sizes: // Creates box to display and choose strategy to handle tracks an
// vias sizes:
m_AuxiliaryToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, m_AuxiliaryToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH,
wxEmptyString, wxEmptyString,
wxBitmap( auto_track_width_xpm ), wxBitmap( auto_track_width_xpm ),
_( "Auto track width: when starting on an existing track use its width\notherwise, use current width setting" ), _( "Auto track width: when starting on \
an existing track use its width\notherwise, use current width setting" ),
wxITEM_CHECK ); wxITEM_CHECK );
// Add the box to display and select the current grid size: // Add the box to display and select the current grid size:
...@@ -625,7 +627,9 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar() ...@@ -625,7 +627,9 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
else else
{ {
wxString value; wxString value;
value.Printf(wxT("%.1f"),(float)GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar ); value.Printf( wxT( "%.1f" ),
(float)GetScreen()->m_ZoomList[i] /
GetScreen()->m_ZoomScalar );
msg += value; msg += value;
} }
m_SelZoomBox->Append( msg ); m_SelZoomBox->Append( msg );
...@@ -648,7 +652,8 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar() ...@@ -648,7 +652,8 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ ) for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ )
{ {
GRID_TYPE grid = GetScreen()->m_GridList[i]; GRID_TYPE grid = GetScreen()->m_GridList[i];
double value = To_User_Unit( g_UnitMetric, grid.m_Size.x, m_InternalUnits ); double value = To_User_Unit( g_UnitMetric, grid.m_Size.x,
m_InternalUnits );
if( grid.m_Id != ID_POPUP_GRID_USER ) if( grid.m_Id != ID_POPUP_GRID_USER )
{ {
if( g_UnitMetric == INCHES ) if( g_UnitMetric == INCHES )
...@@ -659,7 +664,11 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar() ...@@ -659,7 +664,11 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
else else
msg = _( "User Grid" ); msg = _( "User Grid" );
m_SelGridBox->Append( msg ); m_SelGridBox->Append( msg, (void*) &GetScreen()->m_GridList[i].m_Id );
if( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ==
GetScreen()->m_GridList[i].m_Id )
m_SelGridBox->SetSelection( i );
} }
m_TrackAndViasSizesList_Changed = true; m_TrackAndViasSizesList_Changed = true;
......
...@@ -133,18 +133,8 @@ void WinEDA_PcbFrame::AuxiliaryToolBar_Update_UI() ...@@ -133,18 +133,8 @@ void WinEDA_PcbFrame::AuxiliaryToolBar_Update_UI()
if( m_SelGridBox ) if( m_SelGridBox )
{ {
int kk = m_SelGridBox->GetChoice(); m_SelGridBox->SetSelection( ID_POPUP_GRID_LEVEL_1000 +
m_LastGridSizeId );
for( int ii = 0; ii < (int) GetScreen()->m_GridList.GetCount(); ii++ )
{
if( GetScreen()->GetGrid() == GetScreen()->m_GridList[ii].m_Size )
{
if( kk != ii )
m_SelGridBox->SetSelection( ii );
kk = ii;
break;
}
}
} }
m_TrackAndViasSizesList_Changed = false; m_TrackAndViasSizesList_Changed = false;
......
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