From 0d740e45e33eed748702e556b694d6787b224b53 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 16 Mar 2011 11:47:15 +0100 Subject: [PATCH] Minor fixes and code cleanup. --- cvpcb/readschematicnetlist.cpp | 9 +++--- gerbview/class_GERBER.h | 4 +-- gerbview/events_called_functions.cpp | 41 ++++++++++++++-------------- gerbview/gerbview_frame.h | 7 +++++ gerbview/gerbview_id.h | 2 +- gerbview/readgerb.cpp | 6 ++-- gerbview/rs274d.cpp | 10 +++---- gerbview/toolbars_gerber.cpp | 7 +++-- 8 files changed, 46 insertions(+), 40 deletions(-) diff --git a/cvpcb/readschematicnetlist.cpp b/cvpcb/readschematicnetlist.cpp index e41cdf0128..a37ee38993 100644 --- a/cvpcb/readschematicnetlist.cpp +++ b/cvpcb/readschematicnetlist.cpp @@ -112,14 +112,11 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist() // FILE_LINE_READER will close the file. 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" ) * or "# EESchema Netlist" */ netlistReader.ReadLine(); + const char* Line = netlistReader.Line(); /* test for netlist type PCB2 */ idx = strnicmp( Line, "( {", 3 ); @@ -150,6 +147,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist() if( netlistReader.ReadLine( ) == 0 ) break; + Line = netlistReader.Line(); /* Remove blanks */ idx = 0; @@ -316,7 +314,6 @@ int ReadFootprintFilterList( FILE_LINE_READER& aNetlistReader, COMPONENT_LIST& int ReadPinConnection( FILE_LINE_READER& aNetlistReader, COMPONENT* Cmp ) { int i, jj; - char* Line = aNetlistReader; char cbuffer[BUFFER_CHAR_SIZE]; for( ; ; ) @@ -327,6 +324,8 @@ int ReadPinConnection( FILE_LINE_READER& aNetlistReader, COMPONENT* Cmp ) if( aNetlistReader.ReadLine() == 0 ) return -1; + char* Line = aNetlistReader.Line(); + /* Remove blanks from the beginning of the line. */ i = 0; while( Line[i] == ' ' ) i++; diff --git a/gerbview/class_GERBER.h b/gerbview/class_GERBER.h index 87c4b4112d..e7ff3f1dc9 100644 --- a/gerbview/class_GERBER.h +++ b/gerbview/class_GERBER.h @@ -200,8 +200,8 @@ public: int ReturnDCodeNumber( char*& Text ); // functions to execute G commands or D commands: - bool Execute_G_Command( char*& text, int G_commande ); - bool Execute_DCODE_Command( char*& text, int D_commande ); + bool Execute_G_Command( char*& text, int G_command ); + bool Execute_DCODE_Command( char*& text, int D_command ); /** * Function ReadRS274XCommand diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index f5eb6883dc..4232049daf 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -71,8 +71,7 @@ EVT_TOOL( ID_FIND_ITEMS, GERBVIEW_FRAME::Process_Special_Functions ) EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnSelectActiveLayer ) -EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_TOOL, - GERBVIEW_FRAME::Process_Special_Functions ) +EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnSelectActiveDCode ) // Vertical toolbar: 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, 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_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2, GERBVIEW_FRAME::OnUpdateDrawMode ) @@ -112,7 +111,6 @@ END_EVENT_TABLE() void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) { int id = event.GetId(); - GERBER_IMAGE* gerber_layer = g_GERBER_List[getActiveLayer()]; switch( id ) { @@ -126,9 +124,9 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_CANCEL_CURRENT_COMMAND: DrawPanel->EndMouseCapture(); - /* Should not be executed, except bug */ 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_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.ClearItemsList(); @@ -137,8 +135,7 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( GetToolId() == ID_NO_TOOL_SELECTED ) SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString ); else - DrawPanel->SetCursor( DrawPanel->GetDefaultCursor() ); - + DrawPanel->SetCursor( DrawPanel->GetCurrentCursor() ); break; default: @@ -170,18 +167,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_CANCEL_CURRENT_COMMAND: 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: Liste_D_Codes(); break; @@ -195,7 +180,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_ZOOM_BLOCK: GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM; GetScreen()->m_BlockLocate.SetMessageBlock( this ); - GetScreen()->m_BlockLocate.SetMessageBlock( this ); HandleBlockEnd( &dc ); 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: * - if a file is loaded, it is loaded in this layer * _ this layer is displayed on top of other layers diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index d2e1f3c156..3619c0feff 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -279,6 +279,13 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title, void Process_Special_Functions( 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 * Selects the active layer: diff --git a/gerbview/gerbview_id.h b/gerbview/gerbview_id.h index 0d84250b7a..f3f5d6422b 100644 --- a/gerbview/gerbview_id.h +++ b/gerbview/gerbview_id.h @@ -18,7 +18,7 @@ enum gerbview_ids ID_GERBVIEW_SHOW_LIST_DCODES = 1, ID_GERBVIEW_LOAD_DRILL_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_INC_LAYER_AND_APPEND_FILE, ID_GERBVIEW_SHOW_SOURCE, diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp index 62be9d0216..561ccfcc75 100644 --- a/gerbview/readgerb.cpp +++ b/gerbview/readgerb.cpp @@ -17,7 +17,7 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_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 char line[GERBER_BUFZ]; @@ -96,8 +96,8 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName, break; case 'G': /* Line type Gxx : command */ - G_commande = gerber->ReturnGCodeNumber( text ); - gerber->Execute_G_Command( text, G_commande ); + G_command = gerber->ReturnGCodeNumber( text ); + gerber->Execute_G_Command( text, G_command ); break; case 'D': /* Line type Dxx : Tool selection (xx > 0) or diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index fd447f35f0..d3ddf04e96 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -67,8 +67,6 @@ #define GERB_STOP_DRAW 2 // Extinguish light (lift pen) #define GERB_FLASH 3 // Flash -static wxPoint LastPosition; - /* 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 // be safely ignored @@ -534,7 +532,7 @@ bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_commande ) default: { 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 ); return false; } diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 45682c492c..f1826fa594 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -86,9 +86,10 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void ) m_DCodesList.Add( msg ); } - m_DCodeSelector = new DCODE_SELECTION_BOX( m_HToolBar, ID_TOOLBARH_GERBER_SELECT_TOOL, - wxDefaultPosition, wxSize( 150, -1 ), - m_DCodesList ); + m_DCodeSelector = new DCODE_SELECTION_BOX( + m_HToolBar, ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, + wxDefaultPosition, wxSize( 150, -1 ), + m_DCodesList ); m_HToolBar->AddControl( m_DCodeSelector ); m_TextInfo = new wxTextCtrl( m_HToolBar, wxID_ANY, wxEmptyString, wxDefaultPosition,