From 259d9a024cc4ef778f4e59443cd669cfae427c09 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 24 Nov 2010 16:10:33 +0100 Subject: [PATCH] Pcbnew: gen drill files code cleanup. Fix minor bug 680558 --- include/class_board_item.h | 10 + pcbnew/CMakeLists.txt | 52 +- pcbnew/dialog_gendrill.cpp | 85 -- pcbnew/dialog_gendrill.h | 59 -- pcbnew/dialogs/dialog_gendrill.cpp | 288 ++++++ pcbnew/dialogs/dialog_gendrill.h | 68 ++ pcbnew/{ => dialogs}/dialog_gendrill_base.cpp | 15 +- pcbnew/{ => dialogs}/dialog_gendrill_base.fbp | 123 ++- pcbnew/{ => dialogs}/dialog_gendrill_base.h | 13 +- pcbnew/gendrill.cpp | 469 +++------ pcbnew/gendrill.h | 26 +- pcbnew/hotkeys.cpp | 976 +----------------- pcbnew/hotkeys.h | 19 +- pcbnew/hotkeys_board_editor.cpp | 675 ++++++++++++ pcbnew/hotkeys_module_editor.cpp | 308 ++++++ pcbnew/menubar_pcbframe.cpp | 18 +- pcbnew/modedit_onclick.cpp | 20 +- pcbnew/moduleframe.cpp | 2 +- pcbnew/onrightclick.cpp | 60 +- pcbnew/pcbframe.cpp | 2 +- pcbnew/pcbnew.cpp | 2 +- pcbnew/pcbnew_config.cpp | 8 +- pcbnew/tool_modedit.cpp | 8 +- pcbnew/tool_pcb.cpp | 16 +- 24 files changed, 1754 insertions(+), 1568 deletions(-) delete mode 100644 pcbnew/dialog_gendrill.cpp delete mode 100644 pcbnew/dialog_gendrill.h create mode 100644 pcbnew/dialogs/dialog_gendrill.cpp create mode 100644 pcbnew/dialogs/dialog_gendrill.h rename pcbnew/{ => dialogs}/dialog_gendrill_base.cpp (94%) rename pcbnew/{ => dialogs}/dialog_gendrill_base.fbp (88%) rename pcbnew/{ => dialogs}/dialog_gendrill_base.h (80%) create mode 100644 pcbnew/hotkeys_board_editor.cpp create mode 100644 pcbnew/hotkeys_module_editor.cpp diff --git a/include/class_board_item.h b/include/class_board_item.h index 6cf5542261..0b3a4587f3 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -111,6 +111,16 @@ public: return m_Layer == aLayer; } + /** + * Function IsTrack + * tests to see if this object is a track or via (or microvia). + * form of testing. + * @return bool - true if a track or via, else false. + */ + bool IsTrack( ) const + { + return (Type() == TYPE_TRACK) || (Type() == TYPE_VIA); + } /** * Function IsLocked diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index c2e1a41ee2..1507c2c590 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -21,26 +21,7 @@ else( USE_BOOST_POLYGON_LIBRARY ) set(PCBNEW_SRC_FILL_ZONE zones_convert_brd_items_to_polygons_with_Kbool.cpp) endif( USE_BOOST_POLYGON_LIBRARY ) -set(PCBNEW_SRCS - pcbframe.cpp - attribut.cpp - automove.cpp - autoplac.cpp - autorout.cpp - board.cpp - board_items_to_polygon_shape_transform.cpp - board_undo_redo.cpp - block.cpp - block_module_editor.cpp - build_BOM_from_board.cpp - class_pcb_layer_widget.cpp - clean.cpp - connect.cpp - controle.cpp - dimension.cpp - cross-probing.cpp - debug_kbool_key_file_fct.cpp - deltrack.cpp +set(PCBNEW_DIALOGS dialogs/dialog_block_options_base.cpp dialogs/dialog_cleaning_options_base.cpp dialogs/dialog_cleaning_options.cpp @@ -62,8 +43,8 @@ set(PCBNEW_SRCS dialog_export_3Dfiles_base.cpp dialog_freeroute_exchange.cpp dialog_freeroute_exchange_base.cpp - dialog_gendrill.cpp - dialog_gendrill_base.cpp + dialogs/dialog_gendrill.cpp + dialogs/dialog_gendrill_base.cpp dialog_general_options.cpp dialog_general_options_BoardEditor_base.cpp dialog_global_edit_tracks_and_vias.cpp @@ -73,8 +54,6 @@ set(PCBNEW_SRCS dialog_graphic_items_options_base.cpp dialog_graphic_item_properties.cpp dialog_graphic_item_properties_base.cpp -# dialog_initpcb.cpp - dialog_layers_setup.cpp dialog_layers_setup_base.cpp dialog_netlist.cpp @@ -96,6 +75,29 @@ set(PCBNEW_SRCS dialog_SVG_print.cpp dialog_SVG_print_base.cpp dialog_set_grid_base.cpp + ) + +set(PCBNEW_SRCS + pcbframe.cpp + attribut.cpp + automove.cpp + autoplac.cpp + autorout.cpp + board.cpp + board_items_to_polygon_shape_transform.cpp + board_undo_redo.cpp + block.cpp + block_module_editor.cpp + build_BOM_from_board.cpp + class_pcb_layer_widget.cpp + clean.cpp + connect.cpp + controle.cpp + dimension.cpp + cross-probing.cpp + debug_kbool_key_file_fct.cpp + deltrack.cpp + ${PCBNEW_DIALOGS} dist.cpp dragsegm.cpp drc.cpp @@ -123,6 +125,8 @@ set(PCBNEW_SRCS gpcb_exchange.cpp graphpcb.cpp hotkeys.cpp + hotkeys_board_editor.cpp + hotkeys_module_editor.cpp initpcb.cpp ioascii.cpp layer_widget.cpp diff --git a/pcbnew/dialog_gendrill.cpp b/pcbnew/dialog_gendrill.cpp deleted file mode 100644 index 01965715a8..0000000000 --- a/pcbnew/dialog_gendrill.cpp +++ /dev/null @@ -1,85 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dialog_gendrill.cpp -// Author: jean-pierre Charras -// Licence: GPL -///////////////////////////////////////////////////////////////////////////// - -#include "fctsys.h" -#include "pcbnew.h" -#include "wxPcbStruct.h" -#include "gendrill.h" - -#include "dialog_gendrill.h" - - -DIALOG_GENDRILL::DIALOG_GENDRILL( WinEDA_PcbFrame* parent ) - : DIALOG_GENDRILL_BASE( parent ) -{ - m_Parent = parent; - - SetReturnCode( 1 ); - initDialog(); - GetSizer()->SetSizeHints( this ); - Centre( ); -} - - -/*! - * DIALOG_GENDRILL destructor - */ - -DIALOG_GENDRILL::~DIALOG_GENDRILL() -{ -} - - -/*! - * Member initialisation - */ - -void DIALOG_GENDRILL::initDialog() -{ - SetFocus(); // Under wxGTK: mandatory to close dialog by the ESC key - InitDisplayParams(); -} - - -/*! - * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX - */ - -void DIALOG_GENDRILL::OnSelDrillUnitsSelected( wxCommandEvent& event ) -{ - UpdatePrecisionOptions(event); -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK - */ - -void DIALOG_GENDRILL::OnOkClick( wxCommandEvent& event ) -{ - GenDrillFiles(event); -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE - */ - -void DIALOG_GENDRILL::OnCancelClick( wxCommandEvent& event ) -{ - UpdateConfig(); /* Save drill options: */ - event.Skip(); // Process the default cancel event (close dialog) -} - -/*! - * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SEL_ZEROS_FMT - */ - -void DIALOG_GENDRILL::OnSelZerosFmtSelected( wxCommandEvent& event ) -{ - UpdatePrecisionOptions(event); -} - diff --git a/pcbnew/dialog_gendrill.h b/pcbnew/dialog_gendrill.h deleted file mode 100644 index 4f63c9fc7b..0000000000 --- a/pcbnew/dialog_gendrill.h +++ /dev/null @@ -1,59 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dialog_gendrill.h -// Author: jean-pierre Charras -// Created: 2010 apr 30 -// Licence: GPL -///////////////////////////////////////////////////////////////////////////// - -#ifndef _DIALOG_GENDRILL_H_ -#define _DIALOG_GENDRILL_H_ - -#include "dialog_gendrill_base.h" - -class DIALOG_GENDRILL: public DIALOG_GENDRILL_BASE -{ - -private: - WinEDA_PcbFrame* m_Parent; - int m_PadsHoleCount; - int m_ThroughViasCount; - int m_MicroViasCount; - int m_BlindOrBuriedViasCount; - -public: - DIALOG_GENDRILL( WinEDA_PcbFrame* parent ); - ~DIALOG_GENDRILL(); - -private: - /// Initialises member variables - void initDialog(); - - /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SEL_DRILL_UNITS - void OnSelDrillUnitsSelected( wxCommandEvent& event ); - - /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SEL_ZEROS_FMT - void OnSelZerosFmtSelected( wxCommandEvent& event ); - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK - void OnOkClick( wxCommandEvent& event ); - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - void OnCancelClick( wxCommandEvent& event ); - - -private: - void InitDisplayParams(void); - void SetParams(void); - void GenDrillFiles( wxCommandEvent& event ); - void GenDrillMap( const wxString aFileName, std::vector & aHoleListBuffer, std::vector & aToolListBuffer, int format ); - void UpdatePrecisionOptions( wxCommandEvent& event ); - void UpdateConfig(); - void Write_Excellon_Header( FILE * aFile); - void GenDrillReport( const wxString aFileName ); - int Create_Drill_File_EXCELLON(FILE *excellon_dest, - std::vector & aHoleListBuffer, - std::vector & aToolListBuffer ); - int Gen_Liste_Tools( std::vector & buffer, bool print_header ); -}; - -#endif // _DIALOG_GENDRILL_H_ diff --git a/pcbnew/dialogs/dialog_gendrill.cpp b/pcbnew/dialogs/dialog_gendrill.cpp new file mode 100644 index 0000000000..dc49eeaed0 --- /dev/null +++ b/pcbnew/dialogs/dialog_gendrill.cpp @@ -0,0 +1,288 @@ +///////////////////////////////////////////////////////////////////////////// + +// Name: dialog_gendrill.cpp +// Author: jean-pierre Charras +// Licence: GPL + +#include "fctsys.h" +#include "appl_wxstruct.h" +#include "pcbnew.h" +#include "wxPcbStruct.h" +#include "pcbplot.h" +#include "gendrill.h" + +#include "dialog_gendrill.h" + + +// Keywords for read and write config +#define ZerosFormatKey wxT( "DrillZerosFormat" ) +#define PrecisionKey wxT( "DrilltPrecisionOpt" ) +#define MirrorKey wxT( "DrillMirrorYOpt" ) +#define MinimalHeaderKey wxT( "DrillMinHeader" ) +#define UnitDrillInchKey wxT( "DrillUnit" ) +#define DrillOriginIsAuxAxisKey wxT( "DrillAuxAxis" ) + +// list of allowed precision for EXCELLON files, when interger format: +// Due to difference between inches and mm, +// there are 2 set of reasonnable precision values, one for inches and one for metric +static DRILL_PRECISION precisionListForInches[] = +{ + DRILL_PRECISION(2,3), DRILL_PRECISION(2,4) +}; +static DRILL_PRECISION precisionListForMetric[] = +{ + DRILL_PRECISION(3,2), DRILL_PRECISION(3,3) +}; + + + +DIALOG_GENDRILL::DIALOG_GENDRILL( WinEDA_PcbFrame* parent ) : + DIALOG_GENDRILL_BASE( parent ) +{ + m_Parent = parent; + + SetReturnCode( 1 ); + initDialog(); + GetSizer()->SetSizeHints( this ); + Centre(); +} + + +// Static members of DIALOG_GENDRILL +int DIALOG_GENDRILL:: m_UnitDrillIsInch = true; +int DIALOG_GENDRILL:: m_ZerosFormat = DECIMAL_FORMAT; +bool DIALOG_GENDRILL::m_MinimalHeader = false; +bool DIALOG_GENDRILL::m_Mirror = true; +bool DIALOG_GENDRILL::m_DrillOriginIsAuxAxis = false; +int DIALOG_GENDRILL:: m_PrecisionFormat = 1; + +/*! + * DIALOG_GENDRILL destructor + */ + +DIALOG_GENDRILL::~DIALOG_GENDRILL() +{ + UpdateConfig(); +} + + +/*! + * Member initialisation + */ + +void DIALOG_GENDRILL::initDialog() +{ + SetFocus(); // Under wxGTK: mandatory to close dialog by the ESC key + wxConfig* Config = wxGetApp().m_EDA_Config; + + if( Config ) + { + Config->Read( ZerosFormatKey, &DIALOG_GENDRILL::m_ZerosFormat ); + Config->Read( PrecisionKey, &DIALOG_GENDRILL::m_PrecisionFormat ); + Config->Read( MirrorKey, &DIALOG_GENDRILL::m_Mirror ); + Config->Read( MinimalHeaderKey, &DIALOG_GENDRILL::m_MinimalHeader ); + Config->Read( UnitDrillInchKey, &DIALOG_GENDRILL::m_UnitDrillIsInch ); + Config->Read( DrillOriginIsAuxAxisKey, &DIALOG_GENDRILL::m_DrillOriginIsAuxAxis ); + } + InitDisplayParams(); +} + +/* some param values initialization before display dialog window + */ +void DIALOG_GENDRILL::InitDisplayParams( void ) +{ + wxString msg; + + m_Choice_Unit->SetSelection( m_UnitDrillIsInch ? 1 : 0 ); + m_Choice_Precision->SetSelection( m_PrecisionFormat ); + m_Choice_Zeros_Format->SetSelection( m_ZerosFormat ); + if( m_ZerosFormat == DECIMAL_FORMAT ) + m_Choice_Precision->Enable( false ); + + UpdatePrecisionOptions( ); + + m_Check_Minimal->SetValue( m_MinimalHeader ); + + if( m_DrillOriginIsAuxAxis ) + m_Choice_Drill_Offset->SetSelection( 1 ); + + m_Check_Mirror->SetValue( m_Mirror ); + + m_ViaDrillValue->SetLabel( _( "Use Netclasses values" ) ); + + m_MicroViaDrillValue->SetLabel( _( "Use Netclasses values" ) ); + + msg.Empty(); + msg << g_pcb_plot_options.HPGL_Pen_Num; + m_PenNum->SetValue( msg ); + + msg.Empty(); + msg << g_pcb_plot_options.HPGL_Pen_Speed; + m_PenSpeed->SetValue( msg ); + + // See if we have some buried vias or/and microvias, and display + // microvias drill value if so + m_ThroughViasCount = 0; + m_MicroViasCount = 0; + m_BlindOrBuriedViasCount = 0; + for( TRACK* track = m_Parent->GetBoard()->m_Track; track != NULL; + track = track->Next() ) + { + if( track->Type() != TYPE_VIA ) + continue; + if( track->Shape() == VIA_THROUGH ) + m_ThroughViasCount++; + else if( track->Shape() == VIA_MICROVIA ) + m_MicroViasCount++; + else if( track->Shape() == VIA_BLIND_BURIED ) + m_BlindOrBuriedViasCount++; + } + + m_MicroViaDrillValue->Enable( m_MicroViasCount ); + + // Pads holes round: + m_PadsHoleCount = 0; + for( MODULE* module = m_Parent->GetBoard()->m_Modules; + module != NULL; module = module->Next() ) + { + for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() ) + { + if( pad->m_DrillShape == PAD_CIRCLE ) + { + if( pad->m_Drill.x != 0 ) + m_PadsHoleCount++; + } + else + if( MIN( pad->m_Drill.x, pad->m_Drill.y ) != 0 ) + m_PadsHoleCount++; + } + } + + msg = m_PadsCountInfoMsg->GetLabel(); + msg << wxT( " " ) << m_PadsHoleCount; + m_PadsCountInfoMsg->SetLabel( msg ); + + msg = m_ThroughViasInfoMsg->GetLabel(); + msg << wxT( " " ) << m_ThroughViasCount; + m_ThroughViasInfoMsg->SetLabel( msg ); + + msg = m_MicroViasInfoMsg->GetLabel(); + msg << wxT( " " ) << m_MicroViasCount; + m_MicroViasInfoMsg->SetLabel( msg ); + + msg = m_BuriedViasInfoMsg->GetLabel(); + msg << wxT( " " ) << m_BlindOrBuriedViasCount; + m_BuriedViasInfoMsg->SetLabel( msg ); +} + +/* Save drill options: */ +void DIALOG_GENDRILL::UpdateConfig() +{ + SetParams(); + + wxConfig* Config = wxGetApp().m_EDA_Config; + + if( Config ) + { + Config->Write( ZerosFormatKey, m_ZerosFormat ); + Config->Write( PrecisionKey, m_PrecisionFormat ); + Config->Write( MirrorKey, m_Mirror ); + Config->Write( MinimalHeaderKey, m_MinimalHeader ); + Config->Write( UnitDrillInchKey, m_UnitDrillIsInch ); + Config->Write( DrillOriginIsAuxAxisKey, m_DrillOriginIsAuxAxis ); + } +} + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX + */ + +void DIALOG_GENDRILL::OnSelDrillUnitsSelected( wxCommandEvent& event ) +{ + UpdatePrecisionOptions( ); +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void DIALOG_GENDRILL::OnOkClick( wxCommandEvent& event ) +{ + GenDrillOrReportFiles( ); +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + */ + +void DIALOG_GENDRILL::OnCancelClick( wxCommandEvent& event ) +{ + UpdateConfig(); /* Save drill options: */ + event.Skip(); // Process the default cancel event (close dialog) +} + + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SEL_ZEROS_FMT + */ + +void DIALOG_GENDRILL::OnSelZerosFmtSelected( wxCommandEvent& event ) +{ + UpdatePrecisionOptions( ); +} + + +void DIALOG_GENDRILL::UpdatePrecisionOptions( ) +{ + if( m_Choice_Unit->GetSelection()== 1 ) // Units = inches + { + /* inch options */ + m_Choice_Precision->SetString( 0, precisionListForInches[0].GetPrecisionString() ); + m_Choice_Precision->SetString( 1, precisionListForInches[1].GetPrecisionString() ); + } + else + { + /* metric options */ + m_Choice_Precision->SetString( 0, precisionListForMetric[0].GetPrecisionString() ); + m_Choice_Precision->SetString( 1, precisionListForMetric[1].GetPrecisionString() ); + } + if( m_Choice_Zeros_Format->GetSelection()==DECIMAL_FORMAT ) + m_Choice_Precision->Enable( false ); + else + m_Choice_Precision->Enable( true ); +} + + +void DIALOG_GENDRILL::SetParams( void ) +{ + wxString msg; + long ltmp; + + m_UnitDrillIsInch = (m_Choice_Unit->GetSelection() == 0) ? FALSE : TRUE; + m_MinimalHeader = m_Check_Minimal->IsChecked(); + m_Mirror = m_Check_Mirror->IsChecked(); + m_ZerosFormat = m_Choice_Zeros_Format->GetSelection(); + m_DrillOriginIsAuxAxis = m_Choice_Drill_Offset->GetSelection(); + m_PrecisionFormat = m_Choice_Precision->GetSelection(); + + msg = m_PenSpeed->GetValue(); + if( msg.ToLong( <mp ) ) + g_pcb_plot_options.HPGL_Pen_Speed = ltmp; + msg = m_PenNum->GetValue(); + + if( msg.ToLong( <mp ) ) + g_pcb_plot_options.HPGL_Pen_Num = ltmp; + if( m_Choice_Drill_Offset->GetSelection() == 0 ) + m_FileDrillOffset = wxPoint( 0, 0 ); + else + m_FileDrillOffset = m_Parent->m_Auxiliary_Axis_Position; + + // get precision + int idx = m_Choice_Precision->GetSelection(); + if( m_UnitDrillIsInch ) + m_Precision = precisionListForInches[idx]; + else + m_Precision = precisionListForMetric[idx]; +} diff --git a/pcbnew/dialogs/dialog_gendrill.h b/pcbnew/dialogs/dialog_gendrill.h new file mode 100644 index 0000000000..da30af0131 --- /dev/null +++ b/pcbnew/dialogs/dialog_gendrill.h @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////// + +// Name: dialog_gendrill.h +// Author: jean-pierre Charras +// Created: 2010 apr 30 +// Licence: GPL +///////////////////////////////////////////////////////////////////////////// + +#ifndef _DIALOG_GENDRILL_H_ +#define _DIALOG_GENDRILL_H_ + +#include "dialog_gendrill_base.h" + +class DIALOG_GENDRILL : public DIALOG_GENDRILL_BASE +{ +public: + static int m_UnitDrillIsInch; + static int m_ZerosFormat; + static int m_PrecisionFormat; + static bool m_MinimalHeader; + static bool m_Mirror; + static bool m_DrillOriginIsAuxAxis; /* Axis selection (main / auxiliary) + * for drill origin coordinates */ + DRILL_PRECISION m_Precision; // Selected precision for drill files + wxPoint m_FileDrillOffset; // Drill offset: 0,0 for absolute coordiantes, or auxialry axis origin + +private: + WinEDA_PcbFrame* m_Parent; + int m_PadsHoleCount; + int m_ThroughViasCount; + int m_MicroViasCount; + int m_BlindOrBuriedViasCount; + +public: DIALOG_GENDRILL( WinEDA_PcbFrame* parent ); + ~DIALOG_GENDRILL(); + +private: + // Initialises member variables + void initDialog(); + void InitDisplayParams( void ); + // event functions + void OnSelDrillUnitsSelected( wxCommandEvent& event ); + void OnSelZerosFmtSelected( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); + // Specific functions: + void SetParams( void ); + void GenDrillOrReportFiles(); + void GenDrillMap( const wxString aFileName, + std::vector& aHoleListBuffer, + std::vector& aToolListBuffer, + int format ); + void UpdatePrecisionOptions( ); + void UpdateConfig(); + void Write_Excellon_Header( FILE* aFile, bool aMinimalHeader, zeros_fmt aFormat ); + void GenDrillReport( const wxString aFileName ); + int Create_Drill_File_EXCELLON( FILE* aFile, + wxPoint aOffset, + std::vector& aHoleListBuffer, + std::vector& aToolListBuffer ); + int Gen_Liste_Tools( std::vector& buffer, bool print_header ); + /** + * Return the selected format for coordinates, if not decimal + */ + DRILL_PRECISION GetPrecison(); +}; + +#endif // _DIALOG_GENDRILL_H_ diff --git a/pcbnew/dialog_gendrill_base.cpp b/pcbnew/dialogs/dialog_gendrill_base.cpp similarity index 94% rename from pcbnew/dialog_gendrill_base.cpp rename to pcbnew/dialogs/dialog_gendrill_base.cpp index 1e7ae02589..d1ef9b55ee 100644 --- a/pcbnew/dialog_gendrill_base.cpp +++ b/pcbnew/dialogs/dialog_gendrill_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 8 2010) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -75,17 +75,17 @@ DIALOG_GENDRILL_BASE::DIALOG_GENDRILL_BASE( wxWindow* parent, wxWindowID id, con m_staticText1 = new wxStaticText( this, wxID_ANY, _("Speed (cm/s)"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->Wrap( -1 ); - sbHPGOptionsSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + sbHPGOptionsSizer->Add( m_staticText1, 0, wxRIGHT|wxLEFT, 5 ); m_PenSpeed = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); sbHPGOptionsSizer->Add( m_PenSpeed, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); m_staticText2 = new wxStaticText( this, wxID_ANY, _("Pen Number"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText2->Wrap( -1 ); - sbHPGOptionsSizer->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + sbHPGOptionsSizer->Add( m_staticText2, 0, wxRIGHT|wxLEFT, 5 ); m_PenNum = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - sbHPGOptionsSizer->Add( m_PenNum, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + sbHPGOptionsSizer->Add( m_PenNum, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); bMiddleBoxSizer->Add( sbHPGOptionsSizer, 0, wxEXPAND, 5 ); @@ -93,12 +93,10 @@ DIALOG_GENDRILL_BASE::DIALOG_GENDRILL_BASE( wxWindow* parent, wxWindowID id, con sbOptSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options:") ), wxVERTICAL ); m_Check_Mirror = new wxCheckBox( this, wxID_ANY, _("Mirror y axis"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbOptSizer->Add( m_Check_Mirror, 0, wxALL, 5 ); + sbOptSizer->Add( m_Check_Mirror, 0, wxRIGHT|wxLEFT, 5 ); m_Check_Minimal = new wxCheckBox( this, wxID_ANY, _("Minimal header"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbOptSizer->Add( m_Check_Minimal, 0, wxALL, 5 ); + sbOptSizer->Add( m_Check_Minimal, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); bMiddleBoxSizer->Add( sbOptSizer, 0, wxEXPAND, 5 ); @@ -178,4 +176,5 @@ DIALOG_GENDRILL_BASE::~DIALOG_GENDRILL_BASE() m_Choice_Zeros_Format->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_GENDRILL_BASE::OnSelZerosFmtSelected ), NULL, this ); m_OkButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GENDRILL_BASE::OnOkClick ), NULL, this ); m_CancelButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GENDRILL_BASE::OnCancelClick ), NULL, this ); + } diff --git a/pcbnew/dialog_gendrill_base.fbp b/pcbnew/dialogs/dialog_gendrill_base.fbp similarity index 88% rename from pcbnew/dialog_gendrill_base.fbp rename to pcbnew/dialogs/dialog_gendrill_base.fbp index 21201733c9..7be5978631 100644 --- a/pcbnew/dialog_gendrill_base.fbp +++ b/pcbnew/dialogs/dialog_gendrill_base.fbp @@ -1,10 +1,12 @@ - + C++ 1 + source_name + 0 UTF-8 connect dialog_gendrill_base @@ -16,13 +18,16 @@ . 1 + 1 0 0 + 1 1 + impl_virtual @@ -32,11 +37,15 @@ DIALOG_GENDRILL_BASE - 447,412 + 447,385 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER Drill Files Generation + + wxFILTER_NONE + wxDefaultValidator + @@ -92,6 +101,7 @@ "Millimeters" "Inches" + 1 1 @@ -109,6 +119,10 @@ wxRA_SPECIFY_COLS + + wxFILTER_NONE + wxDefaultValidator + @@ -146,6 +160,7 @@ "Decimal format" "Suppress leading zeros" "Suppress trailing zeros" "Keep zeros" + 1 1 @@ -163,6 +178,10 @@ wxRA_SPECIFY_COLS Choose EXCELLON numbers notation + + wxFILTER_NONE + wxDefaultValidator + @@ -200,6 +219,7 @@ "2:3" "2:4" + 1 1 @@ -217,6 +237,10 @@ wxRA_SPECIFY_COLS Choose EXCELLON numbers precision + + wxFILTER_NONE + wxDefaultValidator + @@ -254,6 +278,7 @@ "Absolute" "Auxiliary axis" + 1 1 @@ -271,6 +296,10 @@ wxRA_SPECIFY_COLS Choose the coordinate origin: absolute or relative to the auxiliray axis + + wxFILTER_NONE + wxDefaultValidator + @@ -319,6 +348,7 @@ "None" "Drill map (HPGL)" "Drill map (PostScript)" "Drill map (Gerber)" "Drill map (DXF)" + 1 1 @@ -336,6 +366,10 @@ wxRA_SPECIFY_COLS Creates a drill map in PS, HPGL or other formats + + wxFILTER_NONE + wxDefaultValidator + @@ -373,6 +407,7 @@ "None" "Drill report" + 1 1 @@ -390,6 +425,10 @@ wxRA_SPECIFY_COLS Creates a plain text report + + wxFILTER_NONE + wxDefaultValidator + @@ -433,11 +472,12 @@ 5 - wxTOP|wxRIGHT|wxLEFT + wxRIGHT|wxLEFT 0 + 1 1 @@ -453,6 +493,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -489,6 +533,7 @@ + 1 1 @@ -504,6 +549,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -539,11 +588,12 @@ 5 - wxTOP|wxRIGHT|wxLEFT + wxRIGHT|wxLEFT 0 + 1 1 @@ -559,6 +609,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -590,11 +644,12 @@ 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + wxEXPAND|wxRIGHT|wxLEFT 0 + 1 1 @@ -610,6 +665,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -659,12 +718,13 @@ 5 - wxALL + wxRIGHT|wxLEFT 0 0 + 1 1 @@ -680,6 +740,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -711,12 +775,13 @@ 5 - wxALL + wxTOP|wxRIGHT|wxLEFT 0 0 + 1 1 @@ -732,6 +797,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -805,6 +874,7 @@ + 1 1 @@ -820,6 +890,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -870,6 +944,7 @@ + 1 1 @@ -885,6 +960,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -935,6 +1014,7 @@ + 1 1 @@ -950,6 +1030,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -986,6 +1070,7 @@ + 1 1 @@ -1001,6 +1086,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1037,6 +1126,7 @@ + 1 1 @@ -1052,6 +1142,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1088,6 +1182,7 @@ + 1 1 @@ -1103,6 +1198,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1153,6 +1252,7 @@ + 1 1 1 @@ -1169,6 +1269,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1205,6 +1309,7 @@ + 1 0 1 @@ -1221,6 +1326,10 @@ + + wxFILTER_NONE + wxDefaultValidator + diff --git a/pcbnew/dialog_gendrill_base.h b/pcbnew/dialogs/dialog_gendrill_base.h similarity index 80% rename from pcbnew/dialog_gendrill_base.h rename to pcbnew/dialogs/dialog_gendrill_base.h index b8136d83f1..e15e2365d1 100644 --- a/pcbnew/dialog_gendrill_base.h +++ b/pcbnew/dialogs/dialog_gendrill_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 8 2010) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -60,14 +60,15 @@ class DIALOG_GENDRILL_BASE : public wxDialog wxButton* m_CancelButton; // Virtual event handlers, overide them in your derived class - virtual void OnSelDrillUnitsSelected( wxCommandEvent& event ){ event.Skip(); } - virtual void OnSelZerosFmtSelected( wxCommandEvent& event ){ event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } + virtual void OnSelDrillUnitsSelected( wxCommandEvent& event ) { event.Skip(); } + virtual void OnSelZerosFmtSelected( wxCommandEvent& event ) { event.Skip(); } + virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_GENDRILL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Drill Files Generation"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 447,412 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + DIALOG_GENDRILL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Drill Files Generation"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 447,385 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_GENDRILL_BASE(); }; diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp index f50450fe35..fa48be061c 100644 --- a/pcbnew/gendrill.cpp +++ b/pcbnew/gendrill.cpp @@ -2,8 +2,13 @@ /* Functions to create EXCELLON drill files and report files */ /*************************************************************/ +/** + * @info for EXCELLON format, see: + * http://www.excellon.com/applicationengineering/manuals/program.htm + * and the CNC-7 manual. + */ + #include "fctsys.h" -#include "appl_wxstruct.h" #include @@ -27,7 +32,6 @@ #include "build_version.h" const wxString DrillFileExtension( wxT( "drl" ) ); - const wxString DrillFileWildcard( _( "Drill files (*.drl)|*.drl" ) ); /* @@ -42,220 +46,41 @@ const wxString DrillFileWildcard( _( "Drill files (*.drl)|*.drl" ) ); * * The drill maps can be created in HPGL or PS format * - * dialog_gendrill.cpp is the filewhich handles + * dialog_gendrill.cpp is the file which handles * the Dialog box for drill file generation */ +// Helper functions: +static void Gen_Line_EXCELLON( char * aLine, double aCoordX, double aCoordY, DRILL_PRECISION& aPrecision ); +static void WriteEndOfFile_EXCELLON( FILE* aFile ); -static void Gen_Line_EXCELLON( char* line, float x, float y ); -static void Write_End_Of_File_Drill( FILE* aFile ); - -static float s_ConversionUnits; /* Conversion unite for +static double s_ConversionUnits; /* Conversion unite for * drill / pcb */ -static int s_Unit_Drill_is_Inch = TRUE; /* INCH,LZ (2:4) */ -static int s_Zeros_Format = DECIMAL_FORMAT; -static DrillPrecision s_Precision( 2, 4 ); - -static bool DrillOriginIsAuxAxis; /* Axis selection (main / - * auxiliary) for drill - * origin coordinates */ -static wxPoint File_Drill_Offset; /* Offset coordinate for - * drilling file. */ -static bool Minimal = false; -static bool Mirror = true; - static std::vector s_ToolListBuffer; static std::vector s_HoleListBuffer; -// Keywords for read and write config -#define ZerosFormatKey wxT( "DrillZerosFormat" ) -#define LeftPrecisionKey wxT( "DrillLeftPrecisionOpt" ) -#define RightPrecisionKey wxT( "DrillRightPrecisionOpt" ) -#define MirrorKey wxT( "DrillMirrorYOpt" ) -#define MinimalKey wxT( "DrillMinHeader" ) -#define UnitDrillInchKey wxT( "DrillUnit" ) -#define DrillOriginIsAuxAxisKey wxT( "DrillAuxAxis" ) - - -/* some param values initialization before display dialog window - */ -void DIALOG_GENDRILL::InitDisplayParams( void ) -{ - wxString msg; - - if( s_Zeros_Format == DECIMAL_FORMAT ) - m_Choice_Precision->Enable( false ); - if( DrillOriginIsAuxAxis ) - m_Choice_Drill_Offset->SetSelection( 1 ); - - msg << s_Precision.m_lhs << wxT( ":" ) << s_Precision.m_rhs; - m_Choice_Precision->SetStringSelection( msg ); - if( s_Zeros_Format == DECIMAL_FORMAT ) - m_Choice_Precision->Enable( false ); - - m_ViaDrillValue->SetLabel( _( "Use Netclasses values" ) ); - - m_MicroViaDrillValue->SetLabel( _( "Use Netclasses values" ) ); - - msg.Empty(); - msg << g_pcb_plot_options.HPGL_Pen_Num; - m_PenNum->SetValue( msg ); - - msg.Empty(); - msg << g_pcb_plot_options.HPGL_Pen_Speed; - m_PenSpeed->SetValue( msg ); - - // See if we have some buried vias or/and microvias, and display - // microvias drill value if so - m_ThroughViasCount = 0; - m_MicroViasCount = 0; - m_BlindOrBuriedViasCount = 0; - for( TRACK* track = m_Parent->GetBoard()->m_Track; track != NULL; - track = track->Next() ) - { - if( track->Type() != TYPE_VIA ) - continue; - if( track->Shape() == VIA_THROUGH ) - m_ThroughViasCount++; - else if( track->Shape() == VIA_MICROVIA ) - m_MicroViasCount++; - else if( track->Shape() == VIA_BLIND_BURIED ) - m_BlindOrBuriedViasCount++; - } - - m_MicroViaDrillValue->Enable( m_MicroViasCount ); - - // Pads holes round: - m_PadsHoleCount = 0; - for( MODULE* module = m_Parent->GetBoard()->m_Modules; - module != NULL; module = module->Next() ) - { - for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() ) - { - if( pad->m_DrillShape == PAD_CIRCLE ) - { - if( pad->m_Drill.x != 0 ) - m_PadsHoleCount++; - } - else - if( MIN( pad->m_Drill.x, pad->m_Drill.y ) != 0 ) - m_PadsHoleCount++; - } - } - - msg = m_PadsCountInfoMsg->GetLabel(); - msg << wxT( " " ) << m_PadsHoleCount; - m_PadsCountInfoMsg->SetLabel( msg ); - - msg = m_ThroughViasInfoMsg->GetLabel(); - msg << wxT( " " ) << m_ThroughViasCount; - m_ThroughViasInfoMsg->SetLabel( msg ); - - msg = m_MicroViasInfoMsg->GetLabel(); - msg << wxT( " " ) << m_MicroViasCount; - m_MicroViasInfoMsg->SetLabel( msg ); - - msg = m_BuriedViasInfoMsg->GetLabel(); - msg << wxT( " " ) << m_BlindOrBuriedViasCount; - m_BuriedViasInfoMsg->SetLabel( msg ); -} - - -void DIALOG_GENDRILL::SetParams( void ) -{ - wxString msg; - long ltmp; - - s_Unit_Drill_is_Inch = (m_Choice_Unit->GetSelection() == 0) ? FALSE : TRUE; - Minimal = m_Check_Minimal->IsChecked(); - Mirror = m_Check_Mirror->IsChecked(); - s_Zeros_Format = m_Choice_Zeros_Format->GetSelection(); - DrillOriginIsAuxAxis = m_Choice_Drill_Offset->GetSelection(); - - msg = m_PenSpeed->GetValue(); - if( msg.ToLong( <mp ) ) - g_pcb_plot_options.HPGL_Pen_Speed = ltmp; - msg = m_PenNum->GetValue(); - - if( msg.ToLong( <mp ) ) - g_pcb_plot_options.HPGL_Pen_Num = ltmp; - if( m_Choice_Drill_Offset->GetSelection() == 0 ) - File_Drill_Offset = wxPoint( 0, 0 ); - else - File_Drill_Offset = m_Parent->m_Auxiliary_Axis_Position; - - /* get precision from radio box strings (this just makes it easier to - * change options later)*/ - wxString ps = m_Choice_Precision->GetStringSelection(); - wxString l = ps.substr( 0, 1 ); - wxString r = ps.substr( 2, 1 ); - - - // a long is not an int on all machines - long lhs; - long rhs; - - l.ToLong( &lhs ); - r.ToLong( &rhs ); - - s_Precision.m_lhs = lhs; - s_Precision.m_rhs = rhs; -} /* This function displays and deletes the dialog frame for drill tools */ void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event ) { - wxConfig* Config = wxGetApp().m_EDA_Config; - - if( Config ) - { - Config->Read( ZerosFormatKey, &s_Zeros_Format ); - Config->Read( LeftPrecisionKey, &s_Precision.m_lhs ); - Config->Read( RightPrecisionKey, &s_Precision.m_rhs ); - Config->Read( MirrorKey, &Mirror ); - Config->Read( MinimalKey, &Minimal ); - Config->Read( UnitDrillInchKey, &s_Unit_Drill_is_Inch ); - Config->Read( DrillOriginIsAuxAxisKey, &DrillOriginIsAuxAxis ); - } - DIALOG_GENDRILL* frame = new DIALOG_GENDRILL( this ); frame->ShowModal(); frame->Destroy(); } -/* Save drill options: */ -void DIALOG_GENDRILL::UpdateConfig() -{ - SetParams(); - - wxConfig* Config = wxGetApp().m_EDA_Config; - - if( Config ) - { - Config->Write( ZerosFormatKey, s_Zeros_Format ); - Config->Write( LeftPrecisionKey, s_Precision.m_lhs ); - Config->Write( RightPrecisionKey, s_Precision.m_rhs ); - Config->Write( MirrorKey, Mirror ); - Config->Write( MinimalKey, Minimal ); - Config->Write( UnitDrillInchKey, s_Unit_Drill_is_Inch ); - Config->Write( DrillOriginIsAuxAxisKey, DrillOriginIsAuxAxis ); - } -} - - /** - * Function GenDrillFiles + * Function GenDrillOrReportFiles * Calls the functions to create EXCELLON drill files and/or drill map files - * When all holes are through, one excellon file is created - * when there are some partial holes (some blind or buried vias: - * One excellon file is created, for all through holes. - * And one file per layer pair, which have one or more holes, excluding - * through holes, already in the first file. + * >When all holes are through, only one excellon file is created. + * >When there are some partial holes (some blind or buried vias), + * one excellon file is created, for all through holes, + * and one file per layer pair, which have one or more holes, excluding + * through holes, already in the first file. */ -void DIALOG_GENDRILL::GenDrillFiles( wxCommandEvent& event ) +void DIALOG_GENDRILL::GenDrillOrReportFiles( ) { wxFileName fn; wxString layer_extend; /* added to the Board FileName to @@ -274,9 +99,9 @@ void DIALOG_GENDRILL::GenDrillFiles( wxCommandEvent& event ) m_Parent->MsgPanel->EraseMsgBox(); /* Set conversion scale depending on drill file units */ - s_ConversionUnits = 0.0001f; /* units = INCHES */ - if( !s_Unit_Drill_is_Inch ) - s_ConversionUnits = 0.000254f; /* units = mm */ + s_ConversionUnits = 0.0001; // EXCELLON units = INCHES + if( !m_UnitDrillIsInch ) + s_ConversionUnits = 0.00254; // EXCELLON units = mm if( m_MicroViasCount || m_BlindOrBuriedViasCount ) ExistsBuriedVias = true; @@ -309,14 +134,14 @@ void DIALOG_GENDRILL::GenDrillFiles( wxCommandEvent& event ) wxFileDialog dlg( this, _( "Save Drill File" ), fn.GetPath(), fn.GetFullName(), DrillFileWildcard, - wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + wxFD_SAVE ); if( dlg.ShowModal() == wxID_CANCEL ) break; - FILE* excellon_dest = wxFopen( dlg.GetPath(), wxT( "w" ) ); + FILE* aFile = wxFopen( dlg.GetPath(), wxT( "w" ) ); - if( excellon_dest == 0 ) + if( aFile == 0 ) { msg = _( "Unable to create file " ) + dlg.GetPath(); DisplayError( this, msg ); @@ -324,8 +149,8 @@ void DIALOG_GENDRILL::GenDrillFiles( wxCommandEvent& event ) return; } - Create_Drill_File_EXCELLON( excellon_dest, s_HoleListBuffer, - s_ToolListBuffer ); + Create_Drill_File_EXCELLON( aFile, m_FileDrillOffset, + s_HoleListBuffer, s_ToolListBuffer ); switch( m_Choice_Drill_Map->GetSelection() ) { @@ -366,8 +191,8 @@ void DIALOG_GENDRILL::GenDrillFiles( wxCommandEvent& event ) layer2++; // use next layer pair if( layer2 == m_Parent->GetBoard()->GetCopperLayerCount() - 1 ) - layer2 = LAYER_N_FRONT; // the last layer is always the - // component layer + layer2 = LAYER_N_FRONT; // the last layer is always the + // component layer } gen_through_holes = false; @@ -382,103 +207,72 @@ void DIALOG_GENDRILL::GenDrillFiles( wxCommandEvent& event ) } -void DIALOG_GENDRILL::UpdatePrecisionOptions( wxCommandEvent& event ) -{ - if( m_Choice_Unit->GetSelection()==1 ) - { - /* inch options */ - m_Choice_Precision->SetString( 0, _( "2:3" ) ); - m_Choice_Precision->SetString( 1, _( "2:4" ) ); - } - else - { - /* metric options */ - m_Choice_Precision->SetString( 0, _( "3:2" ) ); - m_Choice_Precision->SetString( 1, _( "3:3" ) ); - } - if( m_Choice_Zeros_Format->GetSelection()==DECIMAL_FORMAT ) - m_Choice_Precision->Enable( false ); - else - m_Choice_Precision->Enable( true ); -} - - /** * Create the drill file in EXCELLON format * @return hole count * @param aHoleListBuffer = hole descriptor list * @param aToolListBuffer = Drill tools list */ -int DIALOG_GENDRILL::Create_Drill_File_EXCELLON( FILE* excellon_dest, - std::vector& aHoleListBuffer, - std::vector& aToolListBuffer ) +int DIALOG_GENDRILL::Create_Drill_File_EXCELLON( FILE* aFile, + wxPoint aOffset, + std::vector& aHoleListBuffer, + std::vector& aToolListBuffer ) { int diam, holes_count; int x0, y0, xf, yf, xc, yc; - float xt, yt; + double xt, yt; char line[1024]; - SetLocaleTo_C_standard(); // Use the standard notation for float numbers + SetLocaleTo_C_standard(); // Use the standard notation for double numbers - Write_Excellon_Header( excellon_dest ); + Write_Excellon_Header( aFile, m_MinimalHeader, (zeros_fmt) m_ZerosFormat ); holes_count = 0; - int tool_reference = -2; - + /* Write the tool list */ for( unsigned ii = 0; ii < aToolListBuffer.size(); ii++ ) { - if( s_Unit_Drill_is_Inch ) /* does it need T01, T02 or is T1,T2 ok?*/ - fprintf( excellon_dest, "T%dC%.3f\n", ii + 1, - float (aToolListBuffer[ii].m_Diameter) - * s_ConversionUnits ); - else - fprintf( excellon_dest, "T%dC%.3f\n", ii + 1, - float (aToolListBuffer[ii].m_Diameter) - * s_ConversionUnits * 10.0 ); + fprintf( aFile, "T%dC%.3f\n", ii + 1, + double (aToolListBuffer[ii].m_Diameter) * s_ConversionUnits ); } - fputs( "%\n", excellon_dest ); + fputs( "%\n", aFile ); // End of header info - if( !Minimal ) - fputs( "M47\n", excellon_dest ); /* Operator message */ - fputs( "G05\n", excellon_dest ); /* Drill mode */ + fputs( "G90\n", aFile ); // Absolute mode + fputs( "G05\n", aFile ); // Drill mode /* Units : */ - if( s_Unit_Drill_is_Inch && !Minimal ) - fputs( "M72\n", excellon_dest ); /* M72 = inch mode */ - else if( !Minimal ) - fputs( "M71\n", excellon_dest ); /* M71 = metric mode */ + if( !m_MinimalHeader ) + { + if( m_UnitDrillIsInch ) + fputs( "M72\n", aFile ); /* M72 = inch mode */ + else + fputs( "M71\n", aFile ); /* M71 = metric mode */ + } /* Read the hole file and generate lines for normal holes (oblong * holes will be created later) */ + int tool_reference = -2; for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ ) { if( aHoleListBuffer[ii].m_Hole_Shape ) - continue; // oblong holes will be created later + continue; // oblong holes will be created later if( tool_reference != aHoleListBuffer[ii].m_Tool_Reference ) { tool_reference = aHoleListBuffer[ii].m_Tool_Reference; - fprintf( excellon_dest, "T%d\n", tool_reference ); + fprintf( aFile, "T%d\n", tool_reference ); } - x0 = aHoleListBuffer[ii].m_Hole_Pos_X - File_Drill_Offset.x; - y0 = aHoleListBuffer[ii].m_Hole_Pos_Y - File_Drill_Offset.y; + x0 = aHoleListBuffer[ii].m_Hole_Pos_X - aOffset.x; + y0 = aHoleListBuffer[ii].m_Hole_Pos_Y - aOffset.y; - if( !Mirror ) + if( !m_Mirror ) y0 *= -1; - xt = float (x0) * s_ConversionUnits; yt = float (y0) * s_ConversionUnits; - if( s_Unit_Drill_is_Inch ) - { - Gen_Line_EXCELLON( line, xt, yt ); - } - else - { - /* metric 3:3 */ - Gen_Line_EXCELLON( line, xt * 10, yt * 10 ); - } + xt = x0 * s_ConversionUnits; + yt = y0 * s_ConversionUnits; + Gen_Line_EXCELLON( line, xt, yt, m_Precision ); - fputs( line, excellon_dest ); + fputs( line, aFile ); holes_count++; } @@ -489,11 +283,11 @@ int DIALOG_GENDRILL::Create_Drill_File_EXCELLON( FILE* excell for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ ) { if( aHoleListBuffer[ii].m_Hole_Shape == 0 ) - continue; // wait for oblong holes + continue; // wait for oblong holes if( tool_reference != aHoleListBuffer[ii].m_Tool_Reference ) { tool_reference = aHoleListBuffer[ii].m_Tool_Reference; - fprintf( excellon_dest, "T%d\n", tool_reference ); + fprintf( aFile, "T%d\n", tool_reference ); } diam = MIN( aHoleListBuffer[ii].m_Hole_SizeX, @@ -502,8 +296,8 @@ int DIALOG_GENDRILL::Create_Drill_File_EXCELLON( FILE* excell continue; /* Compute the hole coordinates: */ - xc = x0 = xf = aHoleListBuffer[ii].m_Hole_Pos_X - File_Drill_Offset.x; - yc = y0 = yf = aHoleListBuffer[ii].m_Hole_Pos_Y - File_Drill_Offset.y; + xc = x0 = xf = aHoleListBuffer[ii].m_Hole_Pos_X - aOffset.x; + yc = y0 = yf = aHoleListBuffer[ii].m_Hole_Pos_Y - aOffset.y; /* Compute the start and end coordinates for the shape */ if( aHoleListBuffer[ii].m_Hole_SizeX < aHoleListBuffer[ii].m_Hole_SizeY ) @@ -522,43 +316,37 @@ int DIALOG_GENDRILL::Create_Drill_File_EXCELLON( FILE* excell RotatePoint( &xf, &yf, xc, yc, aHoleListBuffer[ii].m_Hole_Orient ); - if( !Mirror ) + if( !m_Mirror ) { y0 *= -1; yf *= -1; } - xt = float (x0) * s_ConversionUnits; - yt = float (y0) * s_ConversionUnits; + xt = x0 * s_ConversionUnits; + yt = y0 * s_ConversionUnits; + Gen_Line_EXCELLON( line, xt, yt, m_Precision ); - if( s_Unit_Drill_is_Inch ) - Gen_Line_EXCELLON( line, xt, yt ); - else - Gen_Line_EXCELLON( line, xt * 10, yt * 10 ); /* remove the '\n' from end of line, because we must add the "G85" * command to the line: */ for( int kk = 0; line[kk] != 0; kk++ ) if( line[kk] == '\n' || line[kk] =='\r' ) line[kk] = 0; - fputs( line, excellon_dest ); + fputs( line, aFile ); - fputs( "G85", excellon_dest ); // add the "G85" command + fputs( "G85", aFile ); // add the "G85" command - xt = float (xf) * s_ConversionUnits; - yt = float (yf) * s_ConversionUnits; - - if( s_Unit_Drill_is_Inch ) - Gen_Line_EXCELLON( line, xt, yt ); - else - Gen_Line_EXCELLON( line, xt * 10, yt * 10 ); - fputs( line, excellon_dest ); - fputs( "G05\n", excellon_dest ); + xt = xf * s_ConversionUnits; + yt = yf * s_ConversionUnits; + Gen_Line_EXCELLON( line, xt, yt, m_Precision ); + + fputs( line, aFile ); + fputs( "G05\n", aFile ); holes_count++; } - Write_End_Of_File_Drill( excellon_dest ); + WriteEndOfFile_EXCELLON( aFile ); - SetLocaleTo_Default(); // Revert to locale float notation + SetLocaleTo_Default(); // Revert to locale double notation return holes_count; } @@ -568,46 +356,46 @@ int DIALOG_GENDRILL::Create_Drill_File_EXCELLON( FILE* excell * X48000Y19500 * According to the selected format */ -void Gen_Line_EXCELLON( char* line, float x, float y ) +void Gen_Line_EXCELLON( char * aLine, double aCoordX, double aCoordY, DRILL_PRECISION& aPrecision ) { wxString xs, ys; - int xpad = s_Precision.m_lhs + s_Precision.m_rhs; + int xpad = aPrecision.m_lhs + aPrecision.m_rhs; int ypad = xpad; /* I need to come up with an algorithm that handles any lhs:rhs format.*/ /* one idea is to take more inputs for xpad/ypad when metric is used. */ - switch( s_Zeros_Format ) + switch( DIALOG_GENDRILL::m_ZerosFormat ) { default: case DECIMAL_FORMAT: - sprintf( line, "X%.3fY%.3f\n", x, y ); + sprintf( aLine, "X%.3fY%.3f\n", aCoordX, aCoordY ); break; case SUPPRESS_LEADING: /* that should work now */ - for( int i = 0; i< s_Precision.m_rhs; i++ ) + for( int i = 0; i< aPrecision.m_rhs; i++ ) { - x *= 10; y *= 10; + aCoordX *= 10; aCoordY *= 10; } - sprintf( line, "X%dY%d\n", wxRound( x ), wxRound( y ) ); + sprintf( aLine, "X%dY%d\n", wxRound( aCoordX ), wxRound( aCoordY ) ); break; case SUPPRESS_TRAILING: { - for( int i = 0; i < s_Precision.m_rhs; i++ ) + for( int i = 0; i < aPrecision.m_rhs; i++ ) { - x *= 10; - y *= 10; + aCoordX *= 10; + aCoordY *= 10; } - if( x<0 ) + if( aCoordX < 0 ) xpad++; - if( y<0 ) + if( aCoordY < 0 ) ypad++; - xs.Printf( wxT( "%0*d" ), xpad, wxRound( x ) ); - ys.Printf( wxT( "%0*d" ), ypad, wxRound( y ) ); + xs.Printf( wxT( "%0*d" ), xpad, wxRound( aCoordX ) ); + ys.Printf( wxT( "%0*d" ), ypad, wxRound( aCoordY ) ); size_t j = xs.Len() - 1; while( xs[j] == '0' && j ) @@ -617,23 +405,23 @@ void Gen_Line_EXCELLON( char* line, float x, float y ) while( ys[j] == '0' && j ) ys.Truncate( j-- ); - sprintf( line, "X%sY%s\n", CONV_TO_UTF8( xs ), CONV_TO_UTF8( ys ) ); + sprintf( aLine, "X%sY%s\n", CONV_TO_UTF8( xs ), CONV_TO_UTF8( ys ) ); break; } case KEEP_ZEROS: - for( int i = 0; i< s_Precision.m_rhs; i++ ) + for( int i = 0; i< aPrecision.m_rhs; i++ ) { - x *= 10; y *= 10; + aCoordX *= 10; aCoordY *= 10; } - if( x<0 ) + if( aCoordX < 0 ) xpad++; - if( y<0 ) + if( aCoordY < 0 ) ypad++; - xs.Printf( wxT( "%0*d" ), xpad, wxRound( x ) ); - ys.Printf( wxT( "%0*d" ), ypad, wxRound( y ) ); - sprintf( line, "X%sY%s\n", CONV_TO_UTF8( xs ), CONV_TO_UTF8( ys ) ); + xs.Printf( wxT( "%0*d" ), xpad, wxRound( aCoordX ) ); + ys.Printf( wxT( "%0*d" ), ypad, wxRound( aCoordY ) ); + sprintf( aLine, "X%sY%s\n", CONV_TO_UTF8( xs ), CONV_TO_UTF8( ys ) ); break; } } @@ -651,15 +439,14 @@ void Gen_Line_EXCELLON( char* line, float x, float y ) * ICI,OFF * ATC,ON */ -void DIALOG_GENDRILL::Write_Excellon_Header( FILE* aFile ) +void DIALOG_GENDRILL::Write_Excellon_Header( FILE* aFile, bool aMinimalHeader, zeros_fmt aFormat ) { char Line[256]; - fputs( "M48\n", aFile ); + fputs( "M48\n", aFile ); // The beginning of a header - if( !Minimal ) + if( !aMinimalHeader ) { - int ii = m_Choice_Zeros_Format->GetSelection(); DateAndTime( Line ); // The next 2 lines in EXCELLON files are comments: @@ -669,12 +456,12 @@ void DIALOG_GENDRILL::Write_Excellon_Header( FILE* aFile ) msg = wxT( ";FORMAT={" ); // Print precision: - if( ii > 0 ) + if( aFormat != DECIMAL_FORMAT ) msg << m_Choice_Precision->GetStringSelection(); else - msg << wxT( "-.-" ); // in decimal format the precision is irrelevant + msg << wxT( "-.-" ); // in decimal format the precision is irrelevant msg << wxT( "/ absolute / " ); - msg << ( s_Unit_Drill_is_Inch ? wxT( "inch" ) : wxT( "metric" ) ); + msg << ( m_UnitDrillIsInch ? wxT( "inch" ) : wxT( "metric" ) ); /* Adding numbers notation format. * this is same as m_Choice_Zeros_Format strings, but NOT translated @@ -684,25 +471,23 @@ void DIALOG_GENDRILL::Write_Excellon_Header( FILE* aFile ) * be added here */ msg << wxT( " / " ); - const wxString zero_fmt[5] = + const wxString zero_fmt[4] = { - wxT( "decimal" ), wxT( "suppress leading zeros" ), - wxT( "suppress trailing zeros" ), wxT( "keep zeros" ), - wxT( "???" ) + wxT( "decimal" ), + wxT( "suppress leading zeros" ), + wxT( "suppress trailing zeros" ), + wxT( "keep zeros" ) }; - if( ii < 0 || ii > 4 ) - ii = 4; - msg << zero_fmt[ii]; + msg << zero_fmt[aFormat]; msg << wxT( "}\n" ); fputs( CONV_TO_UTF8( msg ), aFile ); - - fputs( "R,T\nVER,1\nFMAT,2\n", aFile ); + fputs( "FMAT,2\n", aFile ); // Use Format 2 commands (version used since 1979) } - fputs( s_Unit_Drill_is_Inch ? "INCH" : "METRIC", aFile ); + fputs( m_UnitDrillIsInch ? "INCH" : "METRIC", aFile ); - switch( s_Zeros_Format ) + switch( aFormat ) { case SUPPRESS_LEADING: case DECIMAL_FORMAT: @@ -717,25 +502,23 @@ void DIALOG_GENDRILL::Write_Excellon_Header( FILE* aFile ) fputs( ",TZ\n", aFile ); // TZ is acceptable when all zeros are kept break; } - - if( !Minimal ) - fputs( "TCST,OFF\nICI,OFF\nATC,ON\n", aFile ); } -void Write_End_Of_File_Drill( FILE* aFile ) +void WriteEndOfFile_EXCELLON( FILE* aFile ) { //add if minimal here - fputs( "T0\nM30\n", aFile ); fclose( aFile ); + fputs( "T0\nM30\n", aFile ); + fclose( aFile ); } /* Generate the drill plan (Drill map) format HPGL or POSTSCRIPT */ -void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName, - std::vector& aHoleListBuffer, - std::vector& buffer, - int format ) +void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName, + std::vector& aHoleListBuffer, + std::vector& buffer, + int format ) { wxFileName fn; wxString ext, wildcard; @@ -781,9 +564,9 @@ void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName, if( dlg.ShowModal() == wxID_CANCEL ) return; - FILE* drillplot_dest = wxFopen( dlg.GetPath(), wxT( "wt" ) ); + FILE* plotfile = wxFopen( dlg.GetPath(), wxT( "wt" ) ); - if( drillplot_dest == 0 ) + if( plotfile == 0 ) { msg = _( "Unable to create file" ); msg << wxT( " <" ) << dlg.GetPath() << wxT( ">" ); @@ -792,13 +575,13 @@ void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName, } GenDrillMapFile( m_Parent->GetBoard(), - drillplot_dest, + plotfile, dlg.GetPath(), m_Parent->GetScreen()->m_CurrentSheetDesc, s_HoleListBuffer, s_ToolListBuffer, - s_Unit_Drill_is_Inch, - format, File_Drill_Offset ); + m_UnitDrillIsInch, + format, m_FileDrillOffset ); } @@ -833,7 +616,7 @@ void DIALOG_GENDRILL::GenDrillReport( const wxString aFileName ) GenDrillReportFile( report_dest, m_Parent->GetBoard(), m_Parent->GetScreen()->m_FileName, - s_Unit_Drill_is_Inch, + m_UnitDrillIsInch, s_HoleListBuffer, s_ToolListBuffer ); } diff --git a/pcbnew/gendrill.h b/pcbnew/gendrill.h index 8232e2c858..03b81416aa 100644 --- a/pcbnew/gendrill.h +++ b/pcbnew/gendrill.h @@ -2,8 +2,8 @@ /* classes and functions declaration used in drill file and report generation */ /******************************************************************************/ -#ifndef GENDRILL_H -#define GENDRILL_H +#ifndef _GENDRILL_H_ +#define _GENDRILL_H_ /* the DRILL_TOOL class handles tools used in the excellon drill file */ class DRILL_TOOL @@ -39,15 +39,25 @@ public: }; -/* the DrillPrecision class to handle drill precision format in excellon files*/ -class DrillPrecision +/* the DRILL_PRECISION helper class to handle drill precision format in excellon files +*/ +class DRILL_PRECISION { public: - int m_lhs; - int m_rhs; + int m_lhs; // Left digit number (integer value of coordinates) + int m_rhs; // Right digit number (deciam value of coordinates) public: - DrillPrecision( int l, int r ) { m_lhs = l; m_rhs = r; } + DRILL_PRECISION( int l = 2, int r = 4) + { + m_lhs = l; m_rhs = r; + } + wxString GetPrecisionString() + { + wxString text; + text << m_lhs << wxT(":") << m_rhs; + return text; + } }; /* zeros format */ @@ -99,4 +109,4 @@ void GenDrillReportFile( FILE* aFile, BOARD * aPcb, const wxString& aBoardFilena std::vector& aToolListBuffer ); -#endif // #ifndef GENDRILL_H +#endif // #ifndef _GENDRILL_H_ diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index a3fb67cbfe..6a6b4b3da6 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -6,14 +6,9 @@ #include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" -#include "module_editor_frame.h" -#include "pcbnew_id.h" -#include "class_drawpanel.h" -#include "confirm.h" -#include "class_board_design_settings.h" +//#include "pcbnew_id.h" #include "hotkeys.h" -#include "protos.h" /* How to add a new hotkey: * add a new id in the enum hotkey_id_commnand like MY_NEW_ID_FUNCTION. @@ -143,7 +138,7 @@ static Ki_HotkeyInfo HkTrackDisplayMode( wxT( "Track Display Mode" ), static Ki_HotkeyInfo HkAddModule( wxT( "Add Module" ), HK_ADD_MODULE, 'O' ); // List of common hotkey descriptors -Ki_HotkeyInfo* s_Common_Hotkey_List[] = +Ki_HotkeyInfo* common_Hotkey_List[] = { &HkHelp, &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, &HkZoomAuto, @@ -153,7 +148,7 @@ Ki_HotkeyInfo* s_Common_Hotkey_List[] = }; // List of hotkey descriptors for pcbnew -Ki_HotkeyInfo* s_board_edit_Hotkey_List[] = +Ki_HotkeyInfo* board_edit_Hotkey_List[] = { &HkTrackDisplayMode, &HkDelete, &HkBackspace, @@ -171,977 +166,46 @@ Ki_HotkeyInfo* s_board_edit_Hotkey_List[] = }; // List of hotkey descriptors for the module editor -Ki_HotkeyInfo* s_module_edit_Hotkey_List[] = { +Ki_HotkeyInfo* module_edit_Hotkey_List[] = { &HkMoveItem, &HkRotateItem, &HkEditBoardItem, &HkDelete, NULL }; -// list of sections and corresponding hotkey list for pcbnew (used to create an hotkey config file) -struct Ki_HotkeyInfoSectionDescriptor s_Pcbnew_Editor_Hokeys_Descr[] = +// list of sections and corresponding hotkey list for pcbnew + // (used to create an hotkey config file, and edit hotkeys ) +struct Ki_HotkeyInfoSectionDescriptor g_Pcbnew_Editor_Hokeys_Descr[] = { { - &g_CommonSectionTag, s_Common_Hotkey_List, L"Common keys" + &g_CommonSectionTag, common_Hotkey_List, L"Common keys" }, { - &g_BoardEditorSectionTag, s_board_edit_Hotkey_List, L"Board editor keys" + &g_BoardEditorSectionTag, board_edit_Hotkey_List, L"Board editor keys" },{ - &g_ModuleEditSectionTag, s_module_edit_Hotkey_List, L"Footprint editor keys" + &g_ModuleEditSectionTag, module_edit_Hotkey_List, L"Footprint editor keys" },{ NULL, NULL, NULL } }; -// list of sections and corresponding hotkey list for the board editor (used to list current hotkeys) -struct Ki_HotkeyInfoSectionDescriptor s_Board_Editor_Hokeys_Descr[] = +// list of sections and corresponding hotkey list for the board editor +// (used to list current hotkeys in the board editor) +struct Ki_HotkeyInfoSectionDescriptor g_Board_Editor_Hokeys_Descr[] = { { - &g_CommonSectionTag, s_Common_Hotkey_List, + &g_CommonSectionTag, common_Hotkey_List, NULL },{ - &g_BoardEditorSectionTag, s_board_edit_Hotkey_List, NULL + &g_BoardEditorSectionTag, board_edit_Hotkey_List, NULL },{ NULL, NULL, NULL } }; -// list of sections and corresponding hotkey list for the footprint editor (used to list current hotkeys) -struct Ki_HotkeyInfoSectionDescriptor s_Module_Editor_Hokeys_Descr[] = +// list of sections and corresponding hotkey list for the footprint editor +// (used to list current hotkeys in the module editor) +struct Ki_HotkeyInfoSectionDescriptor g_Module_Editor_Hokeys_Descr[] = { { - &g_CommonSectionTag, s_Common_Hotkey_List, NULL + &g_CommonSectionTag, common_Hotkey_List, NULL },{ - &g_ModuleEditSectionTag, s_module_edit_Hotkey_List, NULL + &g_ModuleEditSectionTag, module_edit_Hotkey_List, NULL },{ NULL, NULL, NULL } }; -/** - * Function OnHotKey. - * ** Commands are case insensitive ** - * Some commands are relatives to the item under the mouse cursor - * @param aDC = current device context - * @param hotkey = hotkey code (ascii or wxWidget code for special keys) - * @param aItem = NULL or pointer on a EDA_BaseStruct under the mouse cursor - */ -void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_BaseStruct* aItem ) -{ - if( aHotkeyCode == 0 ) - return; - - bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->m_Flags); - - MODULE* module = NULL; - int evt_type = 0; //Used to post a wxCommandEvent on demand - - /* Convert lower to upper case - * (the usual toupper function has problem with non ascii codes like function keys - */ - if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') ) - aHotkeyCode += 'A' - 'a'; - - Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, s_Common_Hotkey_List ); - - if( HK_Descr == NULL ) - HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, s_board_edit_Hotkey_List ); - - if( HK_Descr == NULL ) - return; - - // Create a wxCommandEvent that will be posted in some hot keys functions - wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); - cmd.SetEventObject( this ); - - int ll; - - switch( HK_Descr->m_Idcommand ) - { - default: - case HK_NOT_FOUND: - return; - break; - - case HK_SWITCH_LAYER_TO_PREVIOUS: - ll = getActiveLayer(); - if( (ll <= LAYER_N_BACK) || (ll > LAYER_N_FRONT) ) - break; - - if( GetBoard()->GetCopperLayerCount() < 2 ) // Single layer - ll = LAYER_N_BACK; - else if( ll == LAYER_N_FRONT ) - ll = MAX( LAYER_N_BACK, - GetBoard()->GetCopperLayerCount() - 2 ); - else - ll--; - SwitchLayer( aDC, ll ); - break; - - case HK_SWITCH_LAYER_TO_NEXT: - ll = getActiveLayer(); - if( (ll < LAYER_N_BACK) || (ll >= LAYER_N_FRONT) ) - break; - if( GetBoard()->GetCopperLayerCount() < 2 ) // Single layer - ll = LAYER_N_BACK; - else if( ll >= GetBoard()->GetCopperLayerCount() - 2 ) - ll = LAYER_N_FRONT; - else - ll++; - SwitchLayer( aDC, ll ); - break; - - case HK_SWITCH_LAYER_TO_COMPONENT: - SwitchLayer( aDC, LAYER_N_FRONT ); - break; - - case HK_SWITCH_LAYER_TO_COPPER: - SwitchLayer( aDC, LAYER_N_BACK ); - break; - - case HK_SWITCH_LAYER_TO_INNER1: - SwitchLayer( aDC, LAYER_N_2 ); - break; - - case HK_SWITCH_LAYER_TO_INNER2: - SwitchLayer( aDC, LAYER_N_3 ); - break; - - case HK_SWITCH_LAYER_TO_INNER3: - SwitchLayer( aDC, LAYER_N_4 ); - break; - - case HK_SWITCH_LAYER_TO_INNER4: - SwitchLayer( aDC, LAYER_N_5 ); - break; - - case HK_SWITCH_LAYER_TO_INNER5: - SwitchLayer( aDC, LAYER_N_6 ); - break; - - case HK_SWITCH_LAYER_TO_INNER6: - SwitchLayer( aDC, LAYER_N_7 ); - break; - - case HK_HELP: // Display Current hotkey list - DisplayHotkeyList( this, s_Board_Editor_Hokeys_Descr ); - break; - - case HK_ZOOM_IN: - evt_type = ID_POPUP_ZOOM_IN; - break; - - case HK_ZOOM_OUT: - evt_type = ID_POPUP_ZOOM_OUT; - break; - - case HK_ZOOM_REDRAW: - evt_type = ID_ZOOM_REDRAW; - break; - - case HK_ZOOM_AUTO: - evt_type = ID_ZOOM_PAGE; - break; - - case HK_ZOOM_CENTER: - evt_type = ID_POPUP_ZOOM_CENTER; - break; - - case HK_ADD_MODULE: - evt_type = ID_COMPONENT_BUTT; - break; - - case HK_UNDO: - case HK_REDO: - if( !itemCurrentlyEdited ) - { - wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, - HK_Descr->m_IdMenuEvent ); - wxPostEvent( this, event ); - } - break; - - case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ - GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; - break; - - case HK_SWITCH_UNITS: - g_UserUnit = (g_UserUnit == INCHES) ? MILLIMETRES : INCHES; - break; - - case HK_SWITCH_TRACK_DISPLAY_MODE: - DisplayOpt.DisplayPcbTrackFill ^= 1; - DisplayOpt.DisplayPcbTrackFill &= 1; - m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; - DrawPanel->Refresh(); - break; - - case HK_DELETE: - OnHotkeyDeleteItem( aDC ); - break; - - case HK_BACK_SPACE: - if( m_ID_current_state == ID_TRACK_BUTT && (getActiveLayer() <= LAYER_N_FRONT) ) - { - if( !itemCurrentlyEdited ) - { - // no track is currently being edited - select a segment and remove it. - // @todo: possibly? pass the HK command code to PcbGeneralLocateAndDisplay() - // so it can restrict its search to specific item types. - aItem = PcbGeneralLocateAndDisplay(); - - // don't let backspace delete modules!! - if( aItem && (aItem->Type() == TYPE_TRACK - || aItem->Type() == TYPE_VIA) ) - { - Delete_Segment( aDC, (TRACK*) aItem ); - SetCurItem( NULL ); - } - OnModify(); - } - else if( GetCurItem()->Type() == TYPE_TRACK ) - { - // then an element is being edited - remove the last segment. - // simple lines for debugger: - TRACK* track = (TRACK*) GetCurItem(); - track = Delete_Segment( aDC, track ); - SetCurItem( track ); - OnModify(); - } - } - break; - - case HK_END_TRACK: - if( itemCurrentlyEdited && (GetCurItem()->Type() == TYPE_TRACK) - && ( (GetCurItem()->m_Flags & IS_NEW) != 0 ) ) - { - // A new track is in progress: call to End_Route() - DrawPanel->MouseToCursorSchema(); - End_Route( (TRACK*) GetCurItem(), aDC ); - } - break; - - case HK_GET_AND_MOVE_FOOTPRINT: - if( !itemCurrentlyEdited ) - evt_type = ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST; - break; - - case HK_FIND_ITEM: - if( !itemCurrentlyEdited ) - evt_type = ID_FIND_ITEMS; - break; - - case HK_LOAD_BOARD: - if( !itemCurrentlyEdited ) - evt_type = ID_LOAD_FILE ; - break; - - case HK_SAVE_BOARD: - if( !itemCurrentlyEdited ) - evt_type = ID_SAVE_BOARD; - break; - - case HK_ADD_MICROVIA: // Place a micro via if a track is in progress - if( m_ID_current_state != ID_TRACK_BUTT ) - return; - if( !itemCurrentlyEdited ) // no track in progress: nothing to do - break; - if( GetCurItem()->Type() != TYPE_TRACK ) // Should not occur - return; - if( (GetCurItem()->m_Flags & IS_NEW) == 0 ) - return; - - // place micro via and switch layer - if( IsMicroViaAcceptable() ) - evt_type = ID_POPUP_PCB_PLACE_MICROVIA; - break; - - case HK_ADD_VIA: // Switch to alternate layer and Place a via if a track is in progress - if( !itemCurrentlyEdited ) // no track in progress: switch layer only - { - Other_Layer_Route( NULL, aDC ); - break; - } - if( m_ID_current_state != ID_TRACK_BUTT ) - return; - if( GetCurItem()->Type() != TYPE_TRACK ) - return; - if( (GetCurItem()->m_Flags & IS_NEW) == 0 ) - return; - evt_type = ID_POPUP_PCB_PLACE_VIA; - break; - - case HK_SWITCH_TRACK_POSTURE: - /* change the position of initial segment when creating new tracks - * switch from _/ to -\ . - */ - evt_type = ID_POPUP_PCB_SWITCH_TRACK_POSTURE ; - break; - - case HK_ADD_NEW_TRACK: // Start new track - if( getActiveLayer() > LAYER_N_FRONT ) - break; - - if( m_ID_current_state != ID_TRACK_BUTT && !itemCurrentlyEdited ) - { - cmd.SetId( ID_TRACK_BUTT ); - GetEventHandler()->ProcessEvent( cmd ); - } - - if( m_ID_current_state != ID_TRACK_BUTT ) - break; - - if( !itemCurrentlyEdited ) // no track in progress: - { - TRACK* track = Begin_Route( NULL, aDC ); - SetCurItem( track ); - if( track ) - DrawPanel->m_AutoPAN_Request = true; - } - else if( GetCurItem()->m_Flags & IS_NEW ) - { - TRACK* track = Begin_Route( (TRACK*) GetCurItem(), aDC ); - - // SetCurItem() must not write to the msg panel - // because a track info is displayed while moving the mouse cursor - if( track ) // A new segment was created - SetCurItem( track, false ); - DrawPanel->m_AutoPAN_Request = true; - } - break; - - case HK_EDIT_ITEM: // Edit board item - OnHotkeyEditItem( HK_EDIT_ITEM ); - break; - - // Footprint edition: - case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status: - // get any module, locked or not locked and toggle its locked status - if( !itemCurrentlyEdited ) - module = Locate_Prefered_Module( GetBoard(), CURSEUR_OFF_GRILLE - | VISIBLE_ONLY ); - else if( GetCurItem()->Type() == TYPE_MODULE ) - module = (MODULE*) GetCurItem(); - if( module ) - { - SetCurItem( module ); - module->SetLocked( !module->IsLocked() ); - module->DisplayInfo( this ); - } - break; - - case HK_DRAG_ITEM: // Start drag module or track segment - OnHotkeyMoveItem( HK_DRAG_ITEM ); - break; - - case HK_MOVE_ITEM: // Start move item - OnHotkeyMoveItem( HK_MOVE_ITEM ); - break; - - case HK_ROTATE_ITEM: // Rotation - OnHotkeyRotateItem( HK_ROTATE_ITEM ); - break; - - case HK_FLIP_FOOTPRINT: // move to other side - OnHotkeyRotateItem( HK_FLIP_FOOTPRINT ); - break; - } - - if( evt_type != 0 ) - { - wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); - evt.SetEventObject( this ); - evt.SetId( evt_type ); - wxPostEvent( this, evt ); - } -} - - -/***********************************************************/ -void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int hotkey, - EDA_BaseStruct* DrawStruct ) -/***********************************************************/ - -/* Hot keys. Some commands are relative to the item under the mouse cursor - * Commands are case insensitive - */ -{ - if( hotkey == 0 ) - return; - - BOARD_ITEM* item = GetCurItem(); - bool ItemFree = (item == 0) || (item->m_Flags == 0); - wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); - cmd.SetEventObject( this ); - - /* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */ - if( (hotkey >= 'a') && (hotkey <= 'z') ) - hotkey += 'A' - 'a'; - - Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey, s_Common_Hotkey_List ); - - if( HK_Descr == NULL ) - HK_Descr = GetDescriptorFromHotkey( hotkey, s_module_edit_Hotkey_List ); - - if( HK_Descr == NULL ) - return; - - switch( HK_Descr->m_Idcommand ) - { - default: - case HK_NOT_FOUND: - return; - break; - - case HK_HELP: // Display Current hotkey list - DisplayHotkeyList( this, s_Module_Editor_Hokeys_Descr ); - break; - - case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ - GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; - break; - - case HK_SWITCH_UNITS: - g_UserUnit = (g_UserUnit == INCHES) ? MILLIMETRES : INCHES; - break; - - case HK_ZOOM_IN: - cmd.SetId( ID_POPUP_ZOOM_IN ); - GetEventHandler()->ProcessEvent( cmd ); - break; - - case HK_ZOOM_OUT: - cmd.SetId( ID_POPUP_ZOOM_OUT ); - GetEventHandler()->ProcessEvent( cmd ); - break; - - case HK_ZOOM_REDRAW: - cmd.SetId( ID_ZOOM_REDRAW ); - GetEventHandler()->ProcessEvent( cmd ); - break; - - case HK_ZOOM_CENTER: - cmd.SetId( ID_POPUP_ZOOM_CENTER ); - GetEventHandler()->ProcessEvent( cmd ); - break; - - case HK_UNDO: - case HK_REDO: - if( ItemFree ) - { - wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, - HK_Descr->m_IdMenuEvent ); - wxPostEvent( this, event ); - } - break; - - case HK_ZOOM_AUTO: - cmd.SetId( ID_ZOOM_PAGE ); - GetEventHandler()->ProcessEvent( cmd ); - break; - - case HK_EDIT_ITEM: - OnHotkeyEditItem( HK_EDIT_ITEM ); - break; - - case HK_DELETE: - OnHotkeyDeleteItem( HK_DELETE ); - break; - - case HK_MOVE_ITEM: - OnHotkeyMoveItem( HK_MOVE_ITEM ); - break; - - case HK_ROTATE_ITEM: - OnHotkeyRotateItem( HK_ROTATE_ITEM ); - break; - } -} - -bool WinEDA_ModuleEditFrame::OnHotkeyEditItem( int aIdCommand ) -{ - BOARD_ITEM* item = GetCurItem(); - bool itemCurrentlyEdited = item && item->m_Flags; - - if( itemCurrentlyEdited ) - return false; - - item = ModeditLocateAndDisplay(); - - if( item == NULL ) - return false; - - SetCurItem( item ); - - int evt_type = 0; //Used to post a wxCommandEvent on demand - - switch( item->Type() ) - { - case TYPE_MODULE: - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_MODULE; - break; - - case TYPE_PAD: - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_PAD; - break; - - case TYPE_TEXTE_MODULE: - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_TEXTMODULE; - break; - - default: - break; - } - - if( evt_type != 0 ) - { - wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); - evt.SetEventObject( this ); - evt.SetId( evt_type ); - wxPostEvent( this, evt ); - return true; - } - - return false; -} - -bool WinEDA_ModuleEditFrame::OnHotkeyDeleteItem( int aIdCommand ) -{ - BOARD_ITEM* item = GetCurItem(); - bool itemCurrentlyEdited = item && item->m_Flags; - - if( itemCurrentlyEdited ) - return false; - - item = ModeditLocateAndDisplay(); - - if( item == NULL ) - return false; - - SetCurItem( item ); - - int evt_type = 0; //Used to post a wxCommandEvent on demand - - switch( item->Type() ) - { - case TYPE_PAD: - if( aIdCommand == HK_DELETE ) - evt_type = ID_POPUP_PCB_DELETE_PAD; - break; - - case TYPE_TEXTE_MODULE: - if( aIdCommand == HK_DELETE ) - evt_type = ID_POPUP_PCB_DELETE_TEXTMODULE; - break; - - case TYPE_EDGE_MODULE: - if( aIdCommand == HK_DELETE ) - evt_type = ID_POPUP_PCB_DELETE_EDGE; - break; - - default: - break; - } - - if( evt_type != 0 ) - { - wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); - evt.SetEventObject( this ); - evt.SetId( evt_type ); - wxPostEvent( this, evt ); - return true; - } - - return false; -} - -bool WinEDA_ModuleEditFrame::OnHotkeyMoveItem( int aIdCommand ) -{ - BOARD_ITEM* item = GetCurItem(); - bool itemCurrentlyEdited = item && item->m_Flags; - - if( itemCurrentlyEdited ) - return false; - - item = ModeditLocateAndDisplay(); - - if( item == NULL ) - return false; - - SetCurItem( item ); - - int evt_type = 0; //Used to post a wxCommandEvent on demand - - switch( item->Type() ) - { - case TYPE_PAD: - if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_PAD_REQUEST; - break; - - case TYPE_TEXTE_MODULE: - if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST; - break; - - case TYPE_EDGE_MODULE: - if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_EDGE; - break; - - default: - break; - } - - if( evt_type != 0 ) - { - wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); - evt.SetEventObject( this ); - evt.SetId( evt_type ); - wxPostEvent( this, evt ); - return true; - } - - return false; -} - -bool WinEDA_ModuleEditFrame::OnHotkeyRotateItem( int aIdCommand ) -{ - BOARD_ITEM* item = GetCurItem(); - bool itemCurrentlyEdited = item && item->m_Flags; - int evt_type = 0; // Used to post a wxCommandEvent on demand - - if( !itemCurrentlyEdited ) - item = ModeditLocateAndDisplay(); - - if( item == NULL ) - return false; - - SetCurItem( item ); - - switch( item->Type() ) - { - case TYPE_TEXTE_MODULE: - if( aIdCommand == HK_ROTATE_ITEM ) // Rotation - evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE; - break; - - default: - break; - } - - if( evt_type != 0 ) - { - wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); - evt.SetEventObject( this ); - evt.SetId( evt_type ); - wxPostEvent( this, evt ); - return true; - } - - return false; -} - -/** - * Function OnHotkeyDeleteItem - * Delete the item found under the mouse cursor - * Depending on the current active tool:: - * Tool track - * if a track is in progress: Delete the last segment - * else delete the entire track - * Tool module (footprint): - * Delete the module. - * @param aDC = current device context - * @return true if an item was deleted - */ -bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* aDC ) -{ - BOARD_ITEM* item = GetCurItem(); - bool ItemFree = (item == NULL) || (item->m_Flags == 0); - - switch( m_ID_current_state ) - { - case ID_TRACK_BUTT: - if( getActiveLayer() > LAYER_N_FRONT ) - return false; - if( ItemFree ) - { - item = PcbGeneralLocateAndDisplay(); - if( item && item->Type() != TYPE_TRACK ) - return false; - Delete_Track( aDC, (TRACK*) item ); - } - else if( item->Type() == TYPE_TRACK ) - { - // simple lines for debugger: - TRACK* track = (TRACK*) item; - track = Delete_Segment( aDC, track ); - SetCurItem( track ); - OnModify(); - return true; - } - break; - - case ID_COMPONENT_BUTT: - if( ItemFree ) - { - MODULE* module = Locate_Prefered_Module( GetBoard(), - CURSEUR_ON_GRILLE ); - if( module == NULL ) - return false; - if( !IsOK( this, _( "Delete module?" ) ) ) - return false; - RemoveStruct( module, aDC ); - } - else - return false; - break; - - default: - return false; - } - - OnModify(); - SetCurItem( NULL ); - return true; -} - -bool WinEDA_PcbFrame::OnHotkeyEditItem( int aIdCommand ) -{ - BOARD_ITEM* item = GetCurItem(); - bool itemCurrentlyEdited = item && item->m_Flags; - - if( itemCurrentlyEdited ) - return false; - - item = PcbGeneralLocateAndDisplay(); - - if( item == NULL ) - return false; - - SetCurItem( item ); - - int evt_type = 0; //Used to post a wxCommandEvent on demand - - switch( item->Type() ) - { - case TYPE_TRACK: - case TYPE_VIA: - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_TRACKSEG; - break; - - case TYPE_TEXTE: - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_TEXTEPCB; - break; - - case TYPE_MODULE: - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_MODULE; - break; - - case TYPE_PAD: - // Post a EDIT_MODULE event here to prevent pads - // from being edited by hotkeys. - // Process_Special_Functions takes care of finding - // the parent. - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_MODULE; - break; - - case TYPE_MIRE: - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_MIRE; - break; - - case TYPE_DIMENSION: - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_DIMENSION; - break; - - case TYPE_TEXTE_MODULE: - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_TEXTMODULE; - break; - - case TYPE_DRAWSEGMENT: - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_DRAWING; - break; - - case TYPE_ZONE_CONTAINER: - if( aIdCommand == HK_EDIT_ITEM ) - evt_type = ID_POPUP_PCB_EDIT_ZONE_PARAMS; - break; - - default: - break; - } - - if( evt_type != 0 ) - { - wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); - evt.SetEventObject( this ); - evt.SetId( evt_type ); - wxPostEvent( this, evt ); - return true; - } - - return false; -} - -/** - * Function OnHotkeyMoveItem - * Move or drag the item (footprint, track, text .. ) found under the mouse cursor - * An item can be moved (or dragged) only if there is no item currently edited - * Only a footprint, a pad or a track can be dragged - * @param aIdCommand = the hotkey command id - * @return true if an item was moved - */ -bool WinEDA_PcbFrame::OnHotkeyMoveItem( int aIdCommand ) -{ - BOARD_ITEM* item = GetCurItem(); - bool itemCurrentlyEdited = item && item->m_Flags; - - if( itemCurrentlyEdited ) - return false; - - item = PcbGeneralLocateAndDisplay(); - - if( item == NULL ) - return false; - - SetCurItem( item ); - - int evt_type = 0; //Used to post a wxCommandEvent on demand - - switch( item->Type() ) - { - case TYPE_TRACK: - case TYPE_VIA: - if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_TRACK_NODE; - if( aIdCommand == HK_DRAG_ITEM ) - evt_type = ID_POPUP_PCB_DRAG_TRACK_SEGMENT; - break; - - case TYPE_MODULE: - { - if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_MODULE_REQUEST; - if( aIdCommand == HK_DRAG_ITEM ) - evt_type = ID_POPUP_PCB_DRAG_MODULE_REQUEST; - } - break; - - case TYPE_PAD: - // Post MODULE_REQUEST events here to prevent pads - // from being moved or dragged by hotkeys. - // Process_Special_Functions takes care of finding - // the parent. - if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_MODULE_REQUEST; - if( aIdCommand == HK_DRAG_ITEM ) - evt_type = ID_POPUP_PCB_DRAG_MODULE_REQUEST; - break; - - case TYPE_TEXTE: - if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST; - break; - - case TYPE_MIRE: - if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_MIRE_REQUEST; - break; - - case TYPE_ZONE_CONTAINER: - if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_ZONE_OUTLINES; - if( aIdCommand == HK_DRAG_ITEM ) - evt_type = ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT; - break; - - case TYPE_TEXTE_MODULE: - if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST; - break; - - case TYPE_DRAWSEGMENT: - if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_DRAWING_REQUEST; - break; - - default: - break; - } - - if( evt_type != 0 ) - { - wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); - evt.SetEventObject( this ); - evt.SetId( evt_type ); - wxPostEvent( this, evt ); - return true; - } - - return false; -} - - -/** - * Function OnHotkeyRotateItem - * Rotate the item (text or footprint) found under the mouse cursor - * Note: - * this command can be used with an item currently in edit - * Only some items can be rotated (footprints and texts) - * @param aIdCommand = the hotkey command id - * @return true if an item was moved - */ -bool WinEDA_PcbFrame::OnHotkeyRotateItem( int aIdCommand ) -{ - BOARD_ITEM* item = GetCurItem(); - bool itemCurrentlyEdited = item && item->m_Flags; - int evt_type = 0; // Used to post a wxCommandEvent on demand - - if( !itemCurrentlyEdited ) - item = PcbGeneralLocateAndDisplay(); - - if( item == NULL ) - return false; - - SetCurItem( item ); - - switch( item->Type() ) - { - case TYPE_MODULE: - { - if( aIdCommand == HK_ROTATE_ITEM ) // Rotation - evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE; - if( aIdCommand == HK_FLIP_FOOTPRINT ) // move to other side - evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE; - } - break; - - case TYPE_TEXTE: - if( aIdCommand == HK_ROTATE_ITEM ) // Rotation - evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB; - break; - - case TYPE_TEXTE_MODULE: - if( aIdCommand == HK_ROTATE_ITEM ) // Rotation - evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE; - break; - - default: - break; - } - - if( evt_type != 0 ) - { - wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); - evt.SetEventObject( this ); - evt.SetId( evt_type ); - wxPostEvent( this, evt ); - return true; - } - - return false; -} diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h index ccbe7a352d..173cbf169c 100644 --- a/pcbnew/hotkeys.h +++ b/pcbnew/hotkeys.h @@ -51,13 +51,24 @@ enum hotkey_id_commnand { HK_SLIDE_TRACK }; -// List of hotkey descriptors for pcbnew -extern struct Ki_HotkeyInfoSectionDescriptor s_Pcbnew_Editor_Hokeys_Descr[]; +// Full list of hotkey descriptors for borad editor and footprint editor +extern struct Ki_HotkeyInfoSectionDescriptor g_Pcbnew_Editor_Hokeys_Descr[]; // List of hotkey descriptors for the board editor only -extern struct Ki_HotkeyInfoSectionDescriptor s_Board_Editor_Hokeys_Descr[]; +extern struct Ki_HotkeyInfoSectionDescriptor g_Board_Editor_Hokeys_Descr[]; // List of hotkey descriptors for the footprint editor only -extern struct Ki_HotkeyInfoSectionDescriptor s_Module_Editor_Hokeys_Descr[]; +extern struct Ki_HotkeyInfoSectionDescriptor g_Module_Editor_Hokeys_Descr[]; + +// List of common hotkey descriptors +// used in hotkeys_board_editor.cpp and hotkeys_module_editor.cpp +extern Ki_HotkeyInfo* common_Hotkey_List[]; +// List of hotkey descriptors for pcbnew +// used in hotkeys_board_editor.cpp +extern Ki_HotkeyInfo* board_edit_Hotkey_List[]; +// List of hotkey descriptors for the module editor +// used in hotkeys_module_editor.cpp +extern Ki_HotkeyInfo* module_edit_Hotkey_List[]; + #endif /* _PCBNEW_HOTKEYS_H_ */ diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp new file mode 100644 index 0000000000..468e67ef4c --- /dev/null +++ b/pcbnew/hotkeys_board_editor.cpp @@ -0,0 +1,675 @@ +/***************/ +/* hotkeys_board_editor.cpp */ +/***************/ + +#include "fctsys.h" +#include "common.h" +#include "pcbnew.h" +#include "wxPcbStruct.h" +#include "pcbnew_id.h" +#include "class_drawpanel.h" +#include "confirm.h" +#include "class_board_design_settings.h" + +#include "hotkeys.h" +#include "protos.h" + +/* How to add a new hotkey: + * see hotkeys.cpp + */ + + +/** + * Function OnHotKey. + * ** Commands are case insensitive ** + * Some commands are relatives to the item under the mouse cursor + * @param aDC = current device context + * @param hotkey = hotkey code (ascii or wxWidget code for special keys) + * @param aItem = NULL or pointer on a EDA_BaseStruct under the mouse cursor + */ +void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_BaseStruct* aItem ) +{ + if( aHotkeyCode == 0 ) + return; + + bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->m_Flags); + + MODULE* module = NULL; + int evt_type = 0; //Used to post a wxCommandEvent on demand + + /* Convert lower to upper case + * (the usual toupper function has problem with non ascii codes like function keys + */ + if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') ) + aHotkeyCode += 'A' - 'a'; + + Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, common_Hotkey_List ); + + if( HK_Descr == NULL ) + HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, board_edit_Hotkey_List ); + + if( HK_Descr == NULL ) + return; + + // Create a wxCommandEvent that will be posted in some hot keys functions + wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); + cmd.SetEventObject( this ); + + int ll; + + switch( HK_Descr->m_Idcommand ) + { + default: + case HK_NOT_FOUND: + return; + break; + + case HK_SWITCH_LAYER_TO_PREVIOUS: + ll = getActiveLayer(); + if( (ll <= LAYER_N_BACK) || (ll > LAYER_N_FRONT) ) + break; + + if( GetBoard()->GetCopperLayerCount() < 2 ) // Single layer + ll = LAYER_N_BACK; + else if( ll == LAYER_N_FRONT ) + ll = MAX( LAYER_N_BACK, + GetBoard()->GetCopperLayerCount() - 2 ); + else + ll--; + SwitchLayer( aDC, ll ); + break; + + case HK_SWITCH_LAYER_TO_NEXT: + ll = getActiveLayer(); + if( (ll < LAYER_N_BACK) || (ll >= LAYER_N_FRONT) ) + break; + if( GetBoard()->GetCopperLayerCount() < 2 ) // Single layer + ll = LAYER_N_BACK; + else if( ll >= GetBoard()->GetCopperLayerCount() - 2 ) + ll = LAYER_N_FRONT; + else + ll++; + SwitchLayer( aDC, ll ); + break; + + case HK_SWITCH_LAYER_TO_COMPONENT: + SwitchLayer( aDC, LAYER_N_FRONT ); + break; + + case HK_SWITCH_LAYER_TO_COPPER: + SwitchLayer( aDC, LAYER_N_BACK ); + break; + + case HK_SWITCH_LAYER_TO_INNER1: + SwitchLayer( aDC, LAYER_N_2 ); + break; + + case HK_SWITCH_LAYER_TO_INNER2: + SwitchLayer( aDC, LAYER_N_3 ); + break; + + case HK_SWITCH_LAYER_TO_INNER3: + SwitchLayer( aDC, LAYER_N_4 ); + break; + + case HK_SWITCH_LAYER_TO_INNER4: + SwitchLayer( aDC, LAYER_N_5 ); + break; + + case HK_SWITCH_LAYER_TO_INNER5: + SwitchLayer( aDC, LAYER_N_6 ); + break; + + case HK_SWITCH_LAYER_TO_INNER6: + SwitchLayer( aDC, LAYER_N_7 ); + break; + + case HK_HELP: // Display Current hotkey list + DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr ); + break; + + case HK_ZOOM_IN: + evt_type = ID_POPUP_ZOOM_IN; + break; + + case HK_ZOOM_OUT: + evt_type = ID_POPUP_ZOOM_OUT; + break; + + case HK_ZOOM_REDRAW: + evt_type = ID_ZOOM_REDRAW; + break; + + case HK_ZOOM_AUTO: + evt_type = ID_ZOOM_PAGE; + break; + + case HK_ZOOM_CENTER: + evt_type = ID_POPUP_ZOOM_CENTER; + break; + + case HK_ADD_MODULE: + evt_type = ID_COMPONENT_BUTT; + break; + + case HK_UNDO: + case HK_REDO: + if( !itemCurrentlyEdited ) + { + wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, + HK_Descr->m_IdMenuEvent ); + wxPostEvent( this, event ); + } + break; + + case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ + GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + break; + + case HK_SWITCH_UNITS: + g_UserUnit = (g_UserUnit == INCHES) ? MILLIMETRES : INCHES; + break; + + case HK_SWITCH_TRACK_DISPLAY_MODE: + DisplayOpt.DisplayPcbTrackFill ^= 1; + DisplayOpt.DisplayPcbTrackFill &= 1; + m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; + DrawPanel->Refresh(); + break; + + case HK_DELETE: + OnHotkeyDeleteItem( aDC ); + break; + + case HK_BACK_SPACE: + if( /*m_ID_current_state == ID_TRACK_BUTT &&*/ (getActiveLayer() <= LAYER_N_FRONT) ) + { + if( !itemCurrentlyEdited ) + { + // no track is currently being edited - select a segment and remove it. + // @todo: possibly? pass the HK command code to PcbGeneralLocateAndDisplay() + // so it can restrict its search to specific item types. + BOARD_ITEM * item = PcbGeneralLocateAndDisplay(); + + // don't let backspace delete modules!! + if( item && item->IsTrack() ) + { + Delete_Segment( aDC, (TRACK*) item ); + SetCurItem( NULL ); + } + OnModify(); + } + else if( GetCurItem()->IsTrack() ) + { + // then an element is being edited - remove the last segment. + // simple lines for debugger: + TRACK* track = (TRACK*) GetCurItem(); + track = Delete_Segment( aDC, track ); + SetCurItem( track ); + OnModify(); + } + } + break; + + case HK_END_TRACK: + if( itemCurrentlyEdited && (GetCurItem()->IsTrack() ) + && ( (GetCurItem()->m_Flags & IS_NEW) != 0 ) ) + { + // A new track is in progress: call to End_Route() + DrawPanel->MouseToCursorSchema(); + End_Route( (TRACK*) GetCurItem(), aDC ); + } + break; + + case HK_GET_AND_MOVE_FOOTPRINT: + if( !itemCurrentlyEdited ) + evt_type = ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST; + break; + + case HK_FIND_ITEM: + if( !itemCurrentlyEdited ) + evt_type = ID_FIND_ITEMS; + break; + + case HK_LOAD_BOARD: + if( !itemCurrentlyEdited ) + evt_type = ID_LOAD_FILE ; + break; + + case HK_SAVE_BOARD: + if( !itemCurrentlyEdited ) + evt_type = ID_SAVE_BOARD; + break; + + case HK_ADD_MICROVIA: // Place a micro via if a track is in progress + if( m_ID_current_state != ID_TRACK_BUTT ) + return; + if( !itemCurrentlyEdited ) // no track in progress: nothing to do + break; + if( GetCurItem()->Type() != TYPE_TRACK ) // Should not occur + return; + if( (GetCurItem()->m_Flags & IS_NEW) == 0 ) + return; + + // place micro via and switch layer + if( IsMicroViaAcceptable() ) + evt_type = ID_POPUP_PCB_PLACE_MICROVIA; + break; + + case HK_ADD_VIA: // Switch to alternate layer and Place a via if a track is in progress + if( !itemCurrentlyEdited ) // no track in progress: switch layer only + { + Other_Layer_Route( NULL, aDC ); + break; + } + if( m_ID_current_state != ID_TRACK_BUTT ) + return; + if( GetCurItem()->Type() != TYPE_TRACK ) + return; + if( (GetCurItem()->m_Flags & IS_NEW) == 0 ) + return; + evt_type = ID_POPUP_PCB_PLACE_VIA; + break; + + case HK_SWITCH_TRACK_POSTURE: + /* change the position of initial segment when creating new tracks + * switch from _/ to -\ . + */ + evt_type = ID_POPUP_PCB_SWITCH_TRACK_POSTURE ; + break; + + case HK_ADD_NEW_TRACK: // Start new track + if( getActiveLayer() > LAYER_N_FRONT ) + break; + + if( m_ID_current_state != ID_TRACK_BUTT && !itemCurrentlyEdited ) + { + cmd.SetId( ID_TRACK_BUTT ); + GetEventHandler()->ProcessEvent( cmd ); + } + + if( m_ID_current_state != ID_TRACK_BUTT ) + break; + + if( !itemCurrentlyEdited ) // no track in progress: + { + TRACK* track = Begin_Route( NULL, aDC ); + SetCurItem( track ); + if( track ) + DrawPanel->m_AutoPAN_Request = true; + } + else if( GetCurItem()->m_Flags & IS_NEW ) + { + TRACK* track = Begin_Route( (TRACK*) GetCurItem(), aDC ); + + // SetCurItem() must not write to the msg panel + // because a track info is displayed while moving the mouse cursor + if( track ) // A new segment was created + SetCurItem( track, false ); + DrawPanel->m_AutoPAN_Request = true; + } + break; + + case HK_EDIT_ITEM: // Edit board item + OnHotkeyEditItem( HK_EDIT_ITEM ); + break; + + // Footprint edition: + case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status: + // get any module, locked or not locked and toggle its locked status + if( !itemCurrentlyEdited ) + module = Locate_Prefered_Module( GetBoard(), CURSEUR_OFF_GRILLE + | VISIBLE_ONLY ); + else if( GetCurItem()->Type() == TYPE_MODULE ) + module = (MODULE*) GetCurItem(); + if( module ) + { + SetCurItem( module ); + module->SetLocked( !module->IsLocked() ); + module->DisplayInfo( this ); + } + break; + + case HK_DRAG_ITEM: // Start drag module or track segment + OnHotkeyMoveItem( HK_DRAG_ITEM ); + break; + + case HK_MOVE_ITEM: // Start move item + OnHotkeyMoveItem( HK_MOVE_ITEM ); + break; + + case HK_ROTATE_ITEM: // Rotation + OnHotkeyRotateItem( HK_ROTATE_ITEM ); + break; + + case HK_FLIP_FOOTPRINT: // move to other side + OnHotkeyRotateItem( HK_FLIP_FOOTPRINT ); + break; + } + + if( evt_type != 0 ) + { + wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); + evt.SetEventObject( this ); + evt.SetId( evt_type ); + wxPostEvent( this, evt ); + } +} + + +/** + * Function OnHotkeyDeleteItem + * Delete the item found under the mouse cursor + * Depending on the current active tool:: + * Tool track + * if a track is in progress: Delete the last segment + * else delete the entire track + * Tool module (footprint): + * Delete the module. + * @param aDC = current device context + * @return true if an item was deleted + */ +bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* aDC ) +{ + BOARD_ITEM* item = GetCurItem(); + bool ItemFree = (item == NULL) || (item->m_Flags == 0); + + switch( m_ID_current_state ) + { + case ID_TRACK_BUTT: + if( getActiveLayer() > LAYER_N_FRONT ) + return false; + if( ItemFree ) + { + item = PcbGeneralLocateAndDisplay(); + if( item && !item->IsTrack( ) ) + return false; + Delete_Track( aDC, (TRACK*) item ); + } + else if( item->IsTrack( ) ) + { + // simple lines for debugger: + TRACK* track = (TRACK*) item; + track = Delete_Segment( aDC, track ); + SetCurItem( track ); + OnModify(); + return true; + } + break; + + case ID_COMPONENT_BUTT: + if( ItemFree ) + { + MODULE* module = Locate_Prefered_Module( GetBoard(), CURSEUR_ON_GRILLE ); + if( module == NULL ) + return false; + if( !IsOK( this, _( "Delete module?" ) ) ) + return false; + RemoveStruct( module, aDC ); + } + else + return false; + break; + + default: + if( ItemFree ) + { + item = PcbGeneralLocateAndDisplay(); + if( item == NULL ) + return false; + if( (item->Type() == TYPE_MODULE) && !IsOK( this, _( "Delete module?" ) ) ) + return false; + RemoveStruct( item, aDC ); + } + else + return false; + } + + OnModify(); + SetCurItem( NULL ); + return true; +} + +bool WinEDA_PcbFrame::OnHotkeyEditItem( int aIdCommand ) +{ + BOARD_ITEM* item = GetCurItem(); + bool itemCurrentlyEdited = item && item->m_Flags; + + if( itemCurrentlyEdited ) + return false; + + item = PcbGeneralLocateAndDisplay(); + + if( item == NULL ) + return false; + + SetCurItem( item ); + + int evt_type = 0; //Used to post a wxCommandEvent on demand + + switch( item->Type() ) + { + case TYPE_TRACK: + case TYPE_VIA: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_TRACKSEG; + break; + + case TYPE_TEXTE: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_TEXTEPCB; + break; + + case TYPE_MODULE: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_MODULE; + break; + + case TYPE_PAD: + // Post a EDIT_MODULE event here to prevent pads + // from being edited by hotkeys. + // Process_Special_Functions takes care of finding + // the parent. + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_MODULE; + break; + + case TYPE_MIRE: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_MIRE; + break; + + case TYPE_DIMENSION: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_DIMENSION; + break; + + case TYPE_TEXTE_MODULE: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_TEXTMODULE; + break; + + case TYPE_DRAWSEGMENT: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_DRAWING; + break; + + case TYPE_ZONE_CONTAINER: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_ZONE_PARAMS; + break; + + default: + break; + } + + if( evt_type != 0 ) + { + wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); + evt.SetEventObject( this ); + evt.SetId( evt_type ); + wxPostEvent( this, evt ); + return true; + } + + return false; +} + +/** + * Function OnHotkeyMoveItem + * Move or drag the item (footprint, track, text .. ) found under the mouse cursor + * An item can be moved (or dragged) only if there is no item currently edited + * Only a footprint, a pad or a track can be dragged + * @param aIdCommand = the hotkey command id + * @return true if an item was moved + */ +bool WinEDA_PcbFrame::OnHotkeyMoveItem( int aIdCommand ) +{ + BOARD_ITEM* item = GetCurItem(); + bool itemCurrentlyEdited = item && item->m_Flags; + + if( itemCurrentlyEdited ) + return false; + + item = PcbGeneralLocateAndDisplay(); + + if( item == NULL ) + return false; + + SetCurItem( item ); + + int evt_type = 0; //Used to post a wxCommandEvent on demand + + switch( item->Type() ) + { + case TYPE_TRACK: + case TYPE_VIA: + if( aIdCommand == HK_MOVE_ITEM ) + evt_type = ID_POPUP_PCB_MOVE_TRACK_NODE; + if( aIdCommand == HK_DRAG_ITEM ) + evt_type = ID_POPUP_PCB_DRAG_TRACK_SEGMENT; + break; + + case TYPE_MODULE: + { + if( aIdCommand == HK_MOVE_ITEM ) + evt_type = ID_POPUP_PCB_MOVE_MODULE_REQUEST; + if( aIdCommand == HK_DRAG_ITEM ) + evt_type = ID_POPUP_PCB_DRAG_MODULE_REQUEST; + } + break; + + case TYPE_PAD: + // Post MODULE_REQUEST events here to prevent pads + // from being moved or dragged by hotkeys. + // Process_Special_Functions takes care of finding + // the parent. + if( aIdCommand == HK_MOVE_ITEM ) + evt_type = ID_POPUP_PCB_MOVE_MODULE_REQUEST; + if( aIdCommand == HK_DRAG_ITEM ) + evt_type = ID_POPUP_PCB_DRAG_MODULE_REQUEST; + break; + + case TYPE_TEXTE: + if( aIdCommand == HK_MOVE_ITEM ) + evt_type = ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST; + break; + + case TYPE_MIRE: + if( aIdCommand == HK_MOVE_ITEM ) + evt_type = ID_POPUP_PCB_MOVE_MIRE_REQUEST; + break; + + case TYPE_ZONE_CONTAINER: + if( aIdCommand == HK_MOVE_ITEM ) + evt_type = ID_POPUP_PCB_MOVE_ZONE_OUTLINES; + if( aIdCommand == HK_DRAG_ITEM ) + evt_type = ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT; + break; + + case TYPE_TEXTE_MODULE: + if( aIdCommand == HK_MOVE_ITEM ) + evt_type = ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST; + break; + + case TYPE_DRAWSEGMENT: + if( aIdCommand == HK_MOVE_ITEM ) + evt_type = ID_POPUP_PCB_MOVE_DRAWING_REQUEST; + break; + + default: + break; + } + + if( evt_type != 0 ) + { + wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); + evt.SetEventObject( this ); + evt.SetId( evt_type ); + wxPostEvent( this, evt ); + return true; + } + + return false; +} + + +/** + * Function OnHotkeyRotateItem + * Rotate the item (text or footprint) found under the mouse cursor + * Note: + * this command can be used with an item currently in edit + * Only some items can be rotated (footprints and texts) + * @param aIdCommand = the hotkey command id + * @return true if an item was moved + */ +bool WinEDA_PcbFrame::OnHotkeyRotateItem( int aIdCommand ) +{ + BOARD_ITEM* item = GetCurItem(); + bool itemCurrentlyEdited = item && item->m_Flags; + int evt_type = 0; // Used to post a wxCommandEvent on demand + + if( !itemCurrentlyEdited ) + item = PcbGeneralLocateAndDisplay(); + + if( item == NULL ) + return false; + + SetCurItem( item ); + + switch( item->Type() ) + { + case TYPE_MODULE: + { + if( aIdCommand == HK_ROTATE_ITEM ) // Rotation + evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE; + if( aIdCommand == HK_FLIP_FOOTPRINT ) // move to other side + evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE; + } + break; + + case TYPE_TEXTE: + if( aIdCommand == HK_ROTATE_ITEM ) // Rotation + evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB; + break; + + case TYPE_TEXTE_MODULE: + if( aIdCommand == HK_ROTATE_ITEM ) // Rotation + evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE; + break; + + default: + break; + } + + if( evt_type != 0 ) + { + wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); + evt.SetEventObject( this ); + evt.SetId( evt_type ); + wxPostEvent( this, evt ); + return true; + } + + return false; +} diff --git a/pcbnew/hotkeys_module_editor.cpp b/pcbnew/hotkeys_module_editor.cpp new file mode 100644 index 0000000000..e78179221d --- /dev/null +++ b/pcbnew/hotkeys_module_editor.cpp @@ -0,0 +1,308 @@ +/*****************************/ +/* hotkeys_module_editor.cpp */ +/*****************************/ + +#include "fctsys.h" +#include "common.h" +#include "pcbnew.h" +#include "wxPcbStruct.h" +#include "module_editor_frame.h" +#include "pcbnew_id.h" +#include "class_drawpanel.h" +#include "confirm.h" +#include "class_board_design_settings.h" + +#include "hotkeys.h" +#include "protos.h" + +/* How to add a new hotkey: + * See hotkeys.cpp + */ + + +/*****************************************************************************************/ +void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int hotkey, EDA_BaseStruct* DrawStruct ) +/*****************************************************************************************/ + +/* Hot keys. Some commands are relative to the item under the mouse cursor + * Commands are case insensitive + */ +{ + if( hotkey == 0 ) + return; + + BOARD_ITEM* item = GetCurItem(); + bool ItemFree = (item == 0) || (item->m_Flags == 0); + wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); + cmd.SetEventObject( this ); + + /* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */ + if( (hotkey >= 'a') && (hotkey <= 'z') ) + hotkey += 'A' - 'a'; + + Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey, common_Hotkey_List ); + + if( HK_Descr == NULL ) + HK_Descr = GetDescriptorFromHotkey( hotkey, module_edit_Hotkey_List ); + + if( HK_Descr == NULL ) + return; + + switch( HK_Descr->m_Idcommand ) + { + default: + case HK_NOT_FOUND: + return; + break; + + case HK_HELP: // Display Current hotkey list + DisplayHotkeyList( this, g_Module_Editor_Hokeys_Descr ); + break; + + case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ + GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + break; + + case HK_SWITCH_UNITS: + g_UserUnit = (g_UserUnit == INCHES) ? MILLIMETRES : INCHES; + break; + + case HK_ZOOM_IN: + cmd.SetId( ID_POPUP_ZOOM_IN ); + GetEventHandler()->ProcessEvent( cmd ); + break; + + case HK_ZOOM_OUT: + cmd.SetId( ID_POPUP_ZOOM_OUT ); + GetEventHandler()->ProcessEvent( cmd ); + break; + + case HK_ZOOM_REDRAW: + cmd.SetId( ID_ZOOM_REDRAW ); + GetEventHandler()->ProcessEvent( cmd ); + break; + + case HK_ZOOM_CENTER: + cmd.SetId( ID_POPUP_ZOOM_CENTER ); + GetEventHandler()->ProcessEvent( cmd ); + break; + + case HK_UNDO: + case HK_REDO: + if( ItemFree ) + { + wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, + HK_Descr->m_IdMenuEvent ); + wxPostEvent( this, event ); + } + break; + + case HK_ZOOM_AUTO: + cmd.SetId( ID_ZOOM_PAGE ); + GetEventHandler()->ProcessEvent( cmd ); + break; + + case HK_EDIT_ITEM: + OnHotkeyEditItem( HK_EDIT_ITEM ); + break; + + case HK_DELETE: + OnHotkeyDeleteItem( HK_DELETE ); + break; + + case HK_MOVE_ITEM: + OnHotkeyMoveItem( HK_MOVE_ITEM ); + break; + + case HK_ROTATE_ITEM: + OnHotkeyRotateItem( HK_ROTATE_ITEM ); + break; + } +} + +bool WinEDA_ModuleEditFrame::OnHotkeyEditItem( int aIdCommand ) +{ + BOARD_ITEM* item = GetCurItem(); + bool itemCurrentlyEdited = item && item->m_Flags; + + if( itemCurrentlyEdited ) + return false; + + item = ModeditLocateAndDisplay(); + + if( item == NULL ) + return false; + + SetCurItem( item ); + + int evt_type = 0; //Used to post a wxCommandEvent on demand + + switch( item->Type() ) + { + case TYPE_MODULE: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_MODULE; + break; + + case TYPE_PAD: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_PAD; + break; + + case TYPE_TEXTE_MODULE: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_TEXTMODULE; + break; + + default: + break; + } + + if( evt_type != 0 ) + { + wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); + evt.SetEventObject( this ); + evt.SetId( evt_type ); + wxPostEvent( this, evt ); + return true; + } + + return false; +} + +bool WinEDA_ModuleEditFrame::OnHotkeyDeleteItem( int aIdCommand ) +{ + BOARD_ITEM* item = GetCurItem(); + bool itemCurrentlyEdited = item && item->m_Flags; + + if( itemCurrentlyEdited ) + return false; + + item = ModeditLocateAndDisplay(); + + if( item == NULL ) + return false; + + SetCurItem( item ); + + int evt_type = 0; //Used to post a wxCommandEvent on demand + + switch( item->Type() ) + { + case TYPE_PAD: + if( aIdCommand == HK_DELETE ) + evt_type = ID_POPUP_PCB_DELETE_PAD; + break; + + case TYPE_TEXTE_MODULE: + if( aIdCommand == HK_DELETE ) + evt_type = ID_POPUP_PCB_DELETE_TEXTMODULE; + break; + + case TYPE_EDGE_MODULE: + if( aIdCommand == HK_DELETE ) + evt_type = ID_POPUP_PCB_DELETE_EDGE; + break; + + default: + break; + } + + if( evt_type != 0 ) + { + wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); + evt.SetEventObject( this ); + evt.SetId( evt_type ); + wxPostEvent( this, evt ); + return true; + } + + return false; +} + +bool WinEDA_ModuleEditFrame::OnHotkeyMoveItem( int aIdCommand ) +{ + BOARD_ITEM* item = GetCurItem(); + bool itemCurrentlyEdited = item && item->m_Flags; + + if( itemCurrentlyEdited ) + return false; + + item = ModeditLocateAndDisplay(); + + if( item == NULL ) + return false; + + SetCurItem( item ); + + int evt_type = 0; //Used to post a wxCommandEvent on demand + + switch( item->Type() ) + { + case TYPE_PAD: + if( aIdCommand == HK_MOVE_ITEM ) + evt_type = ID_POPUP_PCB_MOVE_PAD_REQUEST; + break; + + case TYPE_TEXTE_MODULE: + if( aIdCommand == HK_MOVE_ITEM ) + evt_type = ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST; + break; + + case TYPE_EDGE_MODULE: + if( aIdCommand == HK_MOVE_ITEM ) + evt_type = ID_POPUP_PCB_MOVE_EDGE; + break; + + default: + break; + } + + if( evt_type != 0 ) + { + wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); + evt.SetEventObject( this ); + evt.SetId( evt_type ); + wxPostEvent( this, evt ); + return true; + } + + return false; +} + +bool WinEDA_ModuleEditFrame::OnHotkeyRotateItem( int aIdCommand ) +{ + BOARD_ITEM* item = GetCurItem(); + bool itemCurrentlyEdited = item && item->m_Flags; + int evt_type = 0; // Used to post a wxCommandEvent on demand + + if( !itemCurrentlyEdited ) + item = ModeditLocateAndDisplay(); + + if( item == NULL ) + return false; + + SetCurItem( item ); + + switch( item->Type() ) + { + case TYPE_TEXTE_MODULE: + if( aIdCommand == HK_ROTATE_ITEM ) // Rotation + evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE; + break; + + default: + break; + } + + if( evt_type != 0 ) + { + wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); + evt.SetEventObject( this ); + evt.SetId( evt_type ); + wxPostEvent( this, evt ); + return true; + } + + return false; +} diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index b8670f287a..427872eafd 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -240,14 +240,14 @@ void WinEDA_PcbFrame::ReCreateMenuBar() wxMenu* editMenu = new wxMenu; // Undo - text = AddHotkeyName( _( "Undo" ), s_Pcbnew_Editor_Hokeys_Descr, HK_UNDO ); + text = AddHotkeyName( _( "Undo" ), g_Pcbnew_Editor_Hokeys_Descr, HK_UNDO ); item = new wxMenuItem( editMenu, wxID_UNDO, text, HELP_UNDO, wxITEM_NORMAL ); item->SetBitmap( undo_xpm ); editMenu->Append( item ); // Redo - text = AddHotkeyName( _( "Redo" ), s_Pcbnew_Editor_Hokeys_Descr, HK_REDO ); + text = AddHotkeyName( _( "Redo" ), g_Pcbnew_Editor_Hokeys_Descr, HK_REDO ); item = new wxMenuItem( editMenu, wxID_REDO, text, HELP_REDO, wxITEM_NORMAL ); item->SetBitmap( redo_xpm ); @@ -262,7 +262,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() editMenu->AppendSeparator(); // Find - text = AddHotkeyName( _( "&Find" ), s_Pcbnew_Editor_Hokeys_Descr, HK_FIND_ITEM ); + text = AddHotkeyName( _( "&Find" ), g_Pcbnew_Editor_Hokeys_Descr, HK_FIND_ITEM ); item = new wxMenuItem( editMenu, ID_FIND_ITEMS, text, HELP_FIND ); item->SetBitmap( find_xpm ); @@ -306,7 +306,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() * for Zoom in and Zoom out sub menus */ // Zoom In - text = AddHotkeyName( _( "Zoom In" ), s_Pcbnew_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "Zoom In" ), g_Pcbnew_Editor_Hokeys_Descr, HK_ZOOM_IN, false ); item = new wxMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, wxITEM_NORMAL ); @@ -314,7 +314,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() viewMenu->Append( item ); // Zoom Out - text = AddHotkeyName( _( "Zoom Out" ), s_Pcbnew_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "Zoom Out" ), g_Pcbnew_Editor_Hokeys_Descr, HK_ZOOM_OUT, false ); item = new wxMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, wxITEM_NORMAL ); @@ -323,7 +323,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() viewMenu->Append( item ); // Fit on Screen - text = AddHotkeyName( _( "Fit on Screen" ), s_Pcbnew_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "Fit on Screen" ), g_Pcbnew_Editor_Hokeys_Descr, HK_ZOOM_AUTO ); item = new wxMenuItem( viewMenu, ID_ZOOM_PAGE, text, @@ -334,7 +334,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() viewMenu->AppendSeparator(); // Redraw - text = AddHotkeyName( _( "Redraw" ), s_Pcbnew_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "Redraw" ), g_Pcbnew_Editor_Hokeys_Descr, HK_ZOOM_REDRAW ); item = new wxMenuItem( viewMenu, ID_ZOOM_REDRAW, text, @@ -364,7 +364,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() wxMenu* placeMenu = new wxMenu; // Module - text = AddHotkeyName( _( "Module" ), s_Pcbnew_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "Module" ), g_Pcbnew_Editor_Hokeys_Descr, HK_ADD_MODULE, false ); item = new wxMenuItem( placeMenu, ID_COMPONENT_BUTT, text, _( "Add modules" ), wxITEM_NORMAL ); @@ -373,7 +373,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() placeMenu->Append( item ); // Track - text = AddHotkeyName( _( "Track" ), s_Pcbnew_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "Track" ), g_Pcbnew_Editor_Hokeys_Descr, HK_ADD_NEW_TRACK, false ); item = new wxMenuItem( placeMenu, ID_TRACK_BUTT, text, _( "Add tracks and vias" ), wxITEM_NORMAL ); diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index fdfd1ded3b..f086e41e54 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -265,7 +265,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, _( "Rotate" ), rotate_module_pos_xpm ); ADD_MENUITEM( transform_choice, ID_MODEDIT_MODULE_MIRROR, _( "Mirror" ), mirror_H_xpm ); - msg = AddHotkeyName( _( "Edit Module" ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _( "Edit Module" ), g_Module_Editor_Hokeys_Descr, HK_EDIT_ITEM ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_MODULE, msg, edit_module_xpm ); @@ -278,12 +278,12 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, case TYPE_PAD: if( !flags ) { - msg = AddHotkeyName( _("Move Pad" ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _("Move Pad" ), g_Module_Editor_Hokeys_Descr, HK_MOVE_ITEM ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_PAD_REQUEST, msg, move_pad_xpm ); } - msg = AddHotkeyName( _("Edit Pad" ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _("Edit Pad" ), g_Module_Editor_Hokeys_Descr, HK_EDIT_ITEM ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_PAD, msg, options_pad_xpm ); @@ -291,7 +291,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, _( "New Pad Settings" ), options_new_pad_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EXPORT_PAD_SETTINGS, _( "Export Pad Settings" ), export_options_pad_xpm ); - msg = AddHotkeyName( _("Delete Pad" ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _("Delete Pad" ), g_Module_Editor_Hokeys_Descr, HK_DELETE ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_PAD, msg, delete_pad_xpm ); @@ -306,24 +306,24 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, case TYPE_TEXTE_MODULE: if( !flags ) { - msg = AddHotkeyName( _("Move Text Mod." ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _("Move Text Mod." ), g_Module_Editor_Hokeys_Descr, HK_MOVE_ITEM ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, msg, move_field_xpm ); } - msg = AddHotkeyName( _("Rotate Text Mod." ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _("Rotate Text Mod." ), g_Module_Editor_Hokeys_Descr, HK_ROTATE_ITEM ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_ROTATE_TEXTMODULE, msg, rotate_field_xpm ); if( !flags ) { - msg = AddHotkeyName( _("Edit Text Mod." ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _("Edit Text Mod." ), g_Module_Editor_Hokeys_Descr, HK_EDIT_ITEM ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_TEXTMODULE, msg, edit_text_xpm ); if( ( (TEXTE_MODULE*) DrawStruct )->m_Type == TEXT_is_DIVERS ) { - msg = AddHotkeyName( _("Delete Text Mod." ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _("Delete Text Mod." ), g_Module_Editor_Hokeys_Descr, HK_DELETE ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_TEXTMODULE, msg, delete_text_xpm ); @@ -338,7 +338,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, _( "End edge" ), apply_xpm ); if( !flags ) { - msg = AddHotkeyName( _("Move edge" ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _("Move edge" ), g_Module_Editor_Hokeys_Descr, HK_MOVE_ITEM ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_EDGE, msg, move_line_xpm ); @@ -358,7 +358,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, _( "Edit Layer (Current)" ), select_layer_pair_xpm ); ADD_MENUITEM( edit_mnu, ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE, _( "Edit Layer (All)" ), select_layer_pair_xpm ); - msg = AddHotkeyName( _("Delete edge" ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _("Delete edge" ), g_Module_Editor_Hokeys_Descr, HK_DELETE ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_EDGE, msg, delete_xpm ); diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 89e63d07c3..dc545fc6a8 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -160,7 +160,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, m_Draw_Sheet_Ref = false; // true to show the frame references m_Draw_Axis = true; // true to show X and Y axis on screen m_Draw_Grid_Axis = true; // show the grid origin axis - m_HotkeysZoomAndGridList = s_Module_Editor_Hokeys_Descr; + m_HotkeysZoomAndGridList = g_Module_Editor_Hokeys_Descr; // Give an icon SetIcon( wxICON( icon_modedit ) ); diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 419fcde828..135fa51a6d 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -127,7 +127,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) if( !( (MODULE*) item )->IsLocked() ) { msg = AddHotkeyName( _( - "Lock Module" ), s_Board_Editor_Hokeys_Descr, + "Lock Module" ), g_Board_Editor_Hokeys_Descr, HK_LOCK_UNLOCK_FOOTPRINT ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE, msg, locked_xpm ); @@ -135,7 +135,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) else { msg = AddHotkeyName( _( - "Unlock Module" ), s_Board_Editor_Hokeys_Descr, + "Unlock Module" ), g_Board_Editor_Hokeys_Descr, HK_LOCK_UNLOCK_FOOTPRINT ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_AUTOPLACE_FREE_MODULE, msg, unlocked_xpm ); @@ -169,7 +169,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) } if( !flags ) { - msg = AddHotkeyName( _( "Move Drawing" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); + msg = AddHotkeyName( _( "Move Drawing" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST, msg, move_xpm ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_DRAWING, _( "Edit Drawing" ), edit_xpm ); @@ -215,7 +215,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) case TYPE_DIMENSION: if( !flags ) { - msg = AddHotkeyName( _( "Edit Dimension" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); + msg = AddHotkeyName( _( "Edit Dimension" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_DIMENSION, msg, edit_xpm ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DIMENSION, @@ -226,9 +226,9 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) case TYPE_MIRE: if( !flags ) { - msg = AddHotkeyName( _( "Move Target" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); + msg = AddHotkeyName( _( "Move Target" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST, msg, move_xpm ); - msg = AddHotkeyName( _( "Edit Target" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); + msg = AddHotkeyName( _( "Edit Target" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_MIRE, msg, edit_xpm ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_MIRE, @@ -265,7 +265,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) if( !flags ) { msg = AddHotkeyName( _( "Get and Move Footprint" ), - s_Board_Editor_Hokeys_Descr, HK_GET_AND_MOVE_FOOTPRINT ); + g_Board_Editor_Hokeys_Descr, HK_GET_AND_MOVE_FOOTPRINT ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST, msg, move_module_xpm ); } @@ -421,7 +421,7 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) { if( Track->IsPointOnEnds( cursorPosition, -1 ) != 0 ) { - msg = AddHotkeyName( _( "Move Node" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); + msg = AddHotkeyName( _( "Move Node" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, msg, move_xpm ); } @@ -429,7 +429,7 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) { ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE, _( "Drag Segments, Keep Slope" ), drag_segment_withslope_xpm ); - msg = AddHotkeyName( _( "Drag Segment" ), s_Board_Editor_Hokeys_Descr, HK_DRAG_ITEM ); + msg = AddHotkeyName( _( "Drag Segment" ), g_Board_Editor_Hokeys_Descr, HK_DRAG_ITEM ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DRAG_TRACK_SEGMENT, msg, drag_track_segment_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_BREAK_TRACK, @@ -447,20 +447,20 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) { if( flags & IS_NEW ) { - msg = AddHotkeyName( _( "End Track" ), s_Board_Editor_Hokeys_Descr, HK_END_TRACK ); + msg = AddHotkeyName( _( "End Track" ), g_Board_Editor_Hokeys_Descr, HK_END_TRACK ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_END_TRACK, msg, apply_xpm ); } - msg = AddHotkeyName( _( "Place Via" ), s_Board_Editor_Hokeys_Descr, HK_ADD_VIA ); + msg = AddHotkeyName( _( "Place Via" ), g_Board_Editor_Hokeys_Descr, HK_ADD_VIA ); PopMenu->Append( ID_POPUP_PCB_PLACE_VIA, msg ); - msg = AddHotkeyName( _( "Switch Track Posture" ), s_Board_Editor_Hokeys_Descr, HK_SWITCH_TRACK_POSTURE ); + msg = AddHotkeyName( _( "Switch Track Posture" ), g_Board_Editor_Hokeys_Descr, HK_SWITCH_TRACK_POSTURE ); PopMenu->Append( ID_POPUP_PCB_SWITCH_TRACK_POSTURE, msg ); // See if we can place a Micro Via (4 or more layers, and start from an external layer): if( IsMicroViaAcceptable() ) { msg = AddHotkeyName( _( - "Place Micro Via" ), s_Board_Editor_Hokeys_Descr, + "Place Micro Via" ), g_Board_Editor_Hokeys_Descr, HK_ADD_MICROVIA ); PopMenu->Append( ID_POPUP_PCB_PLACE_MICROVIA, msg ); } @@ -476,7 +476,7 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) } else { - msg = AddHotkeyName( _( "Change Segment Width" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); + msg = AddHotkeyName( _( "Change Segment Width" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_TRACKSEG, msg, width_segment_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_TRACK, @@ -502,13 +502,13 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) msg = AddHotkeyName( Track->Type()==TYPE_VIA ? _( "Delete Via" ) : _( "Delete Segment" ), - s_Board_Editor_Hokeys_Descr, HK_BACK_SPACE ); + g_Board_Editor_Hokeys_Descr, HK_BACK_SPACE ); ADD_MENUITEM( track_mnu, ID_POPUP_PCB_DELETE_TRACKSEG, msg, delete_line_xpm ); if( !flags ) { - msg = AddHotkeyName( _( "Delete Track" ), s_Board_Editor_Hokeys_Descr, HK_DELETE ); + msg = AddHotkeyName( _( "Delete Track" ), g_Board_Editor_Hokeys_Descr, HK_DELETE ); ADD_MENUITEM( track_mnu, ID_POPUP_PCB_DELETE_TRACK, msg, delete_track_xpm ); ADD_MENUITEM( track_mnu, ID_POPUP_PCB_DELETE_TRACKNET, @@ -588,7 +588,7 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu { ADD_MENUITEM( zones_menu, ID_POPUP_PCB_ADD_ZONE_CORNER, _( "Create Corner" ), add_corner_xpm ); - msg = AddHotkeyName( _( "Drag Outline Segment" ), s_Board_Editor_Hokeys_Descr, HK_DRAG_ITEM ); + msg = AddHotkeyName( _( "Drag Outline Segment" ), g_Board_Editor_Hokeys_Descr, HK_DRAG_ITEM ); ADD_MENUITEM( zones_menu, ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT, msg, drag_outline_segment_xpm ); } @@ -610,11 +610,11 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu _( "Remove Filled Areas in Zone" ), fill_zone_xpm ); } - msg = AddHotkeyName( _( "Move Zone" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); + msg = AddHotkeyName( _( "Move Zone" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); ADD_MENUITEM( zones_menu, ID_POPUP_PCB_MOVE_ZONE_OUTLINES, msg, move_xpm ); - msg = AddHotkeyName( _( "Edit Zone Params" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); + msg = AddHotkeyName( _( "Edit Zone Params" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); ADD_MENUITEM( zones_menu, ID_POPUP_PCB_EDIT_ZONE_PARAMS, msg, edit_xpm ); @@ -646,25 +646,25 @@ void WinEDA_PcbFrame::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* men ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_footprint, -1, msg, module_xpm ); if( !flags ) { - msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); + msg = AddHotkeyName( _( "Move" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_MOVE_MODULE_REQUEST, msg, move_module_xpm ); - msg = AddHotkeyName( _( "Drag" ), s_Board_Editor_Hokeys_Descr, HK_DRAG_ITEM ); + msg = AddHotkeyName( _( "Drag" ), g_Board_Editor_Hokeys_Descr, HK_DRAG_ITEM ); ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_DRAG_MODULE_REQUEST, msg, drag_module_xpm ); } - msg = AddHotkeyName( _( "Rotate +" ), s_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM ); + msg = AddHotkeyName( _( "Rotate +" ), g_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM ); ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE, msg, rotate_module_pos_xpm ); ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE, _( "Rotate -" ), rotate_module_neg_xpm ); - msg = AddHotkeyName( _( "Flip" ), s_Board_Editor_Hokeys_Descr, HK_FLIP_FOOTPRINT ); + msg = AddHotkeyName( _( "Flip" ), g_Board_Editor_Hokeys_Descr, HK_FLIP_FOOTPRINT ); ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_CHANGE_SIDE_MODULE, msg, invert_module_xpm ); if( !flags ) { - msg = AddHotkeyName( _( "Edit" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); + msg = AddHotkeyName( _( "Edit" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE, msg, edit_module_xpm ); sub_menu_footprint->AppendSeparator(); @@ -692,17 +692,17 @@ void WinEDA_PcbFrame::createPopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* m if( !flags ) { - msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); + msg = AddHotkeyName( _( "Move" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, msg, move_field_xpm ); } - msg = AddHotkeyName( _( "Rotate" ), s_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM ); + msg = AddHotkeyName( _( "Rotate" ), g_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM ); ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_ROTATE_TEXTMODULE, msg, rotate_field_xpm ); if( !flags ) { - msg = AddHotkeyName( _( "Edit" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); + msg = AddHotkeyName( _( "Edit" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_EDIT_TEXTMODULE, msg, edit_text_xpm ); } @@ -805,14 +805,14 @@ void WinEDA_PcbFrame::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu ) if( !flags ) { - msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); + msg = AddHotkeyName( _( "Move" ), g_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST, msg, move_text_xpm ); } - msg = AddHotkeyName( _( "Rotate" ), s_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM ); + msg = AddHotkeyName( _( "Rotate" ), g_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM ); ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_ROTATE_TEXTEPCB, msg, rotate_pos_xpm ); - msg = AddHotkeyName( _( "Edit" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); + msg = AddHotkeyName( _( "Edit" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_EDIT_TEXTEPCB, msg, edit_text_xpm ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index f835ea9f7b..5e719031a8 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -270,7 +270,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, m_TrackAndViasSizesList_Changed = false; m_show_microwave_tools = false; m_show_layer_manager_tools = true; - m_HotkeysZoomAndGridList = s_Board_Editor_Hokeys_Descr; + m_HotkeysZoomAndGridList = g_Board_Editor_Hokeys_Descr; SetBoard( new BOARD( NULL, this ) ); diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 262c02ac96..f5d2c5ff36 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -137,7 +137,7 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); /* Must be called before creating the main frame in order to * display the real hotkeys in menus or tool tips */ - ReadHotkeyConfig( wxT("PcbFrame"), s_Board_Editor_Hokeys_Descr ); + ReadHotkeyConfig( wxT("PcbFrame"), g_Board_Editor_Hokeys_Descr ); frame = new WinEDA_PcbFrame( NULL, wxT( "PcbNew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() ); diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index dd79c5b427..289711beac 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -109,20 +109,20 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event ) /* Hotkey IDs */ case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: - ExportHotkeyConfigToFile( s_Board_Editor_Hokeys_Descr ); + ExportHotkeyConfigToFile( g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG: - ImportHotkeyConfigFromFile( s_Board_Editor_Hokeys_Descr ); + ImportHotkeyConfigFromFile( g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_EDITOR: - InstallHotkeyFrame( this, s_Board_Editor_Hokeys_Descr ); + InstallHotkeyFrame( this, g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display current hotkey list for eeschema. - DisplayHotkeyList( this, s_Board_Editor_Hokeys_Descr ); + DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr ); break; default: diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index c2987f5a1f..e459cccc08 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -99,22 +99,22 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar() _( "Print Module" ) ); m_HToolBar->AddSeparator(); - msg = AddHotkeyName( _( "Zoom in" ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _( "Zoom in" ), g_Module_Editor_Hokeys_Descr, HK_ZOOM_IN, false ); m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, wxBitmap( zoom_in_xpm ), msg ); - msg = AddHotkeyName( _( "Zoom out" ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _( "Zoom out" ), g_Module_Editor_Hokeys_Descr, HK_ZOOM_OUT, false ); m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, wxBitmap( zoom_out_xpm ), msg ); - msg = AddHotkeyName( _( "Redraw view" ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _( "Redraw view" ), g_Module_Editor_Hokeys_Descr, HK_ZOOM_REDRAW, false ); m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, wxBitmap( zoom_redraw_xpm ), msg ); - msg = AddHotkeyName( _( "Zoom auto" ), s_Module_Editor_Hokeys_Descr, + msg = AddHotkeyName( _( "Zoom auto" ), g_Module_Editor_Hokeys_Descr, HK_ZOOM_AUTO, false ); m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, wxBitmap( zoom_auto_xpm ), msg ); diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index 423c0f89b6..61704ae5e8 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -216,11 +216,11 @@ void WinEDA_PcbFrame::ReCreateHToolbar() #endif m_HToolBar->AddSeparator(); - msg = AddHotkeyName( HELP_UNDO, s_Board_Editor_Hokeys_Descr, + msg = AddHotkeyName( HELP_UNDO, g_Board_Editor_Hokeys_Descr, HK_UNDO, false ); m_HToolBar->AddTool( wxID_UNDO, wxEmptyString, wxBitmap( undo_xpm ), HELP_UNDO ); - msg = AddHotkeyName( HELP_REDO, s_Board_Editor_Hokeys_Descr, + msg = AddHotkeyName( HELP_REDO, g_Board_Editor_Hokeys_Descr, HK_REDO, false ); m_HToolBar->AddTool( wxID_REDO, wxEmptyString, wxBitmap( redo_xpm ), HELP_REDO ); @@ -232,29 +232,29 @@ void WinEDA_PcbFrame::ReCreateHToolbar() _( "Plot (HPGL, PostScript, or GERBER format)" ) ); m_HToolBar->AddSeparator(); - msg = AddHotkeyName( HELP_ZOOM_IN, s_Board_Editor_Hokeys_Descr, + msg = AddHotkeyName( HELP_ZOOM_IN, g_Board_Editor_Hokeys_Descr, HK_ZOOM_IN, false ); m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, wxBitmap( zoom_in_xpm ), msg ); - msg = AddHotkeyName( HELP_ZOOM_OUT, s_Board_Editor_Hokeys_Descr, + msg = AddHotkeyName( HELP_ZOOM_OUT, g_Board_Editor_Hokeys_Descr, HK_ZOOM_OUT, false ); m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, wxBitmap( zoom_out_xpm ), msg ); - msg = AddHotkeyName( HELP_ZOOM_REDRAW, s_Board_Editor_Hokeys_Descr, + msg = AddHotkeyName( HELP_ZOOM_REDRAW, g_Board_Editor_Hokeys_Descr, HK_ZOOM_REDRAW, false ); m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, wxBitmap( zoom_redraw_xpm ), msg ); - msg = AddHotkeyName( HELP_ZOOM_FIT, s_Board_Editor_Hokeys_Descr, + msg = AddHotkeyName( HELP_ZOOM_FIT, g_Board_Editor_Hokeys_Descr, HK_ZOOM_AUTO, false ); m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, wxBitmap( zoom_auto_xpm ), msg ); m_HToolBar->AddSeparator(); msg = AddHotkeyName( HELP_FIND, // Find components and texts - s_Board_Editor_Hokeys_Descr, + g_Board_Editor_Hokeys_Descr, HK_FIND_ITEM, false ); m_HToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, wxBitmap( find_xpm ), msg ); @@ -699,7 +699,7 @@ WinEDALayerChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent if( m_SelLayerBox == NULL ) return NULL; - m_SelLayerBox->m_hotkeys = s_Board_Editor_Hokeys_Descr; + m_SelLayerBox->m_hotkeys = g_Board_Editor_Hokeys_Descr; m_SelLayerBox->Resync(); m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );