Gerbview: code cleanup and very minor fix.

This commit is contained in:
jean-pierre charras 2011-03-14 22:19:13 +01:00
parent fe6890a955
commit a97f5c2530
17 changed files with 432 additions and 401 deletions

View File

@ -33,7 +33,7 @@ set(GERBVIEW_SRCS
dcode.cpp
dummy_functions.cpp
draw_gerber_screen.cpp
edit.cpp
events_called_functions.cpp
export_to_pcbnew.cpp
files.cpp
gerbview.cpp
@ -43,6 +43,7 @@ set(GERBVIEW_SRCS
initpcb.cpp
locate.cpp
menubar.cpp
onleftclick.cpp
onrightclick.cpp
options.cpp
pcbplot.cpp

View File

@ -158,7 +158,7 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
wxString msg;
D_CODE* dcode;
FILE* dest;
int layer = GetScreen()->m_Active_Layer;
int layer = getActiveLayer();
int type_outil;
if( g_GERBER_List[layer] == NULL )

View File

@ -222,7 +222,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
int dcode_highlight = 0;
if( layer == m_PcbFrame->GetScreen()->m_Active_Layer )
if( layer == ((GERBVIEW_FRAME*)m_PcbFrame)->getActiveLayer() )
dcode_highlight = gerber->m_Selected_Tool;
int layerdrawMode = GR_COPY;

View File

@ -1,212 +0,0 @@
/***************************************/
/* edit.cpp: Gerbview events functions */
/***************************************/
#include "fctsys.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "common.h"
#include "gestfich.h"
#include "appl_wxstruct.h"
#include "gerbview.h"
#include "pcbplot.h"
#include "kicad_device_context.h"
#include "gerbview_id.h"
#include "class_GERBER.h"
#include "dialog_helpers.h"
#include "class_DCodeSelectionbox.h"
/* Process the command triggered by the left button of the mouse when a tool
* is already selected.
*/
void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
{
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem();
wxString msg;
if( GetToolId() == ID_NO_TOOL_SELECTED )
{
if( DrawStruct && DrawStruct->m_Flags )
{
msg.Printf( wxT( "GERBVIEW_FRAME::ProcessCommand err: Struct %d, m_Flags = %X" ),
(unsigned) DrawStruct->Type(),
(unsigned) DrawStruct->m_Flags );
DisplayError( this, msg );
}
else
{
DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE );
GetScreen()->SetCurItem( DrawStruct );
if( DrawStruct == NULL )
{
GERBER_IMAGE* gerber = g_GERBER_List[getActiveLayer() ];
if( gerber )
gerber->DisplayImageInfo( );
}
}
}
switch( GetToolId() )
{
case ID_NO_TOOL_SELECTED:
break;
if( DrawStruct == NULL )
break;
/* TODO:
Delete_Item( DC, (GERBER_DRAW_ITEM*) DrawStruct );
GetScreen()->SetCurItem( NULL );
GetScreen()->SetModify();
*/
break;
default:
DisplayError( this, wxT( "GERBVIEW_FRAME::ProcessCommand error" ) );
break;
}
}
/* Handles the selection of tools, menu, and popup menu commands.
*/
void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
int id = event.GetId();
int layer = GetScreen()->m_Active_Layer;
GERBER_IMAGE* gerber_layer = g_GERBER_List[layer];
wxPoint pos;
wxGetMousePosition( &pos.x, &pos.y );
pos.y += 20;
switch( id )
{
case wxID_CUT:
case wxID_COPY:
case ID_POPUP_DELETE_BLOCK:
case ID_POPUP_PLACE_BLOCK:
case ID_POPUP_ZOOM_BLOCK:
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
DrawPanel->EndMouseCapture( );
/* Should not be executed, except bug */
if( 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.ClearItemsList();
}
if( GetToolId() == ID_NO_TOOL_SELECTED )
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
else
DrawPanel->SetCursor( DrawPanel->GetDefaultCursor() );
break;
default:
DrawPanel->EndMouseCapture( );
break;
}
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
switch( id )
{
case ID_EXIT:
Close( true );
break;
case ID_GERBVIEW_GLOBAL_DELETE:
Erase_Current_Layer( true );
ClearMsgPanel();
break;
case ID_NO_TOOL_SELECTED:
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
case ID_POPUP_CLOSE_CURRENT_TOOL:
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
break;
case ID_TOOLBARH_GERBVIEW_SELECT_LAYER:
{
int layer = getActiveLayer( );
setActiveLayer(event.GetSelection());
if( layer != getActiveLayer( ) )
DrawPanel->ReDraw( &dc, false );
}
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;
case ID_GERBVIEW_SHOW_SOURCE:
if( gerber_layer )
{
wxString editorname = wxGetApp().GetEditorName();
if( !editorname.IsEmpty() )
{
wxFileName fn( gerber_layer->m_FileName );
ExecuteFile( this, editorname, QuoteFullPath( fn ) );
}
else
{
wxMessageBox(_("No editor defined. Please select one") );
}
}
break;
case ID_POPUP_PLACE_BLOCK:
GetScreen()->m_BlockLocate.m_Command = BLOCK_MOVE;
DrawPanel->m_AutoPAN_Request = FALSE;
HandleBlockPlace( &dc );
break;
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;
case ID_POPUP_DELETE_BLOCK:
GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE;
GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc );
break;
default:
wxMessageBox( wxT( "GERBVIEW_FRAME::Process_Special_Functions error" ) );
break;
}
}
/* Called on a double click of left mouse button.
*/
void GERBVIEW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
{
// Currently: no nothing
}

View File

@ -0,0 +1,294 @@
/**********************************************************/
/* events_called_functions.cpp: Gerbview events functions */
/**********************************************************/
#include "fctsys.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "common.h"
#include "gestfich.h"
#include "appl_wxstruct.h"
#include "gerbview.h"
#include "kicad_device_context.h"
#include "gerbview_id.h"
#include "class_GERBER.h"
#include "dialog_helpers.h"
#include "class_DCodeSelectionbox.h"
// Event table:
BEGIN_EVENT_TABLE( GERBVIEW_FRAME, PCB_BASE_FRAME )
EVT_CLOSE( GERBVIEW_FRAME::OnCloseWindow )
EVT_SIZE( GERBVIEW_FRAME::OnSize )
EVT_TOOL( wxID_FILE, GERBVIEW_FRAME::Files_io )
EVT_TOOL( ID_INC_LAYER_AND_APPEND_FILE, GERBVIEW_FRAME::Files_io )
EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, GERBVIEW_FRAME::Files_io )
EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, GERBVIEW_FRAME::Files_io )
EVT_TOOL( ID_NEW_BOARD, GERBVIEW_FRAME::Files_io )
// Menu Files:
EVT_MENU( wxID_FILE, GERBVIEW_FRAME::Files_io )
EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, GERBVIEW_FRAME::Files_io )
EVT_MENU( ID_NEW_BOARD, GERBVIEW_FRAME::Files_io )
EVT_MENU( ID_GEN_PLOT, GERBVIEW_FRAME::ToPlotter )
EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW, GERBVIEW_FRAME::ExportDataInPcbnewFormat )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, GERBVIEW_FRAME::OnFileHistory )
EVT_MENU( ID_EXIT, GERBVIEW_FRAME::Process_Special_Functions )
// menu Preferences
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
GERBVIEW_FRAME::Process_Config )
EVT_MENU( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_MENU( ID_GERBVIEW_OPTIONS_SETUP, GERBVIEW_FRAME::InstallGerberOptionsDialog )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, EDA_DRAW_FRAME::SetLanguage )
// menu Postprocess
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, GERBVIEW_FRAME::OnShowGerberSourceFile )
EVT_MENU( ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR,
EDA_BASE_FRAME::OnSelectPreferredEditor )
// menu Miscellaneous
EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE, GERBVIEW_FRAME::Process_Special_Functions )
// Menu Help
EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp )
EVT_MENU( ID_KICAD_ABOUT, EDA_DRAW_FRAME::GetKicadAbout )
EVT_TOOL( wxID_CUT, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_COPY, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_PRINT, GERBVIEW_FRAME::ToPrinter )
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 )
// Vertical toolbar:
EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
GERBVIEW_FRAME::Process_Special_Functions )
// Option toolbar
EVT_TOOL( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH,
GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2,
GERBVIEW_FRAME::OnSelectDisplayMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH,
GERBVIEW_FRAME::OnUpdateFlashedItemsDrawMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnUpdateLinesDrawMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH,
GERBVIEW_FRAME::OnUpdatePolygonsDrawMode )
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_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 )
END_EVENT_TABLE()
/* Handles the selection of tools, menu, and popup menu commands.
*/
void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
int id = event.GetId();
GERBER_IMAGE* gerber_layer = g_GERBER_List[getActiveLayer()];
switch( id )
{
case wxID_CUT:
case wxID_COPY:
case ID_POPUP_DELETE_BLOCK:
case ID_POPUP_PLACE_BLOCK:
case ID_POPUP_ZOOM_BLOCK:
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
DrawPanel->EndMouseCapture();
/* Should not be executed, except bug */
if( 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.ClearItemsList();
}
if( GetToolId() == ID_NO_TOOL_SELECTED )
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
else
DrawPanel->SetCursor( DrawPanel->GetDefaultCursor() );
break;
default:
DrawPanel->EndMouseCapture();
break;
}
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
switch( id )
{
case ID_EXIT:
Close( true );
break;
case ID_GERBVIEW_GLOBAL_DELETE:
Erase_Current_Layer( true );
ClearMsgPanel();
break;
case ID_NO_TOOL_SELECTED:
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
case ID_POPUP_CLOSE_CURRENT_TOOL:
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
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;
case ID_POPUP_PLACE_BLOCK:
GetScreen()->m_BlockLocate.m_Command = BLOCK_MOVE;
DrawPanel->m_AutoPAN_Request = FALSE;
HandleBlockPlace( &dc );
break;
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;
case ID_POPUP_DELETE_BLOCK:
GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE;
GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc );
break;
default:
wxFAIL_MSG( wxT( "GERBVIEW_FRAME::Process_Special_Functions error" ) );
break;
}
}
/* Selects the active layer:
* - if a file is loaded, it is loaded in this layer
* _ this layer is displayed on top of other layers
*/
void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
{
int layer = getActiveLayer();
setActiveLayer( event.GetSelection() );
if( layer != getActiveLayer() )
DrawPanel->Refresh();
}
/* Call preferred editor to show (and edit) the gerber source file
* loaded in the active layer
*/
void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event )
{
int layer = getActiveLayer();
GERBER_IMAGE* gerber_layer = g_GERBER_List[layer];
if( gerber_layer )
{
wxString editorname = wxGetApp().GetEditorName();
if( !editorname.IsEmpty() )
{
wxFileName fn( gerber_layer->m_FileName );
ExecuteFile( this, editorname, QuoteFullPath( fn ) );
}
else
{
wxMessageBox( _( "No editor defined. Please select one" ) );
}
}
}
/* Function OnSelectDisplayMode: called to select display mode
* (fast display, or exact mode with stacked images or with transparency
*/
void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event )
{
int oldMode = GetDisplayMode();
switch( event.GetId() )
{
case ID_TB_OPTIONS_SHOW_GBR_MODE_0:
SetDisplayMode( 0 );
break;
case ID_TB_OPTIONS_SHOW_GBR_MODE_1:
SetDisplayMode( 1 );
break;
case ID_TB_OPTIONS_SHOW_GBR_MODE_2:
SetDisplayMode( 2 );
break;
}
if( GetDisplayMode() != oldMode )
DrawPanel->Refresh();
}
/**
* Function SetLanguage
* called on a language menu selection
* Update Layer manager title and tabs texts
*/
void GERBVIEW_FRAME::SetLanguage( wxCommandEvent& event )
{
EDA_DRAW_FRAME::SetLanguage( event );
m_LayersManager->SetLayersManagerTabsText();
wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
pane_info.Caption( _( "Visibles" ) );
m_auimgr.Update();
ReFillLayerWidget();
}

View File

@ -9,6 +9,7 @@
#include "gestfich.h"
#include "gerbview.h"
#include "gerbview_id.h"
/* Load a Gerber file selected from history list on current layer

View File

@ -119,13 +119,14 @@ bool WinEDA_App::OnInit()
wxSetWorkingDirectory( fn.GetPath() );
// Load all files specified on the command line.
int jj = 0;
for( int ii = 1; ii < argc && ii <= LAYER_COUNT; ++ii )
{
fn = wxFileName( argv[ii] );
if( fn.FileExists() )
{
( (PCB_SCREEN*) frame->GetScreen() )->m_Active_Layer = ii - 1;
frame->setActiveLayer( jj++ );
frame->LoadGerberFiles( fn.GetFullPath() );
}
}

View File

@ -89,7 +89,7 @@ PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings( void )
WHITE ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true,
wxT( "DisplayPolairCoordinates" ),
wxT( "DisplayPolarCoordinates" ),
&DisplayOpt.DisplayPolarCood,
false ) );
@ -108,7 +108,7 @@ PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings( void )
// List of keywords used as identifiers in config
// they *must* be static const and not temporary created,
// because the parameter list that used these keywords does not store them,
// because the parameter list that use these keywords does not store them,
// just points on them
static const wxChar * keys[32] =
{

View File

@ -29,99 +29,6 @@ const wxString GerbviewShowDCodes( wxT( "ShowDCodesOpt" ) );
/* class GERBVIEW_FRAME for GerbView*/
/****************************************/
BEGIN_EVENT_TABLE( GERBVIEW_FRAME, PCB_BASE_FRAME )
EVT_CLOSE( GERBVIEW_FRAME::OnCloseWindow )
EVT_SIZE( GERBVIEW_FRAME::OnSize )
EVT_TOOL( wxID_FILE, GERBVIEW_FRAME::Files_io )
EVT_TOOL( ID_INC_LAYER_AND_APPEND_FILE, GERBVIEW_FRAME::Files_io )
EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, GERBVIEW_FRAME::Files_io )
EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, GERBVIEW_FRAME::Files_io )
EVT_TOOL( ID_NEW_BOARD, GERBVIEW_FRAME::Files_io )
// Menu Files:
EVT_MENU( wxID_FILE, GERBVIEW_FRAME::Files_io )
EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, GERBVIEW_FRAME::Files_io )
EVT_MENU( ID_NEW_BOARD, GERBVIEW_FRAME::Files_io )
EVT_MENU( ID_GEN_PLOT, GERBVIEW_FRAME::ToPlotter )
EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW, GERBVIEW_FRAME::ExportDataInPcbnewFormat )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, GERBVIEW_FRAME::OnFileHistory )
EVT_MENU( ID_EXIT, GERBVIEW_FRAME::Process_Special_Functions )
// menu Preferences
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
GERBVIEW_FRAME::Process_Config )
EVT_MENU( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_MENU( ID_GERBVIEW_OPTIONS_SETUP, GERBVIEW_FRAME::InstallGerberOptionsDialog )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, EDA_DRAW_FRAME::SetLanguage )
// menu Postprocess
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR,
EDA_BASE_FRAME::OnSelectPreferredEditor )
// menu Miscellaneous
EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE, GERBVIEW_FRAME::Process_Special_Functions )
// Menu Help
EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp )
EVT_MENU( ID_KICAD_ABOUT, EDA_DRAW_FRAME::GetKicadAbout )
EVT_TOOL( wxID_CUT, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_COPY, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_PRINT, GERBVIEW_FRAME::ToPrinter )
EVT_TOOL( ID_FIND_ITEMS, GERBVIEW_FRAME::Process_Special_Functions )
EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBVIEW_SELECT_LAYER,
GERBVIEW_FRAME::Process_Special_Functions )
EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_TOOL,
GERBVIEW_FRAME::Process_Special_Functions )
// Vertical toolbar:
EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
GERBVIEW_FRAME::Process_Special_Functions )
// Pop up menu
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, GERBVIEW_FRAME::Process_Special_Functions )
// Option toolbar
EVT_TOOL( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH,
GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2,
GERBVIEW_FRAME::OnSelectDisplayMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH,
GERBVIEW_FRAME::OnUpdateFlashedItemsDrawMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnUpdateLinesDrawMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH,
GERBVIEW_FRAME::OnUpdatePolygonsDrawMode )
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_GERBVIEW_SELECT_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 )
END_EVENT_TABLE()
GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
const wxString& title,
@ -463,23 +370,6 @@ void GERBVIEW_FRAME::syncLayerBox()
}
/**
* Function SetLanguage
* called on a language menu selection
* Update Layer manager title and tabs texts
*/
void GERBVIEW_FRAME::SetLanguage( wxCommandEvent& event )
{
EDA_DRAW_FRAME::SetLanguage( event );
m_LayersManager->SetLayersManagerTabsText();
wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
pane_info.Caption( _( "Visibles" ) );
m_auimgr.Update();
ReFillLayerWidget();
}
void GERBVIEW_FRAME::Liste_D_Codes()
{
int ii, jj;
@ -487,7 +377,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
wxString Line;
WinEDA_TextFrame* List;
int scale = 10000;
int curr_layer = GetScreen()->m_Active_Layer;
int curr_layer = getActiveLayer();
List = new WinEDA_TextFrame( this, _( "List D codes" ) );
@ -556,7 +446,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
*/
void GERBVIEW_FRAME::UpdateTitleAndInfo()
{
GERBER_IMAGE* gerber = g_GERBER_List[ GetScreen()->m_Active_Layer ];
GERBER_IMAGE* gerber = g_GERBER_List[ getActiveLayer() ];
wxString text;
// Display the gerber filename
@ -565,7 +455,7 @@ void GERBVIEW_FRAME::UpdateTitleAndInfo()
text = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
SetTitle( text );
SetStatusText( wxEmptyString, 0 );
text.Printf( _( "Layer %d not in use" ), GetScreen()->m_Active_Layer + 1 );
text.Printf( _( "Layer %d not in use" ), getActiveLayer() + 1 );
m_TextInfo->SetValue( text );
ClearMsgPanel();
return;
@ -593,29 +483,3 @@ void GERBVIEW_FRAME::UpdateTitleAndInfo()
m_TextInfo->SetValue( text );
}
/* Function OnSelectDisplayMode: called to select display mode
* (fast display, or exact mode with stacked images or with transparency
*/
void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event )
{
int oldMode = GetDisplayMode();
switch( event.GetId() )
{
case ID_TB_OPTIONS_SHOW_GBR_MODE_0:
SetDisplayMode( 0 );
break;
case ID_TB_OPTIONS_SHOW_GBR_MODE_1:
SetDisplayMode( 1 );
break;
case ID_TB_OPTIONS_SHOW_GBR_MODE_2:
SetDisplayMode( 2 );
break;
}
if( GetDisplayMode() != oldMode )
DrawPanel->Refresh();
}

View File

@ -16,27 +16,6 @@
#define NO_AVAILABLE_LAYERS -1
/**
* Command IDs for the gerber file viewer.
*
* Please add IDs that are unique to the gerber file viewer here and not in the
* global id.h file. This will prevent the entire project from being rebuilt
* when adding new command to the gerber file viewer.
*/
enum id_gerbview_frm {
// A MenuItem ID of Zero does not work under Mac,first id = 1
ID_GERBVIEW_SHOW_LIST_DCODES = 1,
ID_GERBVIEW_LOAD_DRILL_FILE,
ID_GERBVIEW_LOAD_DCODE_FILE,
ID_TOOLBARH_GERBER_SELECT_TOOL,
ID_MENU_INC_LAYER_AND_APPEND_FILE,
ID_INC_LAYER_AND_APPEND_FILE,
ID_GERBVIEW_SHOW_SOURCE,
ID_GERBVIEW_EXPORT_TO_PCBNEW,
ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS
};
class DCODE_SELECTION_BOX;
@ -81,6 +60,17 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
void OnCloseWindow( wxCloseEvent& Event );
// Virtual basic functions:
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void ReCreateHToolbar();
void ReCreateVToolbar();
void ReCreateOptToolbar();
void ReCreateMenuBar();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
int BestZoom();
/**
* Function ReportMessage
* Add a message (a string) in message list
@ -287,17 +277,23 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
virtual void SetLanguage( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event );
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void ReCreateHToolbar();
void ReCreateVToolbar();
void ReCreateOptToolbar();
void ReCreateMenuBar();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
int BestZoom();
void OnSelectOptionToolbar( wxCommandEvent& event );
/**
* Function OnSelectActiveLayer
* Selects the active layer:
* - if a file is loaded, it is loaded in this layer
* _ this layer is displayed on top of other layers
*/
void OnSelectActiveLayer( wxCommandEvent& event );
/**
* Function OnShowGerberSourceFile
* Call the preferred editor to show (and edit) the gerber source file
* loaded in the active layer
*/
void OnShowGerberSourceFile( wxCommandEvent& event );
/**
* Function OnSelectDisplayMode
* called on a display mode selection
@ -305,6 +301,7 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
* or exact mode with stacked images or with transparency
*/
void OnSelectDisplayMode( wxCommandEvent& event );
void OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct );
GERBER_DRAW_ITEM* GerberGeneralLocateAndDisplay();

View File

@ -15,10 +15,19 @@ enum gerbview_ids
{
ID_MAIN_MENUBAR = ID_END_LIST,
ID_GERBVIEW_SHOW_LIST_DCODES = 1,
ID_GERBVIEW_LOAD_DRILL_FILE,
ID_GERBVIEW_LOAD_DCODE_FILE,
ID_TOOLBARH_GERBER_SELECT_TOOL,
ID_MENU_INC_LAYER_AND_APPEND_FILE,
ID_INC_LAYER_AND_APPEND_FILE,
ID_GERBVIEW_SHOW_SOURCE,
ID_GERBVIEW_EXPORT_TO_PCBNEW,
ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR,
ID_TOOLBARH_GERBVIEW_SELECT_LAYER,
ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,
ID_GERBVIEW_GLOBAL_DELETE,
ID_GERBVIEW_OPTIONS_SETUP,
ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,

View File

@ -4,10 +4,11 @@
#include "fctsys.h"
#include "common.h"
#include "hotkeys.h"
#include "kicad_device_context.h"
#include "gerbview.h"
#include "class_drawpanel.h"
#include "hotkeys.h"
/* How to add a new hotkey:
* add a new id in the enum hotkey_id_commnand like MY_NEW_ID_FUNCTION.
@ -139,13 +140,19 @@ void GERBVIEW_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
break;
case HK_SWITCH_LAYER_TO_PREVIOUS:
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer > 0 )
((PCB_SCREEN*)GetScreen())->m_Active_Layer--;
if( getActiveLayer() > 0 )
{
setActiveLayer( getActiveLayer() - 1 );
DrawPanel->Refresh();
}
break;
case HK_SWITCH_LAYER_TO_NEXT:
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer < 31 )
((PCB_SCREEN*)GetScreen())->m_Active_Layer++;
if( getActiveLayer() < 31 )
{
setActiveLayer( getActiveLayer() + 1 );
DrawPanel->Refresh();
}
break;
}
}

View File

@ -19,7 +19,7 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc
if( aTypeloc == CURSEUR_ON_GRILLE )
ref = GetScreen()->GetNearestGridPosition( ref );
int layer = GetScreen()->m_Active_Layer;
int layer = getActiveLayer();
// Search first on active layer
BOARD_ITEM* item = GetBoard()->m_Drawings;

69
gerbview/onleftclick.cpp Normal file
View File

@ -0,0 +1,69 @@
/******************************************************************/
/* onleftclick.cpp: functions called on left or double left click */
/******************************************************************/
#include "fctsys.h"
#include "class_drawpanel.h"
#include "common.h"
//#include "gestfich.h"
//#include "appl_wxstruct.h"
#include "gerbview.h"
//#include "pcbplot.h"
//#include "kicad_device_context.h"
#include "gerbview_id.h"
#include "class_GERBER.h"
#include "dialog_helpers.h"
#include "class_DCodeSelectionbox.h"
/* Process the command triggered by the left button of the mouse when a tool
* is already selected.
*/
void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
{
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem();
wxString msg;
if( GetToolId() == ID_NO_TOOL_SELECTED )
{
if( DrawStruct && DrawStruct->m_Flags )
{
msg.Printf( wxT( "GERBVIEW_FRAME::OnLeftClick err: Struct %d, m_Flags = %X" ),
(unsigned) DrawStruct->Type(),
(unsigned) DrawStruct->m_Flags );
wxFAIL_MSG( msg );
}
else
{
DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE );
GetScreen()->SetCurItem( DrawStruct );
if( DrawStruct == NULL )
{
GERBER_IMAGE* gerber = g_GERBER_List[getActiveLayer() ];
if( gerber )
gerber->DisplayImageInfo( );
}
}
}
switch( GetToolId() )
{
case ID_NO_TOOL_SELECTED:
break;
if( DrawStruct == NULL )
break;
default:
wxFAIL_MSG( wxT( "GERBVIEW_FRAME::ProcessCommand error" ) );
break;
}
}
/* Called on a double click of left mouse button.
*/
void GERBVIEW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
{
// Currently: no nothing
}

View File

@ -26,7 +26,7 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName,
char* text;
int layer; /* current layer used in gerbview */
layer = GetScreen()->m_Active_Layer;
layer = getActiveLayer();
if( g_GERBER_List[layer] == NULL )
{

View File

@ -570,7 +570,7 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
GERBER_DRAW_ITEM* gbritem;
BOARD* pcb = m_Parent->GetBoard();
int activeLayer = m_Parent->GetScreen()->m_Active_Layer;
int activeLayer = m_Parent->getActiveLayer();
int dcode = 0;
D_CODE* tool = NULL;

View File

@ -28,7 +28,7 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void )
if( GetScreen() )
{
layer = GetScreen()->m_Active_Layer;
layer = getActiveLayer();
gerber = g_GERBER_List[layer];
}
@ -70,7 +70,7 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void )
choices.Add( msg );
}
m_SelLayerBox = new WinEDALayerChoiceBox( m_HToolBar, ID_TOOLBARH_GERBVIEW_SELECT_LAYER,
m_SelLayerBox = new WinEDALayerChoiceBox( m_HToolBar, ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,
wxDefaultPosition, wxSize( 150, -1 ), choices );
m_HToolBar->AddControl( m_SelLayerBox );
@ -260,7 +260,7 @@ void GERBVIEW_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent )
void GERBVIEW_FRAME::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent )
{
int layer = GetScreen()->m_Active_Layer;
int layer = getActiveLayer();
GERBER_IMAGE* gerber = g_GERBER_List[layer];
int selected = ( gerber ) ? gerber->m_Selected_Tool : 0;
@ -273,8 +273,8 @@ void GERBVIEW_FRAME::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent )
void GERBVIEW_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
{
if( m_SelLayerBox && (m_SelLayerBox->GetSelection() != GetScreen()->m_Active_Layer) )
if( m_SelLayerBox && (m_SelLayerBox->GetSelection() != getActiveLayer()) )
{
m_SelLayerBox->SetSelection( GetScreen()->m_Active_Layer );
m_SelLayerBox->SetSelection( getActiveLayer() );
}
}