Minor fixes and code cleanup.

This commit is contained in:
jean-pierre charras 2011-03-16 11:47:15 +01:00
parent a97f5c2530
commit 0d740e45e3
8 changed files with 46 additions and 40 deletions

View File

@ -112,14 +112,11 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
// FILE_LINE_READER will close the file. // FILE_LINE_READER will close the file.
FILE_LINE_READER netlistReader( source, m_NetlistFileName.GetFullPath() ); FILE_LINE_READER netlistReader( source, m_NetlistFileName.GetFullPath() );
// hopes netlistReader's line buffer does not move. It won't unless you encounter
// a line larger than LINE_READER_LINE_INITIAL_SIZE = 5000
const char* Line = netlistReader.Line();
/* Read the file header (must be "( { OrCAD PCB" or "({ OrCAD PCB" ) /* Read the file header (must be "( { OrCAD PCB" or "({ OrCAD PCB" )
* or "# EESchema Netlist" * or "# EESchema Netlist"
*/ */
netlistReader.ReadLine(); netlistReader.ReadLine();
const char* Line = netlistReader.Line();
/* test for netlist type PCB2 */ /* test for netlist type PCB2 */
idx = strnicmp( Line, "( {", 3 ); idx = strnicmp( Line, "( {", 3 );
@ -150,6 +147,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
if( netlistReader.ReadLine( ) == 0 ) if( netlistReader.ReadLine( ) == 0 )
break; break;
Line = netlistReader.Line();
/* Remove blanks */ /* Remove blanks */
idx = 0; idx = 0;
@ -316,7 +314,6 @@ int ReadFootprintFilterList( FILE_LINE_READER& aNetlistReader, COMPONENT_LIST&
int ReadPinConnection( FILE_LINE_READER& aNetlistReader, COMPONENT* Cmp ) int ReadPinConnection( FILE_LINE_READER& aNetlistReader, COMPONENT* Cmp )
{ {
int i, jj; int i, jj;
char* Line = aNetlistReader;
char cbuffer[BUFFER_CHAR_SIZE]; char cbuffer[BUFFER_CHAR_SIZE];
for( ; ; ) for( ; ; )
@ -327,6 +324,8 @@ int ReadPinConnection( FILE_LINE_READER& aNetlistReader, COMPONENT* Cmp )
if( aNetlistReader.ReadLine() == 0 ) if( aNetlistReader.ReadLine() == 0 )
return -1; return -1;
char* Line = aNetlistReader.Line();
/* Remove blanks from the beginning of the line. */ /* Remove blanks from the beginning of the line. */
i = 0; while( Line[i] == ' ' ) i = 0; while( Line[i] == ' ' )
i++; i++;

View File

@ -200,8 +200,8 @@ public:
int ReturnDCodeNumber( char*& Text ); int ReturnDCodeNumber( char*& Text );
// functions to execute G commands or D commands: // functions to execute G commands or D commands:
bool Execute_G_Command( char*& text, int G_commande ); bool Execute_G_Command( char*& text, int G_command );
bool Execute_DCODE_Command( char*& text, int D_commande ); bool Execute_DCODE_Command( char*& text, int D_command );
/** /**
* Function ReadRS274XCommand * Function ReadRS274XCommand

View File

@ -71,8 +71,7 @@ EVT_TOOL( ID_FIND_ITEMS, GERBVIEW_FRAME::Process_Special_Functions )
EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,
GERBVIEW_FRAME::OnSelectActiveLayer ) GERBVIEW_FRAME::OnSelectActiveLayer )
EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_TOOL, EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnSelectActiveDCode )
GERBVIEW_FRAME::Process_Special_Functions )
// Vertical toolbar: // Vertical toolbar:
EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions ) EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions )
@ -100,7 +99,7 @@ EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_DCODES, GERBVIEW_FRAME::OnUpdateShowDCodes )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
GERBVIEW_FRAME::OnUpdateShowLayerManager ) GERBVIEW_FRAME::OnUpdateShowLayerManager )
EVT_UPDATE_UI( ID_TOOLBARH_GERBER_SELECT_TOOL, GERBVIEW_FRAME::OnUpdateSelectDCode ) EVT_UPDATE_UI( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnUpdateSelectDCode )
EVT_UPDATE_UI( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnUpdateLayerSelectBox ) EVT_UPDATE_UI( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnUpdateLayerSelectBox )
EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2, EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2,
GERBVIEW_FRAME::OnUpdateDrawMode ) GERBVIEW_FRAME::OnUpdateDrawMode )
@ -112,7 +111,6 @@ END_EVENT_TABLE()
void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
GERBER_IMAGE* gerber_layer = g_GERBER_List[getActiveLayer()];
switch( id ) switch( id )
{ {
@ -126,9 +124,9 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_CANCEL_CURRENT_COMMAND: case ID_POPUP_CANCEL_CURRENT_COMMAND:
DrawPanel->EndMouseCapture(); DrawPanel->EndMouseCapture();
/* Should not be executed, except bug */
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE ) if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE )
{ {
/* Should not be executed, except bug */
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
@ -137,8 +135,7 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( GetToolId() == ID_NO_TOOL_SELECTED ) if( GetToolId() == ID_NO_TOOL_SELECTED )
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString ); SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
else else
DrawPanel->SetCursor( DrawPanel->GetDefaultCursor() ); DrawPanel->SetCursor( DrawPanel->GetCurrentCursor() );
break; break;
default: default:
@ -170,18 +167,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_CANCEL_CURRENT_COMMAND: case ID_POPUP_CANCEL_CURRENT_COMMAND:
break; break;
case ID_TOOLBARH_GERBER_SELECT_TOOL:
if( gerber_layer )
{
int tool = m_DCodeSelector->GetSelectedDCodeId();
if( tool != gerber_layer->m_Selected_Tool )
{
gerber_layer->m_Selected_Tool = tool;
DrawPanel->ReDraw( &dc, false );
}
}
break;
case ID_GERBVIEW_SHOW_LIST_DCODES: case ID_GERBVIEW_SHOW_LIST_DCODES:
Liste_D_Codes(); Liste_D_Codes();
break; break;
@ -195,7 +180,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_ZOOM_BLOCK:
GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM; GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM;
GetScreen()->m_BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
@ -212,6 +196,23 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
} }
/* Selects the active DCode for the current active layer.
* Items using this DCode are hightlighted
*/
void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
{
GERBER_IMAGE* gerber_image = g_GERBER_List[getActiveLayer()];
if( gerber_image )
{
int tool = m_DCodeSelector->GetSelectedDCodeId();
if( tool != gerber_image->m_Selected_Tool )
{
gerber_image->m_Selected_Tool = tool;
DrawPanel->Refresh();
}
}
}
/* Selects the active layer: /* Selects the active layer:
* - if a file is loaded, it is loaded in this layer * - if a file is loaded, it is loaded in this layer
* _ this layer is displayed on top of other layers * _ this layer is displayed on top of other layers

View File

@ -279,6 +279,13 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
void OnSelectOptionToolbar( wxCommandEvent& event ); void OnSelectOptionToolbar( wxCommandEvent& event );
/**
* Function OnSelectActiveDCode
* Selects the active DCode for the current active layer.
* Items using this DCode are hightlighted
*/
void OnSelectActiveDCode( wxCommandEvent& event );
/** /**
* Function OnSelectActiveLayer * Function OnSelectActiveLayer
* Selects the active layer: * Selects the active layer:

View File

@ -18,7 +18,7 @@ enum gerbview_ids
ID_GERBVIEW_SHOW_LIST_DCODES = 1, ID_GERBVIEW_SHOW_LIST_DCODES = 1,
ID_GERBVIEW_LOAD_DRILL_FILE, ID_GERBVIEW_LOAD_DRILL_FILE,
ID_GERBVIEW_LOAD_DCODE_FILE, ID_GERBVIEW_LOAD_DCODE_FILE,
ID_TOOLBARH_GERBER_SELECT_TOOL, ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE,
ID_MENU_INC_LAYER_AND_APPEND_FILE, ID_MENU_INC_LAYER_AND_APPEND_FILE,
ID_INC_LAYER_AND_APPEND_FILE, ID_INC_LAYER_AND_APPEND_FILE,
ID_GERBVIEW_SHOW_SOURCE, ID_GERBVIEW_SHOW_SOURCE,

View File

@ -17,7 +17,7 @@
bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName, bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName,
const wxString& D_Code_FullFileName ) const wxString& D_Code_FullFileName )
{ {
int G_commande = 0; // command number for G commands like G04 int G_command = 0; // command number for G commands like G04
int D_commande = 0; // command number for D commands like D02 int D_commande = 0; // command number for D commands like D02
char line[GERBER_BUFZ]; char line[GERBER_BUFZ];
@ -96,8 +96,8 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName,
break; break;
case 'G': /* Line type Gxx : command */ case 'G': /* Line type Gxx : command */
G_commande = gerber->ReturnGCodeNumber( text ); G_command = gerber->ReturnGCodeNumber( text );
gerber->Execute_G_Command( text, G_commande ); gerber->Execute_G_Command( text, G_command );
break; break;
case 'D': /* Line type Dxx : Tool selection (xx > 0) or case 'D': /* Line type Dxx : Tool selection (xx > 0) or

View File

@ -67,8 +67,6 @@
#define GERB_STOP_DRAW 2 // Extinguish light (lift pen) #define GERB_STOP_DRAW 2 // Extinguish light (lift pen)
#define GERB_FLASH 3 // Flash #define GERB_FLASH 3 // Flash
static wxPoint LastPosition;
/* Local Functions (are lower case since they are private to this source file) /* Local Functions (are lower case since they are private to this source file)
**/ **/
@ -433,11 +431,11 @@ int GERBER_IMAGE::ReturnDCodeNumber( char*& Text )
} }
bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_commande ) bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_command )
{ {
// D( printf( "%22s: G_CODE<%d>\n", __func__, G_commande ); ) // D( printf( "%22s: G_CODE<%d>\n", __func__, G_command ); )
switch( G_commande ) switch( G_command )
{ {
case GC_PHOTO_MODE: // can starts a D03 flash command: redundant, can case GC_PHOTO_MODE: // can starts a D03 flash command: redundant, can
// be safely ignored // be safely ignored
@ -534,7 +532,7 @@ bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_commande )
default: default:
{ {
wxString msg; wxString msg;
msg.Printf( wxT( "G%0.2d command not handled" ), G_commande ); msg.Printf( wxT( "G%0.2d command not handled" ), G_command );
ReportMessage( msg ); ReportMessage( msg );
return false; return false;
} }

View File

@ -86,7 +86,8 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void )
m_DCodesList.Add( msg ); m_DCodesList.Add( msg );
} }
m_DCodeSelector = new DCODE_SELECTION_BOX( m_HToolBar, ID_TOOLBARH_GERBER_SELECT_TOOL, m_DCodeSelector = new DCODE_SELECTION_BOX(
m_HToolBar, ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE,
wxDefaultPosition, wxSize( 150, -1 ), wxDefaultPosition, wxSize( 150, -1 ),
m_DCodesList ); m_DCodesList );
m_HToolBar->AddControl( m_DCodeSelector ); m_HToolBar->AddControl( m_DCodeSelector );