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 )
m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */
m_ZoomScalar = 10;
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_Center = true;
m_CurrentSheetDesc = &g_Sheet_A4;
......@@ -357,25 +358,26 @@ void BASE_SCREEN::SetGrid( const wxRealPoint& size )
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++ )
{
if( m_GridList[i].m_Size == size )
{
m_Grid = m_GridList[i].m_Size;
m_Grid = m_GridList[i];
return;
}
// keep trace of the nearest grill size, if the exact size is not found
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;
wxLogWarning( wxT( "Grid size( %f, %f ) not in grid list, falling back " ) \
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. */
......@@ -389,15 +391,16 @@ void BASE_SCREEN::SetGrid( int id )
{
if( m_GridList[i].m_Id == id )
{
m_Grid = m_GridList[i].m_Size;
m_Grid = m_GridList[i];
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 " ) \
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 )
......@@ -406,8 +409,8 @@ void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
for( i = 0; i < m_GridList.GetCount(); i++ )
{
if( m_GridList[i].m_Size == grid.m_Size &&
grid.m_Id != ID_POPUP_GRID_USER)
if( m_GridList[i].m_Size == grid.m_Size
&& grid.m_Id != ID_POPUP_GRID_USER )
{
wxLogDebug( wxT( "Discarding duplicate grid size( %g, %g )." ),
grid.m_Size.x, grid.m_Size.y );
......@@ -446,13 +449,13 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id )
if( units == MILLIMETRE )
{
x = size.x / 25.4;
y = size.y / 25.4;
x = size.x / 25.4000508001016;
y = size.y / 25.4000508001016;
}
else if( units == CENTIMETRE )
{
x = size.x / 2.54;
y = size.y / 2.54;
x = size.x / 2.54000508001016;
y = size.y / 2.54000508001016;
}
else
{
......@@ -468,14 +471,25 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id )
AddGrid( new_grid );
}
/*********************************/
wxRealPoint BASE_SCREEN::GetGrid()
/*********************************/
GRID_TYPE BASE_SCREEN::GetGrid()
{
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()
/*****************************************/
......
......@@ -423,7 +423,7 @@ double To_User_Unit( bool is_metric, double val, int internal_unit_value )
double value;
if( is_metric )
value = val * 25.4 / internal_unit_value;
value = val * 25.4000508001016 / internal_unit_value;
else
value = val / internal_unit_value;
......@@ -441,7 +441,7 @@ int From_User_Unit( bool is_metric, double val, int internal_unit_value )
double value;
if( is_metric )
value = val * internal_unit_value / 25.4;
value = val * internal_unit_value / 25.4000508001016;
else
value = val * internal_unit_value;
......
......@@ -24,6 +24,7 @@
/* Configuration entry names. */
static const wxString CursorShapeEntry( wxT( "CuShape" ) );
static const wxString ShowGridEntry( wxT( "ShGrid" ) );
static const wxString LastGridSizeId( wxT( "_LastGridSize" ) );
BEGIN_EVENT_TABLE( WinEDA_DrawFrame, WinEDA_BasicFrame )
......@@ -32,6 +33,8 @@ BEGIN_EVENT_TABLE( WinEDA_DrawFrame, WinEDA_BasicFrame )
EVT_ACTIVATE( WinEDA_DrawFrame::OnActivate )
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
WinEDA_DrawFrame::OnZoom )
EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER,
WinEDA_DrawFrame::OnSelectGrid )
END_EVENT_TABLE()
......@@ -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_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch
m_CursorShape = 0;
m_LastGridSizeId = 0;
// Internal units per inch: = 1000 for schema, = 10000 for PCB
m_InternalUnits = EESCHEMA_INTERNAL_UNIT;
......@@ -191,23 +195,65 @@ void WinEDA_DrawFrame::ToolOnRightClick( wxCommandEvent& event )
}
/********************************************************/
void WinEDA_DrawFrame::OnSelectGrid( wxCommandEvent& event )
/********************************************************/
// Virtual function
void WinEDA_DrawFrame::OnSelectGrid( wxCommandEvent& event )
{
if( m_SelGridBox == NULL )
return; // Should not occurs
int* clientData;
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();
screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
wxRealPoint current_grid = screen->GetGrid();
screen->SetGrid( event.GetSelection() + ID_POPUP_GRID_LEVEL_1000 );
wxRealPoint selected_grid = screen->GetGrid();
if( screen->GetGridId() == id )
return;
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 )
}
}
/* 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
*/
double Round_To_0(double x)
double RoundTo0( double x, double precision )
{
long long ix = wxRound(x * 1000); // ix is in 0.001 mm
if ( x < 0 ) NEGATE(ix);
assert( precision != 0 );
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 )
ix -= remainder; // truncate to the near number
ix -= remainder; // truncate to the near number
else if (remainder >= 8 )
ix += 10 - remainder; // round to near number
ix += 10 - remainder; // round to near number
if ( x < 0 ) NEGATE(ix);
return (double)ix/1000.0;
if ( x < 0 )
NEGATE( ix );
return (double) ix / precision;
}
/** Function UpdateStatusBar()
/**
* Function UpdateStatusBar()
* Displays in the bottom of the main window a stust:
* - Absolute Cursor coordinates
* - Relative Cursor coordinates (relative to the last coordinate stored when actiavte the space bar)
* ( in this status is also displayed the zoom level, but this is not made by this function)
* - Relative Cursor coordinates (relative to the last coordinate stored
* 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()
{
......@@ -690,21 +749,31 @@ void WinEDA_DrawFrame::UpdateStatusBar()
if ( (screen->GetZoom() % screen->m_ZoomScalar) == 0 )
Line.Printf( wxT( "Z %d" ), screen->GetZoom() / screen->m_ZoomScalar );
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 );
/* Display absolute coordinates: */
double dXpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.x, m_InternalUnits );
double dYpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.y, m_InternalUnits );
/* When using mm the conversion from 1/10000 inch to mm can give some non easy to read numbers,
* like 1.999 or 2.001 that be better if displayed 2.000, so small diffs are filtered here.
double dXpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.x,
m_InternalUnits );
double dYpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.y,
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 )
{
dXpos = Round_To_0(dXpos);
dYpos = Round_To_0(dYpos);
dXpos = RoundTo0( dXpos, (double)( m_InternalUnits / 10 ) );
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 );
/* Display relative coordinates: */
......@@ -714,10 +783,15 @@ void WinEDA_DrawFrame::UpdateStatusBar()
dYpos = To_User_Unit( g_UnitMetric, dy, m_InternalUnits );
if ( g_UnitMetric )
{
dXpos = Round_To_0(dXpos);
dYpos = Round_To_0(dYpos);
dXpos = RoundTo0( dXpos, (double)( m_InternalUnits / 10 ) );
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 );
}
......@@ -737,6 +811,7 @@ void WinEDA_DrawFrame::LoadSettings()
WinEDA_BasicFrame::LoadSettings();
cfg->Read( m_FrameName + CursorShapeEntry, &m_CursorShape, ( long )0 );
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()
WinEDA_BasicFrame::SaveSettings();
cfg->Write( m_FrameName + CursorShapeEntry, m_CursorShape );
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 )
EVT_ERASE_BACKGROUND( WinEDA_DrawPanel::OnEraseBackground )
EVT_SCROLLWIN( WinEDA_DrawPanel::OnScroll )
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 )
END_EVENT_TABLE()
......@@ -186,7 +183,7 @@ void WinEDA_DrawPanel::SetZoom( int zoom )
wxRealPoint WinEDA_DrawPanel::GetGrid()
/************************************/
{
return GetScreen()->GetGrid();
return GetScreen()->GetGridSize();
}
......@@ -763,7 +760,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
*/
drawgrid = m_Parent->m_Draw_Grid;
screen_grid_size = screen->GetGrid();
screen_grid_size = screen->GetGridSize();
wxRealPoint dgrid = screen_grid_size;
screen->Scale( dgrid ); // dgrid = grid size in pixels
......@@ -797,7 +794,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
screen->Unscale( size );
#ifdef WX_ZOOM
screen_grid_size = screen->GetGrid();
screen_grid_size = screen->GetGridSize();
if( DC->LogicalToDeviceXRel( (int) screen_grid_size.x ) < 5
|| DC->LogicalToDeviceYRel( (int) screen_grid_size.y ) < 5 )
......
......@@ -47,7 +47,7 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord )
* @param coord = coordinate to adjust
*/
{
wxRealPoint grid_size = GetBaseScreen()->GetGrid();
wxRealPoint grid_size = GetBaseScreen()->GetGridSize();
if( !GetBaseScreen()->m_UserGridIsON )
{
......@@ -183,11 +183,6 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
UpdateStatusBar();
}
void WinEDA_DrawPanel::OnPopupGridSelect( wxCommandEvent& event )
{
GetScreen()->SetGrid( event.GetId() );
Refresh();
}
/*************************************************************/
void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
......@@ -200,7 +195,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
size_t i;
int maxZoomIds;
int zoom;
wxRealPoint grid;
wxRealPoint grid;
wxString msg;
GRID_TYPE tmp;
wxMenu* gridMenu;
......@@ -228,10 +223,12 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
/* Populate zoom submenu. */
for( i = 0; i < (size_t) maxZoomIds; i++ )
{
if ( (GetScreen()->m_ZoomList[i] % GetScreen()->m_ZoomScalar) == 0 )
msg.Printf( wxT( "%u" ), GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar);
if ( ( GetScreen()->m_ZoomList[i] % GetScreen()->m_ZoomScalar ) == 0 )
msg.Printf( wxT( "%u" ),
GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar );
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,
wxEmptyString, wxITEM_CHECK );
......@@ -247,7 +244,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
ID_POPUP_GRID_SELECT, _( "Grid Select" ),
grid_select_xpm );
grid = GetScreen()->GetGrid();
grid = GetScreen()->GetGridSize();
for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ )
{
......
......@@ -199,7 +199,7 @@ void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGrid();
delta = GetScreen()->GetGridSize();
GetScreen()->Scale( delta );
if( delta.x <= 0 )
......
......@@ -327,7 +327,7 @@ void LIB_TEXT::DisplayInfo( WinEDA_DrawFrame* frame )
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
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,
/***********************************************************/
void DrawSheetStruct::DisplayInfo( WinEDA_DrawFrame* frame )
{
WinEDA_MsgPanel *msgpanel = frame->MsgPanel;
msgpanel->EraseMsgBox();
msgpanel->AppendMessage( _( "Name" ), m_SheetName, CYAN );
msgpanel->AppendMessage( _( "FileName" ), m_FileName, BROWN );
frame->ClearMsgPanel();
frame->AppendMsgPanel( _( "Sheet name" ), m_SheetName, CYAN );
frame->AppendMsgPanel( _( "File name" ), m_FileName, BROWN );
}
......
......@@ -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
* writes the data structures for this object out to a FILE in "*.brd" format.
......
......@@ -241,17 +241,46 @@ public:
* @param type - type of searched item (filter).
* 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,
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 )
{
return (LIB_PIN*) GetNextDrawItem( (LIB_DRAW_ITEM*) item,
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.
*
......
......@@ -1182,17 +1182,17 @@ void LIB_PIN::DisplayInfo( WinEDA_DrawFrame* 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 )
Text = wxT( "?" );
else
ReturnPinStringNum( Text );
frame->MsgPanel->AppendMessage( _( "Pin number" ), Text, DARKCYAN );
frame->AppendMsgPanel( _( "Pin number" ), Text, DARKCYAN );
ii = m_PinType;
frame->MsgPanel->AppendMessage( _( "Pin type" ), MsgPinElectricType[ii],
frame->AppendMsgPanel( _( "Pin type" ), MsgPinElectricType[ii],
RED );
ii = m_Attributs;
......@@ -1200,12 +1200,12 @@ void LIB_PIN::DisplayInfo( WinEDA_DrawFrame* frame )
Text = _( "Not visible" );
else
Text = _( "Visible" );
frame->MsgPanel->AppendMessage( _( "Display" ), Text, DARKGREEN );
frame->AppendMsgPanel( _( "Display" ), Text, DARKGREEN );
/* Display pin length */
Text = ReturnStringFromValue( g_UnitMetric, m_PinLen,
EESCHEMA_INTERNAL_UNIT, true );
frame->MsgPanel->AppendMessage( _( "Length" ), Text, MAGENTA );
frame->AppendMsgPanel( _( "Length" ), Text, MAGENTA );
switch( m_Orient )
{
......@@ -1230,7 +1230,7 @@ void LIB_PIN::DisplayInfo( WinEDA_DrawFrame* frame )
break;
}
frame->MsgPanel->AppendMessage( _( "Orientation" ), Text, MAGENTA );
frame->AppendMsgPanel( _( "Orientation" ), Text, MAGENTA );
}
......
......@@ -1025,29 +1025,30 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
{
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( Entry == NULL )
return;
wxString msg;
WinEDA_MsgPanel *msgpanel = frame->MsgPanel;
msgpanel->EraseMsgBox();
frame->ClearMsgPanel();
msg = GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet());
msgpanel->AppendMessage( _( "Ref" ), msg, DARKCYAN );
frame->AppendMsgPanel( _( "Reference" ),
GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()),
DARKCYAN );
if( Entry && Entry->m_Options == ENTRY_POWER )
msg = _( "Pwr Symb" );
if( Entry->m_Options == ENTRY_POWER )
msg = _( "Power symbol" );
else
msg = _( "Val" );
msgpanel->AppendMessage( msg, GetField( VALUE )->m_Text, DARKCYAN );
msg = _( "Name" );
msgpanel->AppendMessage( _( "RefLib" ), m_ChipName.GetData(), BROWN );
frame->AppendMsgPanel( msg, GetField( VALUE )->m_Text, DARKCYAN );
frame->AppendMsgPanel( _( "Component" ), m_ChipName, BROWN );
msg = Entry->GetLibraryName();
msgpanel->AppendMessage( _( "Lib" ), msg, DARKRED );
if( Entry )
msgpanel->AppendMessage( Entry->m_Doc, Entry->m_KeyWord, DARKCYAN );
frame->AppendMsgPanel( _( "Library" ), msg, DARKRED );
frame->AppendMsgPanel( _( "Description" ), Entry->m_Doc, DARKCYAN );
frame->AppendMsgPanel( _( "Key words" ), Entry->m_KeyWord, DARKCYAN );
}
/** virtual function Mirror_Y
......
......@@ -53,6 +53,7 @@ static int SchematicZoomList[] =
#define SCHEMATIC_ZOOM_LIST_CNT ( sizeof( SchematicZoomList ) / \
sizeof( int ) )
#define MM_TO_SCH_UNITS 1000.0 / 25.4000508001016
/* Default grid sizes for the schematic editor. */
......@@ -62,7 +63,19 @@ static GRID_TYPE SchematicGridList[] = {
{ ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) },
{ ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) },
{ 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 ) / \
......
......@@ -58,16 +58,15 @@ void LIB_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame )
{
wxString msg;
frame->MsgPanel->EraseMsgBox();
frame->MsgPanel->AppendMessage( _( "Type" ), m_typeName, CYAN );
frame->ClearMsgPanel();
frame->AppendMsgPanel( _( "Type" ), m_typeName, CYAN );
/* Affichage de l'appartenance */
if( m_Unit == 0 )
msg = _( "All" );
else
msg.Printf( wxT( "%d" ), m_Unit );
frame->MsgPanel->AppendMessage( _( "Unit" ), msg, BROWN );
frame->AppendMsgPanel( _( "Unit" ), msg, BROWN );
if( m_Convert == 0 )
msg = _( "All" );
......@@ -77,7 +76,7 @@ void LIB_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame )
msg = _( "yes" );
else
msg = wxT( "?" );
frame->MsgPanel->AppendMessage( _( "Convert" ), msg, BROWN );
frame->AppendMsgPanel( _( "Convert" ), msg, BROWN );
}
......@@ -525,12 +524,12 @@ void LIB_ARC::DisplayInfo( WinEDA_DrawFrame* frame )
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
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,
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 )
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
frame->MsgPanel->AppendMessage( _( "Line width" ), msg, BLUE );
frame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
msg = ReturnStringFromValue( g_UnitMetric, m_Radius,
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,
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 )
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
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 )
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
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,
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 )
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
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,
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 )
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
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,
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 @@
class LIB_COMPONENT;
class PLOTTER;
class LIB_DRAW_ITEM;
class LIB_PIN;
#define TARGET_PIN_DIAM 12 /* Circle diameter drawn at the active end of
......@@ -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 */
/****************************************************************************/
......@@ -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 */
/********/
......
......@@ -48,7 +48,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
DrawStruct = SchematicGeneralLocateAndDisplay( mouse_position, IncludePin );
if( !DrawStruct && ( mouse_position != GetScreen()->m_Curseur) )
{
DrawStruct = SchematicGeneralLocateAndDisplay( GetScreen()->m_Curseur, IncludePin );
DrawStruct = SchematicGeneralLocateAndDisplay( GetScreen()->m_Curseur,
IncludePin );
}
if( !DrawStruct )
return NULL;
......@@ -63,7 +64,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
break;
case TYPE_SCH_COMPONENT:
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem );
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur,
&LibItem );
if( Pin )
break; // Priority is probing a pin first
LibItem = (SCH_COMPONENT*) DrawStruct;
......@@ -71,7 +73,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
break;
default:
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem );
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur,
&LibItem );
break;
case COMPONENT_PIN_DRAW_TYPE:
......@@ -81,16 +84,15 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
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 );
if( LibItem )
{
MsgPanel->AppendMessage( LibItem->GetRef( GetSheet() ),
LibItem->GetField( VALUE )->m_Text,
DARKCYAN );
}
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
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 );
}
return DrawStruct;
......@@ -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 )
/********************************************************************************************/
......@@ -129,20 +131,20 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), MARKERITEM );
if( DrawStruct )
{
MsgPanel->EraseMsgBox();
ClearMsgPanel();
return DrawStruct;
}
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), NOCONNECTITEM );
if( DrawStruct )
{
MsgPanel->EraseMsgBox();
ClearMsgPanel();
return DrawStruct;
}
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), JUNCTIONITEM );
if( DrawStruct )
{
MsgPanel->EraseMsgBox();
ClearMsgPanel();
return DrawStruct;
}
......@@ -154,14 +156,11 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
{
Pin->DisplayInfo( this );
if( LibItem )
{
MsgPanel->AppendMessage( LibItem->GetRef( GetSheet() ),
LibItem->GetField( VALUE )->m_Text,
DARKCYAN );
}
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
}
else
MsgPanel->EraseMsgBox();
ClearMsgPanel();
return DrawStruct;
}
......@@ -176,16 +175,14 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
}
/* search for a pin */
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint,
&LibItem );
if( Pin )
{
Pin->DisplayInfo( this );
if( LibItem )
{
MsgPanel->AppendMessage( LibItem->GetRef( GetSheet() ),
LibItem->GetField( VALUE )->m_Text,
DARKCYAN );
}
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
if( IncludePin )
return LibItem;
}
......@@ -213,7 +210,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
return DrawStruct;
}
MsgPanel->EraseMsgBox();
ClearMsgPanel();
return NULL;
}
......@@ -231,7 +228,7 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur;
delta = screen->GetGrid();
delta = screen->GetGridSize();
screen->Scale( delta );
if( delta.x <= 0 )
......@@ -324,7 +321,7 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur;
delta = screen->GetGrid();
delta = screen->GetGridSize();
screen->Scale( delta );
if( delta.x <= 0 )
......@@ -416,7 +413,7 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur;
delta = screen->GetGrid();
delta = screen->GetGridSize();
screen->Scale( delta );
if( delta.x <= 0 )
......
......@@ -92,7 +92,7 @@ WinEDA_SetOptionsFrame::WinEDA_SetOptionsFrame( WinEDA_SchematicFrame* parent,
/* Init options */
if( screen )
{
switch( (int)screen->GetGrid().x )
switch( (int)screen->GetGridSize().x )
{
case 50:
m_SelGridSize->SetSelection( 0 );
......
......@@ -301,7 +301,7 @@ bool EDA_Printout::OnPrintPage( int page )
wxString msg;
msg.Printf( _( "Print page %d" ), page );
m_Parent->Affiche_Message( msg );
m_Parent->AppendMsgPanel( msg, wxEmptyString, CYAN );
WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent;
SCH_SCREEN* screen = schframe->GetScreen();
......
......@@ -263,6 +263,7 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName,
SetDrawBgColor( g_DrawBgColor );
LoadLibraries();
GetBaseScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
return IsRead;
}
......
......@@ -99,7 +99,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
GetScreen()->m_FileName = FullFileName;
g_RootSheet->SetFileName( FullFileName );
Affiche_Message( wxEmptyString );
MsgPanel->EraseMsgBox();
ClearMsgPanel();
memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) );
......@@ -111,6 +111,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
{
screen->m_CurrentSheetDesc = &g_Sheet_A4;
screen->SetZoom( 32 );
screen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
screen->m_Title = wxT( "noname.sch" );
GetScreen()->m_FileName = screen->m_Title;
screen->m_Company.Empty();
......@@ -213,6 +214,7 @@ Error: %s" ),
/* Reaffichage ecran de base (ROOT) si necessaire */
ActiveScreen = GetScreen();
ActiveScreen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
Zoom_Automatique( FALSE );
SetSheetNumberAndCount();
DrawPanel->Refresh( true );
......
......@@ -235,7 +235,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
DrawStructsInGhost( DrawPanel, DC, Component, wxPoint(0,0) );
MsgPanel->EraseMsgBox();
ClearMsgPanel();
Component->DisplayInfo( this );
return Component;
......
......@@ -264,7 +264,7 @@ void WinEDA_SchematicFrame::InstallPreviousSheet()
return;
g_ItemToRepeat = NULL;
MsgPanel->EraseMsgBox();
ClearMsgPanel();
//make a copy for testing purposes.
DrawSheetPath listtemp = *m_CurrentSheet;
......@@ -296,7 +296,7 @@ void WinEDA_SchematicFrame::InstallNextScreen( DrawSheetStruct* Sheet )
}
m_CurrentSheet->Push( Sheet );
g_ItemToRepeat = NULL;
MsgPanel->EraseMsgBox();
ClearMsgPanel();
UpdateScreenFromSheet( this );
}
......@@ -321,7 +321,7 @@ static bool UpdateScreenFromSheet( WinEDA_SchematicFrame* frame )
// Reinit des parametres d'affichage du nouvel ecran
// assumes m_CurrentSheet has already been updated.
frame->MsgPanel->EraseMsgBox();
frame->ClearMsgPanel();
frame->DrawPanel->SetScrollbars( NewScreen->m_ZoomScalar,
NewScreen->m_ZoomScalar,
NewScreen->m_ScrollbarNumber.x,
......
......@@ -268,13 +268,13 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
bool success = m_library->Save( fn.GetFullPath(), true );
MsgPanel->EraseMsgBox();
ClearMsgPanel();
if( !success )
{
msg = _( "Error while saving library file \"" ) + fn.GetFullPath() +
_( "\"." );
MsgPanel->AppendMessage( wxT( "*** ERROR: ***" ), msg, RED );
AppendMsgPanel( _( "*** ERROR: ***" ), msg, RED );
DisplayError( this, msg );
}
else
......@@ -283,7 +283,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
fn.SetExt( DOC_EXT );
wxString msg1 = _( "Document file \"" ) + fn.GetFullPath() +
wxT( "\" Ok" );
MsgPanel->AppendMessage( msg, msg1, BLUE );
AppendMsgPanel( msg, msg1, BLUE );
}
}
......@@ -297,14 +297,14 @@ void WinEDA_LibeditFrame::DisplayCmpDoc()
wxString msg;
LIB_ALIAS* alias = NULL;
MsgPanel->EraseMsgBox();
ClearMsgPanel();
if( m_library == NULL || m_component == NULL )
return;
msg = m_component->GetName();
MsgPanel->AppendMessage( _( "Part" ), msg, BLUE, 8 );
AppendMsgPanel( _( "Part" ), msg, BLUE, 8 );
if( m_aliasName.IsEmpty() )
{
......@@ -316,40 +316,40 @@ void WinEDA_LibeditFrame::DisplayCmpDoc()
alias = m_library->FindAlias( m_aliasName );
}
MsgPanel->AppendMessage( _( "Alias" ), msg, RED, 8 );
AppendMsgPanel( _( "Alias" ), msg, RED, 8 );
static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
msg = UnitLetter[m_unit];
MsgPanel->AppendMessage( _( "Unit" ), msg, BROWN, 8 );
AppendMsgPanel( _( "Unit" ), msg, BROWN, 8 );
if( m_convert > 1 )
msg = _( "Convert" );
else
msg = _( "Normal" );
MsgPanel->AppendMessage( _( "Body" ), msg, GREEN, 8 );
AppendMsgPanel( _( "Body" ), msg, GREEN, 8 );
if( m_component->m_Options == ENTRY_POWER )
msg = _( "Power Symbol" );
else
msg = _( "Component" );
MsgPanel->AppendMessage( _( "Type" ), msg, MAGENTA, 8 );
AppendMsgPanel( _( "Type" ), msg, MAGENTA, 8 );
if( alias != NULL )
msg = alias->m_Doc;
else
msg = m_component->m_Doc;
MsgPanel->AppendMessage( _( "Description" ), msg, CYAN, 8 );
AppendMsgPanel( _( "Description" ), msg, CYAN, 8 );
if( alias != NULL )
msg = alias->m_KeyWord;
else
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,
GetScreen()->m_Center = true;
LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
if( DrawPanel )
DrawPanel->m_Block_Enable = true;
ReCreateHToolbar();
......
......@@ -160,17 +160,16 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( EDA_BaseStruct* DrawList
if( Entry->GetPartCount() <= 1 ) // One part per package
{
for( Pin = Entry->GetNextPin(); Pin != NULL;
Pin = Entry->GetNextPin( Pin ) )
LIB_PIN_LIST pins;
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
&& ( Pin->m_Unit != Component->GetUnitSelection( sheet ) ) )
continue;
if( Pin->m_Convert
&& ( Pin->m_Convert != Component->m_Convert ) )
continue;
wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
AddPinToComponentPinList( Component, sheet, Pin );
}
......
......@@ -482,7 +482,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
if( dlg.ShowModal() == wxID_CANCEL )
return;
m_Parent->MsgPanel->EraseMsgBox();
m_Parent->ClearMsgPanel();
ReAnnotatePowerSymbolsOnly();
if( m_Parent->CheckAnnotate( NULL, 0 ) )
......
......@@ -295,11 +295,13 @@ void WinEDA_SchematicFrame::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SELECT_UNIT_MM:
g_UnitMetric = MILLIMETRE;
UpdateStatusBar(); /* Reaffichage des coord curseur */
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SELECT_UNIT_INCH:
g_UnitMetric = INCHES;
UpdateStatusBar(); /* Reaffichage des coord curseur */
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SELECT_CURSOR:
......
......@@ -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
LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
ReCreateHToolbar();
ReCreateVToolbar();
......
......@@ -310,11 +310,11 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( !tmp.IsEmpty() )
component->m_Name.m_Text = tmp;
MsgPanel->EraseMsgBox();
MsgPanel->AppendMessage( _( "Part" ), component->GetName(), BLUE, 6 );
MsgPanel->AppendMessage( _( "Alias" ), msg, RED, 6 );
MsgPanel->AppendMessage( _( "Description" ), entry->m_Doc, CYAN, 6 );
MsgPanel->AppendMessage( _( "Key words" ), entry->m_KeyWord, DARKDARKGRAY );
ClearMsgPanel();
AppendMsgPanel( _( "Part" ), component->GetName(), BLUE, 6 );
AppendMsgPanel( _( "Alias" ), msg, RED, 6 );
AppendMsgPanel( _( "Description" ), entry->m_Doc, CYAN, 6 );
AppendMsgPanel( _( "Key words" ), entry->m_KeyWord, DARKDARKGRAY );
DrawPanel->Trace_Curseur( DC );
}
......@@ -58,7 +58,7 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGrid();
delta = GetScreen()->GetGridSize();
GetScreen()->Scale( delta );
if( delta.x == 0 )
......
......@@ -147,6 +147,7 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
ActiveScreen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
ReCreateMenuBar();
ReCreateHToolbar();
ReCreateVToolbar();
......@@ -299,9 +300,9 @@ int WinEDA_GerberFrame::BestZoom()
GetBoard()->ComputeBoundaryBox();
size = DrawPanel->GetClientSize();
x = ( (double) GetBoard()->m_BoundaryBox.GetWidth() +
GetScreen()->GetGrid().x ) / (double) size.x;
GetScreen()->GetGridSize().x ) / (double) size.x;
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();
return wxRound( MAX( x, y ) * (double)GetScreen()->m_ZoomScalar );
......
......@@ -25,6 +25,22 @@ class GRID_TYPE
public:
int m_Id;
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:
* navigation dans la hierarchie */
bool m_Center; /* fix the coordinate (0,0) position on
* 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
* FALSE: when coordinates can be only >= 0
* Schematic */
......@@ -94,11 +110,11 @@ private:
char m_FlagModified; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde
char m_FlagSave; // indique sauvegarde auto faite
EDA_BaseStruct* m_CurrentItem; ///< Currently selected object
GRID_TYPE m_Grid; ///< Current grid selection.
/* Valeurs du pas de grille et du zoom */
public:
wxRealPoint m_Grid; /* Current grid. */
GridArray m_GridList;
GridArray m_GridList;
bool m_UserGridIsON;
wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */
......@@ -137,7 +153,7 @@ public:
/** function ClearUndoORRedoList (virtual).
* 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
* function that must be created for SCH_SCREEN and PCB_SCREEN
* @param aList = the UNDO_REDO_CONTAINER of commands
......@@ -257,9 +273,30 @@ public:
bool SetLastZoom(); /* ajuste le coeff de zoom au max */
//----<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( int );
void SetGrid( int id );
void SetGridList( GridArray& sizelist );
void AddGrid( const GRID_TYPE& grid );
void AddGrid( const wxRealPoint& size, int id );
......@@ -268,11 +305,13 @@ public:
/**
* Function RefPos
* returns the reference position, coming from either the mouse position or the
* the cursor position.
* Return the reference position, coming from either the mouse position
* or the cursor position.
*
* @param useMouse If true, return mouse position, else cursor's.
*
* @return wxPoint - The reference point, either the mouse position or
* the cursor position.
* the cursor position.
*/
wxPoint RefPos( bool useMouse )
{
......
......@@ -96,7 +96,6 @@ public:
void AddMenuZoom( wxMenu* MasterMenu );
bool OnRightClick( wxMouseEvent& event );
void OnPopupGridSelect( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event );
/** Function CursorRealPosition
......
......@@ -174,11 +174,16 @@ enum main_id
ID_POPUP_GRID_LEVEL_5,
ID_POPUP_GRID_LEVEL_2,
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_0_5MM,
ID_POPUP_GRID_LEVEL_0_25MM,
ID_POPUP_GRID_LEVEL_0_2MM,
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_SHEET_SET,
......
......@@ -310,24 +310,29 @@ public:
* add a picker to handle aItemToCopy
* @param aItemToCopy = the board item modified by the command to undo
* @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,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy,
UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
/** Function SaveCopyInUndoList (virtual pure, overloaded).
* Creates a new entry in undo list of commands.
* add a list of pickers to handle a list of items
* @param aItemsList = the list of items modified by the command to undo
* @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,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
// 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,
bool null_layer = false );
void SelectLayerPair();
......@@ -336,7 +341,28 @@ public:
// divers
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();
/**
* 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();
DECLARE_EVENT_TABLE()
......
......@@ -58,6 +58,8 @@ public:
wxTextCtrl* m_NetClassSelectedBox; // a text ctrl to display the current NetClass
bool m_TrackAndViasSizesList_Changed;
bool m_show_microwave_tools;
private:
DRC* m_drc; ///< the DRC controller, see drc.cpp
......@@ -670,6 +672,28 @@ public:
void Begin_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()
};
......@@ -712,7 +736,6 @@ public:
void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
void Show3D_Frame( wxCommandEvent& event );
void GeneralControle( wxDC* DC, wxPoint Mouse );
virtual void OnSelectGrid( wxCommandEvent& event );
void LoadModuleFromBoard( wxCommandEvent& event );
// BOARD handling
......
......@@ -172,6 +172,9 @@ public:
*/
wxPoint m_Auxiliary_Axis_Position; /* position of the auxiliary axis */
protected:
int m_LastGridSizeId;
private:
BASE_SCREEN* m_CurrentScreen; ///< current used SCREEN
......@@ -215,6 +218,16 @@ public:
virtual void SetToolID( int id, int new_cursor_id,
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 OnSelectZoom( wxCommandEvent& event );
......@@ -297,6 +310,26 @@ public:
virtual void LoadSettings();
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();
};
......@@ -404,7 +437,7 @@ public:
* @param pad - Number of spaces to pad between messages (default = 4).
*/
void AppendMessage( const wxString& textUpper, const wxString& textLower,
int color, int pad = 4 );
int color, int pad = 6 );
DECLARE_EVENT_TABLE()
};
......
......@@ -203,7 +203,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( wxDC* DC, bool PlaceModulesHorsPcb )
MODULE* Module;
wxPoint start, current;
int Ymax_size, Xsize_allowed;
int pas_grille = (int)GetScreen()->GetGrid().x;
int pas_grille = (int)GetScreen()->GetGridSize().x;
bool EdgeExists;
float surface;
......
......@@ -117,7 +117,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC
lay_tmp_TOP = Route_Layer_TOP;
OldPasRoute = g_GridRoutingSize;
g_GridRoutingSize = (int)GetScreen()->GetGrid().x;
g_GridRoutingSize = (int)GetScreen()->GetGridSize().x;
// Ensure g_GridRoutingSize has a reasonnable value:
if( g_GridRoutingSize < 10 )
......
......@@ -133,7 +133,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
start = time( NULL );
/* 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 )
g_GridRoutingSize = 50;
E_scale = g_GridRoutingSize / 50; if( E_scale < 1 )
......
......@@ -70,7 +70,6 @@ WinEDA_BasePcbFrame::WinEDA_BasePcbFrame( wxWindow* father,
m_UserGridSize = wxRealPoint( 100.0, 100.0 );
m_UserGridUnits = INCHES;
m_Collector = new GENERAL_COLLECTOR();
}
......
......@@ -28,32 +28,37 @@ static const int PcbZoomList[] =
};
#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. */
#define MM_TO_PCB_UNITS 10000.0 / 25.4
static GRID_TYPE PcbGridList[] =
{
// predefined grid list in 0.0001 inches
{ ID_POPUP_GRID_LEVEL_1000, wxRealPoint( 1000, 1000 ) },
{ ID_POPUP_GRID_LEVEL_500, wxRealPoint( 500, 500 ) },
{ ID_POPUP_GRID_LEVEL_250, wxRealPoint( 250, 250 ) },
{ ID_POPUP_GRID_LEVEL_200, wxRealPoint( 200, 200 ) },
{ ID_POPUP_GRID_LEVEL_100, wxRealPoint( 100, 100 ) },
{ ID_POPUP_GRID_LEVEL_50, wxRealPoint( 50, 50 ) },
{ ID_POPUP_GRID_LEVEL_25, wxRealPoint( 25, 25 ) },
{ ID_POPUP_GRID_LEVEL_20, wxRealPoint( 20, 20 ) },
{ ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) },
{ ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) },
{ ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) },
{ ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) },
{ ID_POPUP_GRID_LEVEL_1000, wxRealPoint( 1000, 1000 ) },
{ ID_POPUP_GRID_LEVEL_500, wxRealPoint( 500, 500 ) },
{ ID_POPUP_GRID_LEVEL_250, wxRealPoint( 250, 250 ) },
{ ID_POPUP_GRID_LEVEL_200, wxRealPoint( 200, 200 ) },
{ ID_POPUP_GRID_LEVEL_100, wxRealPoint( 100, 100 ) },
{ ID_POPUP_GRID_LEVEL_50, wxRealPoint( 50, 50 ) },
{ ID_POPUP_GRID_LEVEL_25, wxRealPoint( 25, 25 ) },
{ ID_POPUP_GRID_LEVEL_20, wxRealPoint( 20, 20 ) },
{ ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) },
{ ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) },
{ ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) },
{ ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) },
// predefined grid list in mm
{ ID_POPUP_GRID_LEVEL_1MM, wxRealPoint( MM_TO_PCB_UNITS, MM_TO_PCB_UNITS ) },
{ ID_POPUP_GRID_LEVEL_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.5, MM_TO_PCB_UNITS * 0.5 ) },
{ 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_5MM, wxRealPoint( MM_TO_PCB_UNITS * 5.0, MM_TO_PCB_UNITS * 5.0 ) },
{ ID_POPUP_GRID_LEVEL_2_5MM, wxRealPoint( MM_TO_PCB_UNITS * 2.5, MM_TO_PCB_UNITS * 2.5 ) },
{ ID_POPUP_GRID_LEVEL_1MM, wxRealPoint( MM_TO_PCB_UNITS, MM_TO_PCB_UNITS ) },
{ ID_POPUP_GRID_LEVEL_0_5MM, wxRealPoint( MM_TO_PCB_UNITS * 0.5, MM_TO_PCB_UNITS * 0.5 ) },
{ 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 ) )
......
......@@ -261,7 +261,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGrid();
delta = GetScreen()->GetGridSize();
GetScreen()->Scale( delta );
if( delta.x <= 0 )
......@@ -326,10 +326,10 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
PutOnGrid( &on_grid );
wxSize grid;
grid.x = (int) GetScreen()->GetGrid().x;
grid.y = (int) GetScreen()->GetGrid().y;
grid.x = (int) GetScreen()->GetGridSize().x;
grid.y = (int) GetScreen()->GetGridSize().y;
if( Magnetize(m_Pcb, (WinEDA_PcbFrame *) this, m_ID_current_state,
grid, on_grid, &curpos) )
grid, on_grid, &curpos) )
{
GetScreen()->m_Curseur = curpos;
}
......
......@@ -310,9 +310,9 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
return false;
}
pas_45 = (int) GetScreen()->GetGrid().x / 2;
pas_45 = (int) GetScreen()->GetGridSize().x / 2;
if( pas_45 < curTrack->m_Width )
pas_45 = (int) GetScreen()->GetGrid().x;
pas_45 = (int) GetScreen()->GetGridSize().x;
while( pas_45 < curTrack->m_Width )
pas_45 *= 2;
......
......@@ -170,7 +170,7 @@ bool WinEDA_PcbFrame::Clear_Pcb( bool aQuery )
GetScreen()->m_FileName.Empty();
/* Init new grid size */
wxRealPoint gridsize = GetScreen()->GetGrid();
wxRealPoint gridsize = GetScreen()->GetGridSize();
GetScreen()->Init();
GetScreen()->SetGrid( gridsize );
......@@ -218,7 +218,7 @@ bool WinEDA_ModuleEditFrame::Clear_Pcb( bool aQuery )
SetCurItem( NULL );
/* Init parametres de gestion */
wxRealPoint gridsize = GetScreen()->GetGrid();
wxRealPoint gridsize = GetScreen()->GetGridSize();
GetScreen()->Init();
GetScreen()->SetGrid( gridsize );
......
......@@ -19,8 +19,6 @@
#include "3d_viewer.h"
// Keys used in read/write config
#define MODEDIT_CURR_GRID wxT( "ModEditCurrGrid" )
// local variables:
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,
EVT_CLOSE( WinEDA_ModuleEditFrame::OnCloseWindow )
EVT_SIZE( WinEDA_ModuleEditFrame::OnSize )
EVT_KICAD_CHOICEBOX( ID_ON_ZOOM_SELECT, WinEDA_PcbFrame::OnSelectZoom )
EVT_KICAD_CHOICEBOX( ID_ON_GRID_SELECT, WinEDA_PcbFrame::OnSelectGrid )
EVT_KICAD_CHOICEBOX( ID_ON_ZOOM_SELECT, WinEDA_ModuleEditFrame::OnSelectZoom )
EVT_KICAD_CHOICEBOX( ID_ON_GRID_SELECT, WinEDA_ModuleEditFrame::OnSelectGrid )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_ModuleEditFrame::OnZoom )
......@@ -156,8 +154,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
WinEDA_BasePcbFrame( father, MODULE_EDITOR_FRAME,
wxEmptyString, pos, size, style )
{
wxConfig* config = wxGetApp().m_EDA_Config;
m_FrameName = wxT( "ModEditFrame" );
m_Draw_Sheet_Ref = false; // true to show the frame references
m_Draw_Axis = true; // true to show X and Y axis on screen
......@@ -181,6 +177,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
LoadSettings();
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 );
ReCreateMenuBar();
......@@ -189,13 +186,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
ReCreateVToolbar();
ReCreateOptToolbar();
if( config )
{
long gridselection = 1;
config->Read( MODEDIT_CURR_GRID, &gridselection );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + gridselection );
}
if( DrawPanel )
DrawPanel->m_Block_Enable = TRUE;
}
......@@ -222,8 +212,6 @@ WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame()
void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event )
/**************************************************************/
{
wxConfig* config = wxGetApp().m_EDA_Config;
if( GetScreen()->IsModify() )
{
if( !IsOK( this, _( "Module Editor: Module modified! Continue?" ) ) )
......@@ -233,19 +221,12 @@ void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event )
}
SaveSettings();
if( config )
{
config->Write( MODEDIT_CURR_GRID, m_SelGridBox->GetSelection() );
}
Destroy();
}
/*********************************************/
void WinEDA_ModuleEditFrame::SetToolbars()
/*********************************************/
{
size_t i;
bool active, islib = TRUE;
WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) wxGetApp().GetTopWindow();
......@@ -382,19 +363,10 @@ void WinEDA_ModuleEditFrame::SetToolbars()
m_SelZoomBox->SetSelection( -1 );
}
if( m_SelGridBox && GetScreen() )
if( m_SelGridBox )
{
int kk = m_SelGridBox->GetChoice();
for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ )
{
if( ( GetScreen()->GetGrid() == GetScreen()->m_GridList[i].m_Size ) )
{
if( kk != (int) i )
m_SelGridBox->SetSelection( (int) i );
kk = (int) i;
break;
}
}
m_SelGridBox->SetSelection( ID_POPUP_GRID_LEVEL_1000 +
m_LastGridSizeId );
}
}
......@@ -441,7 +413,7 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGrid();
delta = GetScreen()->GetGridSize();
GetScreen()->Scale( delta );
if( delta.x == 0 )
......@@ -514,26 +486,3 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
SetToolbars();
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 @@
#include "dialog_design_rules.h"
// Keys used in read/write config
#define PCB_CURR_GRID wxT( "PcbCurrGrid" )
#define PCB_MAGNETIC_PADS_OPT wxT( "PcbMagPadOpt" )
#define PCB_MAGNETIC_TRACKS_OPT wxT( "PcbMagTrackOpt" )
#define SHOW_MICROWAVE_TOOLS wxT( "ShowMicrowaveTools" )
......@@ -220,8 +219,6 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
long style ) :
WinEDA_BasePcbFrame( father, PCB_FRAME, title, pos, size, style )
{
wxConfig* config = wxGetApp().m_EDA_Config;
m_FrameName = wxT( "PcbFrame" );
m_Draw_Sheet_Ref = true; // true to display sheet references
m_Draw_Auxiliary_Axis = true;
......@@ -229,6 +226,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
m_SelViaSizeBox = NULL;
m_SelLayerBox = NULL;
m_TrackAndViasSizesList_Changed = false;
m_show_microwave_tools = false;
SetBoard( new BOARD( NULL, this ) );
m_TrackAndViasSizesList_Changed = true;
......@@ -251,16 +249,8 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
LoadSettings();
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()->SetGrid( GridSize );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
if( DrawPanel )
DrawPanel->m_Block_Enable = true;
......@@ -268,17 +258,10 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
ReCreateHToolbar();
ReCreateAuxiliaryToolbar();
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();
if( m_show_microwave_tools )
ReCreateAuxVToolbar();
}
......@@ -297,8 +280,6 @@ WinEDA_PcbFrame::~WinEDA_PcbFrame()
void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
/********************************************************/
{
wxConfig* config = wxGetApp().m_EDA_Config;
DrawPanel->m_AbortRequest = true;
if( ScreenPcb->IsModify() )
......@@ -327,17 +308,7 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
}
}
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
Show( false );
......@@ -376,3 +347,35 @@ void WinEDA_PcbFrame::ShowDesignRulesEditor( wxCommandEvent& event )
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()
wxBitmap( via_sketch_xpm ),
_( "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 ),
_( "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 ),
_( "Show Edges Sketch" ) );
......@@ -280,12 +282,14 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
for( int i = 0; i < (int)GetScreen()->m_ZoomList.GetCount(); i++ )
{
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;
else
{
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;
}
m_SelZoomBox->Append( msg );
......@@ -293,8 +297,8 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
m_AuxiliaryToolBar->AddControl( m_SelZoomBox );
// after adding the buttons to the toolbar, must call Realize() to reflect
// the changes
// after adding the buttons to the toolbar, must call Realize() to
// reflect the changes
m_AuxiliaryToolBar->Realize();
}
......@@ -317,7 +321,11 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
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();
......
......@@ -59,7 +59,7 @@ static const char s_BitmapLayerIcon[16][16] = {
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;
......@@ -99,7 +99,7 @@ void WinEDA_PcbFrame::PrepareLayerIndicator()
if( !change && (LayerPairBitmap != NULL) )
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 )
{
LayerPairBitmap = new wxBitmap( 16, 16 );
......@@ -276,7 +276,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
m_HToolBar->AddSeparator();
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,
*LayerPairBitmap, SEL_LAYER_HELP );
......@@ -495,7 +495,7 @@ void WinEDA_PcbFrame::ReCreateVToolbar()
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 )
......@@ -566,6 +566,7 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
wxPoint( -1, -1 ),
wxSize( LISTBOX_WIDTH + 10, -1 ) );
m_AuxiliaryToolBar->AddControl( m_SelTrackWidthBox );
m_AuxiliaryToolBar->AddSeparator();
// Creates box to display and choose vias diameters:
m_SelViaSizeBox = new WinEDAChoiceBox( m_AuxiliaryToolBar,
......@@ -573,32 +574,33 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
wxPoint( -1, -1 ),
wxSize( LISTBOX_WIDTH + 10, -1 ) );
m_AuxiliaryToolBar->AddControl( m_SelViaSizeBox );
m_AuxiliaryToolBar->AddSeparator();
// Creates box to display tracks and vias clearance:
m_ClearanceBox = new wxTextCtrl( m_AuxiliaryToolBar,
-1,
wxEmptyString,
wxPoint( -1, -1 ),
wxSize( LISTBOX_WIDTH + 20, -1 ),
wxTE_READONLY );
m_AuxiliaryToolBar->AddControl( m_ClearanceBox );
m_ClearanceBox = new wxTextCtrl( m_AuxiliaryToolBar, -1,
wxEmptyString, wxPoint( -1, -1 ),
wxSize( LISTBOX_WIDTH + 20, -1 ),
wxTE_READONLY );
m_ClearanceBox->SetToolTip(_("Current NetClass clearance value") );
m_AuxiliaryToolBar->AddControl( m_ClearanceBox );
m_AuxiliaryToolBar->AddSeparator();
// Creates box to display the current NetClass:
m_NetClassSelectedBox = new wxTextCtrl( m_AuxiliaryToolBar,
-1,
wxEmptyString,
wxPoint( -1, -1 ),
wxSize( LISTBOX_WIDTH, -1 ),
wxTE_READONLY );
m_AuxiliaryToolBar->AddControl( m_NetClassSelectedBox );
m_NetClassSelectedBox = new wxTextCtrl( m_AuxiliaryToolBar, -1,
wxEmptyString, wxPoint( -1, -1 ),
wxSize( LISTBOX_WIDTH, -1 ),
wxTE_READONLY );
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,
wxEmptyString,
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 );
// Add the box to display and select the current grid size:
......@@ -625,7 +627,9 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
else
{
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;
}
m_SelZoomBox->Append( msg );
......@@ -648,7 +652,8 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
for( i = 0; i < GetScreen()->m_GridList.GetCount(); 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( g_UnitMetric == INCHES )
......@@ -659,7 +664,11 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
else
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;
......
......@@ -133,18 +133,8 @@ void WinEDA_PcbFrame::AuxiliaryToolBar_Update_UI()
if( m_SelGridBox )
{
int kk = m_SelGridBox->GetChoice();
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_SelGridBox->SetSelection( ID_POPUP_GRID_LEVEL_1000 +
m_LastGridSizeId );
}
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