diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 54c163b4ea..93d8aa65e7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,22 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. + +2011-Sept-07, UPDATE Andrey Fedorushkov +================================================================================ +Pcbnew: + Add hotkey "P" - place item + Add Roman Bashkov patch for record/play sequence hotkey macros + Add record and play macros for sequence hotkey. + Macros set to numeric key 0..9: + + - start record macros + ... | + + - end record macros + - play macros + Add menu save/read macros to/from xml-file + Add configure rotate angle for rotate module: 45 or 90 deg. + Fix segfault when move/drag segment if disconnected to pad + 2011-Sept-01, UPDATE Jean-Pierre Charras ================================================================================ Add Fabrizio Tappero in contribuotors list. diff --git a/common/common.cpp b/common/common.cpp index 91bfb8ed0c..fb48935876 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -59,6 +59,7 @@ const wxString NetlistFileExtension( wxT( "net" ) ); const wxString GerberFileExtension( wxT( "pho" ) ); const wxString PcbFileExtension( wxT( "brd" ) ); const wxString PdfFileExtension( wxT( "pdf" ) ); +const wxString MacrosFileExtension( wxT( "mcr" ) ); /* Proper wxFileDialog wild card definitions. */ const wxString ProjectFileWildcard( _( "Kicad project files (*.pro)|*.pro" ) ); @@ -67,6 +68,7 @@ const wxString NetlistFileWildcard( _( "Kicad netlist files (*.net)|*.net" ) ); const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) ); const wxString PcbFileWildcard( _( "Kicad printed circuit board files (*.brd)|*.brd" ) ); const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) ); +const wxString MacrosFileWildcard( _( "Kicad recorded macros (*.mcr)|*.mcr" ) ); const wxString AllFilesWildcard( _( "All files (*)|*" ) ); diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index 927afbf21e..d2a5364e57 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -349,9 +349,12 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, for( ; *List != NULL; List++ ) { Ki_HotkeyInfo* hk_decr = *List; - keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); - msg += wxT( "" ) + hk_decr->m_InfoMsg + wxT(""); - msg += wxT("  ") + keyname + wxT( "" ); + if( !hk_decr->m_InfoMsg.Contains( wxT( "Macros" ) ) ) + { + keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); + msg += wxT( "" ) + hk_decr->m_InfoMsg + wxT(""); + msg += wxT("  ") + keyname + wxT( "" ); + } } } diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index f4df6dd2be..b1237d6054 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -83,6 +83,7 @@ const wxString ModuleFileWildcard( _( "Kicad footprint library files (*.mod)|*.m int g_CurrentVersionPCB = 1; +int g_RotationAngle; int g_TimeOut; // Timer for automatic saving int g_SaveTime; // Time for next saving diff --git a/include/common.h b/include/common.h index 9c66cf3d7c..46e011a98b 100644 --- a/include/common.h +++ b/include/common.h @@ -146,6 +146,7 @@ extern const wxString NetlistFileExtension; extern const wxString GerberFileExtension; extern const wxString PcbFileExtension; extern const wxString PdfFileExtension; +extern const wxString MacrosFileExtension; extern const wxString ProjectFileWildcard; extern const wxString SchematicFileWildcard; @@ -154,6 +155,7 @@ extern const wxString NetlistFileWildcard; extern const wxString GerberFileWildcard; extern const wxString PcbFileWildcard; extern const wxString PdfFileWildcard; +extern const wxString MacrosFileWildcard; extern const wxString AllFilesWildcard; diff --git a/include/id.h b/include/id.h index 52e2b040fb..d089838cc9 100644 --- a/include/id.h +++ b/include/id.h @@ -42,6 +42,10 @@ enum main_id ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, ID_PREFERENCES_HOTKEY_END, + ID_PREFRENCES_MACROS, + ID_PREFRENCES_MACROS_SAVE, + ID_PREFRENCES_MACROS_READ, + ID_GEN_PLOT, ID_GEN_PLOT_PS, ID_GEN_PLOT_HPGL, diff --git a/include/pcbcommon.h b/include/pcbcommon.h index dc484ae558..890ede0adf 100644 --- a/include/pcbcommon.h +++ b/include/pcbcommon.h @@ -35,6 +35,7 @@ extern wxString g_ViaType_Name[4]; extern int g_CurrentVersionPCB; +extern int g_RotationAngle; extern int g_TimeOut; // Timer for automatic saving extern int g_SaveTime; // Time for next saving diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index edf1db001f..560fd8c547 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -10,6 +10,7 @@ #include "base_struct.h" #include "param_config.h" #include "class_layer_box_selector.h" +#include "class_macros_record.h" #include "richio.h" #ifndef PCB_INTERNAL_UNIT @@ -53,6 +54,9 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME void updateTraceWidthSelectBox(); void updateViaSizeSelectBox(); + int m_RecordingMacros; + MACROS_RECORDED m_Macros[10]; + protected: PCB_LAYER_WIDGET* m_Layers; @@ -165,6 +169,22 @@ public: void OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent ); void OnUpdateSelectAutoTrackWidth( wxUpdateUIEvent& aEvent ); + /** + * Function RecordMacros + * record sequence hotkeys and cursor position to macros. + */ + void RecordMacros(wxDC* aDC, int aNumber); + + /** + * Function CallMacros + * play hotkeys and cursor position from recorded macros. + */ + void CallMacros(wxDC* aDC, const wxPoint& aPosition, int aNumber); + + void SaveMacros(); + + void ReadMacros(); + /** * Function PrintPage , virtual * used to print a page @@ -308,6 +328,8 @@ public: */ bool OnHotkeyDeleteItem( wxDC* aDC ); + bool OnHotkeyPlaceItem( wxDC* aDC ); + bool OnHotkeyEditItem( int aIdCommand ); /** diff --git a/pcbnew/dialogs/dialog_general_options.cpp b/pcbnew/dialogs/dialog_general_options.cpp index 5c8c8efe78..3ede8c6b7d 100644 --- a/pcbnew/dialogs/dialog_general_options.cpp +++ b/pcbnew/dialogs/dialog_general_options.cpp @@ -41,6 +41,16 @@ void Dialog_GeneralOptions::init() m_UnitsSelection->SetSelection( g_UserUnit ? 1 : 0 ); m_CursorShape->SetSelection( m_Parent->m_CursorShape ? 1 : 0 ); + + switch( g_RotationAngle ) + { + case 450: + m_RotationAngle->SetSelection( 0 ); + break; + default: + m_RotationAngle->SetSelection( 1 ); + } + wxString timevalue; timevalue << g_TimeOut / 60; m_SaveTime->SetValue( timevalue ); @@ -82,6 +92,9 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) m_Parent->m_CursorShape = m_CursorShape->GetSelection(); g_TimeOut = 60 * m_SaveTime->GetValue(); + + g_RotationAngle = 10 * wxAtoi( m_RotationAngle->GetStringSelection() ); + /* Updating the combobox to display the active layer. */ g_MaxLinksShowed = m_MaxShowLinks->GetValue(); Drc_On = m_DrcOn->GetValue(); diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp index 6557d6f2b6..3f98b085b0 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 6 2011) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -66,6 +66,16 @@ DialogGeneralOptionsBoardEditor_base::DialogGeneralOptionsBoardEditor_base( wxWi bMiddleLeftSizer->Add( m_SaveTime, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + m_staticTextRotationAngle = new wxStaticText( this, wxID_ANY, _("Rotation Angle"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextRotationAngle->Wrap( -1 ); + bMiddleLeftSizer->Add( m_staticTextRotationAngle, 0, wxALL, 5 ); + + wxString m_RotationAngleChoices[] = { _("45"), _("90") }; + int m_RotationAngleNChoices = sizeof( m_RotationAngleChoices ) / sizeof( wxString ); + m_RotationAngle = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_RotationAngleNChoices, m_RotationAngleChoices, 0 ); + m_RotationAngle->SetSelection( 0 ); + bMiddleLeftSizer->Add( m_RotationAngle, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bMainSizer->Add( bMiddleLeftSizer, 1, wxEXPAND, 5 ); wxStaticBoxSizer* bMiddleRightBoxSizer; @@ -73,49 +83,41 @@ DialogGeneralOptionsBoardEditor_base::DialogGeneralOptionsBoardEditor_base( wxWi m_DrcOn = new wxCheckBox( this, wxID_DRC_ONOFF, _("Drc ON"), wxDefaultPosition, wxDefaultSize, 0 ); m_DrcOn->SetValue(true); - m_DrcOn->SetToolTip( _("Enable/disable the DRC control.\nWhen DRC is disable, all connections are allowed.") ); bMiddleRightBoxSizer->Add( m_DrcOn, 0, wxALL|wxEXPAND, 5 ); m_ShowGlobalRatsnest = new wxCheckBox( this, wxID_GENERAL_RATSNEST, _("Show Ratsnest"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ShowGlobalRatsnest->SetToolTip( _("Show (or not) the full rastnest.") ); bMiddleRightBoxSizer->Add( m_ShowGlobalRatsnest, 0, wxALL, 5 ); m_ShowModuleRatsnest = new wxCheckBox( this, wxID_RATSNEST_MODULE, _("Show Mod Ratsnest"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ShowModuleRatsnest->SetToolTip( _("Shows (or not) the local ratsnest relative to a footprint, when moving it.\nThis ratsnest is useful to place a footprint.") ); bMiddleRightBoxSizer->Add( m_ShowModuleRatsnest, 0, wxALL, 5 ); m_TrackAutodel = new wxCheckBox( this, wxID_TRACK_AUTODEL, _("Tracks Auto Del"), wxDefaultPosition, wxDefaultSize, 0 ); - m_TrackAutodel->SetToolTip( _("Enable/disable the automatic track deletion when recreating a track.") ); bMiddleRightBoxSizer->Add( m_TrackAutodel, 0, wxALL, 5 ); m_Track_45_Only_Ctrl = new wxCheckBox( this, wxID_TRACKS45, _("Track only 45 degrees"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Track_45_Only_Ctrl->SetToolTip( _("If enabled, force tracks directions to H, V or 45 degrees, when creating a track.") ); bMiddleRightBoxSizer->Add( m_Track_45_Only_Ctrl, 0, wxALL, 5 ); m_Segments_45_Only_Ctrl = new wxCheckBox( this, wxID_SEGMENTS45, _("Segments 45 Only"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Segments_45_Only_Ctrl->SetToolTip( _("If enabled, force segments directions to H, V or 45 degrees, when creating a segment on technical layers.") ); bMiddleRightBoxSizer->Add( m_Segments_45_Only_Ctrl, 0, wxALL, 5 ); m_AutoPANOpt = new wxCheckBox( this, wxID_AUTOPAN, _("Auto PAN"), wxDefaultPosition, wxDefaultSize, 0 ); - m_AutoPANOpt->SetToolTip( _("Allows auto pan when creating a track, or moving an item.") ); bMiddleRightBoxSizer->Add( m_AutoPANOpt, 0, wxALL, 5 ); m_Track_DoubleSegm_Ctrl = new wxCheckBox( this, wxID_ANY, _("Double Segm Track"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Track_DoubleSegm_Ctrl->SetToolTip( _("If enabled, uses two track segments, with 45 degrees angle between them when creating a new track ") ); bMiddleRightBoxSizer->Add( m_Track_DoubleSegm_Ctrl, 0, wxALL, 5 ); @@ -163,4 +165,5 @@ DialogGeneralOptionsBoardEditor_base::~DialogGeneralOptionsBoardEditor_base() // Disconnect Events m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGeneralOptionsBoardEditor_base::OnOkClick ), NULL, this ); m_buttonCANCEL->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGeneralOptionsBoardEditor_base::OnCancelClick ), NULL, this ); + } diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp index 074fdb0faa..691d141b9b 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp @@ -1,1130 +1,1346 @@ - - - - - - C++ - 1 - UTF-8 - connect - dialog_general_options_BoardEditor_base - 1000 - none - 1 - DialogGeneralOptionsBoardEditor_base - - . - - 1 - 1 - 0 - - - - - 1 - - - - 0 - wxID_ANY - - - DialogGeneralOptionsBoardEditor_base - - 585,280 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - - General settings - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bMainSizer - wxHORIZONTAL - none - - 5 - wxEXPAND - 1 - - - bLeftSizer - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - - "No Display" "Display" - - 1 - - - 0 - wxID_POLAR_CTRL - Display Polar Coord - 1 - - - m_PolarDisplay - protected - - 1 - - wxRA_SPECIFY_COLS - - Activates the display of relative coordinates from relative origin (set by the space key) to the cursor, in polar coordinates (angle and distance) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Inches" "Millimeters" - - 1 - - - 0 - wxID_UNITS - Units - 1 - - - m_UnitsSelection - protected - - 1 - - wxRA_SPECIFY_COLS - - Selection of units used to display dimensions and positions of items - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Small cross" "Full screen cursor" - - 1 - - - 0 - wxID_CURSOR_SHAPE - Cursor - 1 - - - m_CursorShape - protected - - 0 - - wxRA_SPECIFY_COLS - - Main cursor shape selection (small cross or large cursor) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - - bMiddleLeftSizer - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - - - 1 - - - 0 - wxID_ANY - Max Links: - - - m_staticTextmaxlinks - protected - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 0 - - - - 1 - - - 0 - wxID_ANY - 1 - 5 - - 1 - - m_MaxShowLinks - protected - - - wxSP_ARROW_KEYS - - Adjust the number of ratsnets shown from cursor to closest pads - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT|wxEXPAND - 0 - - - - 1 - - - 0 - wxID_ANY - Auto Save (minutes): - - - m_staticTextautosave - protected - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 0 - - - - 1 - - - 0 - wxID_ANY - 0 - 60 - - 0 - - m_SaveTime - protected - - - wxSP_ARROW_KEYS - - Delay after the first change to create a backup file of the board on disk. - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - - 1 - - wxID_ANY - Options: - - bMiddleRightBoxSizer - wxVERTICAL - none - - - 5 - wxALL|wxEXPAND - 0 - - - 1 - - 1 - - - 0 - wxID_DRC_ONOFF - Drc ON - - - m_DrcOn - protected - - - - - Enable/disable the DRC control. When DRC is disable, all connections are allowed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_GENERAL_RATSNEST - Show Ratsnest - - - m_ShowGlobalRatsnest - protected - - - - - Show (or not) the full rastnest. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_RATSNEST_MODULE - Show Mod Ratsnest - - - m_ShowModuleRatsnest - protected - - - - - Shows (or not) the local ratsnest relative to a footprint, when moving it. This ratsnest is useful to place a footprint. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_TRACK_AUTODEL - Tracks Auto Del - - - m_TrackAutodel - protected - - - - - Enable/disable the automatic track deletion when recreating a track. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_TRACKS45 - Track only 45 degrees - - - m_Track_45_Only_Ctrl - protected - - - - - If enabled, force tracks directions to H, V or 45 degrees, when creating a track. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_SEGMENTS45 - Segments 45 Only - - - m_Segments_45_Only_Ctrl - protected - - - - - If enabled, force segments directions to H, V or 45 degrees, when creating a segment on technical layers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_AUTOPAN - Auto PAN - - - m_AutoPANOpt - protected - - - - - Allows auto pan when creating a track, or moving an item. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Double Segm Track - - - m_Track_DoubleSegm_Ctrl - protected - - - - - If enabled, uses two track segments, with 45 degrees angle between them when creating a new track - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - - bRightSizer - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - - "Never" "When creating tracks" "Always" - - 1 - - - 0 - wxID_ANY - Magnetic Pads - 1 - - - m_MagneticPadOptCtrl - protected - - 0 - - wxRA_SPECIFY_COLS - - control the capture of the pcb cursor when the mouse cursor enters a pad area - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Never" "When creating tracks" "Always" - - 1 - - - 0 - wxID_MAGNETIC_TRACKS - Magnetic Tracks - 1 - - - m_MagneticTrackOptCtrl - protected - - 0 - - wxRA_SPECIFY_COLS - - Control the capture of the pcb cursor when the mouse cursor enters a track - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxALIGN_CENTER_HORIZONTAL - 0 - - - - 1 - 1 - - - 0 - wxID_OK - OK - - - m_buttonOK - protected - - - - - - - - - OnOkClick - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_HORIZONTAL|wxALL - 0 - - - - 0 - 1 - - - 0 - wxID_CANCEL - Cancel - - - m_buttonCANCEL - protected - - - - - - - - - OnCancelClick - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + C++ + 1 + source_name + 0 + UTF-8 + connect + dialog_general_options_BoardEditor_base + 1000 + none + 1 + DialogGeneralOptionsBoardEditor_base + + . + + 1 + 1 + 1 + 0 + + + + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DialogGeneralOptionsBoardEditor_base + + 585,280 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + + General settings + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bMainSizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bLeftSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + + "No Display" "Display" + + 1 + 1 + + + 0 + wxID_POLAR_CTRL + Display Polar Coord + 1 + + + m_PolarDisplay + protected + + 1 + + wxRA_SPECIFY_COLS + + Activates the display of relative coordinates from relative origin (set by the space key) to the cursor, in polar coordinates (angle and distance) + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Inches" "Millimeters" + + 1 + 1 + + + 0 + wxID_UNITS + Units + 1 + + + m_UnitsSelection + protected + + 1 + + wxRA_SPECIFY_COLS + + Selection of units used to display dimensions and positions of items + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Small cross" "Full screen cursor" + + 1 + 1 + + + 0 + wxID_CURSOR_SHAPE + Cursor + 1 + + + m_CursorShape + protected + + 0 + + wxRA_SPECIFY_COLS + + Main cursor shape selection (small cross or large cursor) + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bMiddleLeftSizer + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Max Links: + + + m_staticTextmaxlinks + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + 1 + 5 + + 1 + + m_MaxShowLinks + protected + + + wxSP_ARROW_KEYS + + Adjust the number of ratsnets shown from cursor to closest pads + + wxFILTER_NONE + wxDefaultValidator + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Auto Save (minutes): + + + m_staticTextautosave + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + 0 + 60 + + 0 + + m_SaveTime + protected + + + wxSP_ARROW_KEYS + + Delay after the first change to create a backup file of the board on disk. + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Rotation Angle + + + m_staticTextRotationAngle + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + 0 + + + "45" "90" + + 1 + 1 + + + 0 + wxID_ANY + + + m_RotationAngle + protected + + 0 + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 1 + + wxID_ANY + Options: + + bMiddleRightBoxSizer + wxVERTICAL + none + + + 5 + wxALL|wxEXPAND + 0 + + + 1 + + 1 + 1 + + + 0 + wxID_DRC_ONOFF + Drc ON + + + m_DrcOn + protected + + + + + Enable/disable the DRC control. When DRC is disable, all connections are allowed. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_GENERAL_RATSNEST + Show Ratsnest + + + m_ShowGlobalRatsnest + protected + + + + + Show (or not) the full rastnest. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_RATSNEST_MODULE + Show Mod Ratsnest + + + m_ShowModuleRatsnest + protected + + + + + Shows (or not) the local ratsnest relative to a footprint, when moving it. This ratsnest is useful to place a footprint. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_TRACK_AUTODEL + Tracks Auto Del + + + m_TrackAutodel + protected + + + + + Enable/disable the automatic track deletion when recreating a track. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_TRACKS45 + Track only 45 degrees + + + m_Track_45_Only_Ctrl + protected + + + + + If enabled, force tracks directions to H, V or 45 degrees, when creating a track. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_SEGMENTS45 + Segments 45 Only + + + m_Segments_45_Only_Ctrl + protected + + + + + If enabled, force segments directions to H, V or 45 degrees, when creating a segment on technical layers. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_AUTOPAN + Auto PAN + + + m_AutoPANOpt + protected + + + + + Allows auto pan when creating a track, or moving an item. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Double Segm Track + + + m_Track_DoubleSegm_Ctrl + protected + + + + + If enabled, uses two track segments, with 45 degrees angle between them when creating a new track + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bRightSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + + "Never" "When creating tracks" "Always" + + 1 + 1 + + + 0 + wxID_ANY + Magnetic Pads + 1 + + + m_MagneticPadOptCtrl + protected + + 0 + + wxRA_SPECIFY_COLS + + control the capture of the pcb cursor when the mouse cursor enters a pad area + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Never" "When creating tracks" "Always" + + 1 + 1 + + + 0 + wxID_MAGNETIC_TRACKS + Magnetic Tracks + 1 + + + m_MagneticTrackOptCtrl + protected + + 0 + + wxRA_SPECIFY_COLS + + Control the capture of the pcb cursor when the mouse cursor enters a track + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + + + 1 + 1 + 1 + + + 0 + wxID_OK + OK + + + m_buttonOK + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnOkClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_HORIZONTAL|wxALL + 0 + + + + 1 + 0 + 1 + + + 0 + wxID_CANCEL + Cancel + + + m_buttonCANCEL + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCancelClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h index f1988c92cf..63318b28c0 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 6 2011) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,8 @@ class DialogGeneralOptionsBoardEditor_base : public wxDialog wxSpinCtrl* m_MaxShowLinks; wxStaticText* m_staticTextautosave; wxSpinCtrl* m_SaveTime; + wxStaticText* m_staticTextRotationAngle; + wxChoice* m_RotationAngle; wxCheckBox* m_DrcOn; wxCheckBox* m_ShowGlobalRatsnest; wxCheckBox* m_ShowModuleRatsnest; @@ -70,11 +73,12 @@ class DialogGeneralOptionsBoardEditor_base : public wxDialog wxButton* m_buttonCANCEL; // Virtual event handlers, overide them in your derived class - virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } + virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } public: + DialogGeneralOptionsBoardEditor_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("General settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 585,280 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DialogGeneralOptionsBoardEditor_base(); diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 257b25d108..54637cc52b 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -658,7 +658,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */ SaveCopyInUndoList(GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->m_Pos); - Rotate_Module( &dc, (MODULE*) GetCurItem(), 900, true ); + Rotate_Module( &dc, (MODULE*) GetCurItem(), g_RotationAngle, true ); break; case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: @@ -685,7 +685,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */ SaveCopyInUndoList(GetCurItem(), UR_ROTATED_CLOCKWISE, ((MODULE*)GetCurItem())->m_Pos); - Rotate_Module( &dc, (MODULE*) GetCurItem(), -900, true ); + Rotate_Module( &dc, (MODULE*) GetCurItem(), -g_RotationAngle, true ); break; case ID_POPUP_PCB_CHANGE_SIDE_MODULE: diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index d5401e15ee..9886725ee2 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -65,6 +65,8 @@ static Ki_HotkeyInfo HkSwitchTrackPosture( wxT( "Switch Track Posture" ), HK_SWITCH_TRACK_POSTURE, '/' ); static Ki_HotkeyInfo HkDragTrackKeepSlope( wxT( "Drag track keep slope" ), HK_DRAG_TRACK_KEEP_SLOPE, 'D' ); +static Ki_HotkeyInfo HkPlaceItem( wxT( "Place Item" ), + HK_PLACE_ITEM, 'P' ); static Ki_HotkeyInfo HkAddMicroVia( wxT( "Add MicroVia" ), HK_ADD_MICROVIA, 'V' + GR_KB_CTRL ); static Ki_HotkeyInfo HkEndTrack( wxT( "End Track" ), HK_END_TRACK, WXK_END ); @@ -136,6 +138,46 @@ static Ki_HotkeyInfo HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U' static Ki_HotkeyInfo HkTrackDisplayMode( wxT( "Track Display Mode" ), HK_SWITCH_TRACK_DISPLAY_MODE, 'K' ); static Ki_HotkeyInfo HkAddModule( wxT( "Add Module" ), HK_ADD_MODULE, 'O' ); +/* Record and play macros */ +static Ki_HotkeyInfo HkRecordMacros0( wxT( "Record Macros 0" ), HK_RECORD_MACROS_0, GR_KB_CTRL+'0' ); + +static Ki_HotkeyInfo HkCallMacros0( wxT( "Call Macross 0" ), HK_CALL_MACROS_0, '0' ); + +static Ki_HotkeyInfo HkRecordMacros1( wxT( "Record Macros 1" ), HK_RECORD_MACROS_1, GR_KB_CTRL+'1' ); + +static Ki_HotkeyInfo HkCallMacros1( wxT( "Call Macross 1" ), HK_CALL_MACROS_1, '1' ); + +static Ki_HotkeyInfo HkRecordMacros2( wxT( "Record Macros 2" ), HK_RECORD_MACROS_2, GR_KB_CTRL+'2' ); + +static Ki_HotkeyInfo HkCallMacros2( wxT( "Call Macross 2" ), HK_CALL_MACROS_2, '2' ); + +static Ki_HotkeyInfo HkRecordMacros3( wxT( "Record Macros 3" ), HK_RECORD_MACROS_3, GR_KB_CTRL+'3' ); + +static Ki_HotkeyInfo HkCallMacros3( wxT( "Call Macross 3" ), HK_CALL_MACROS_3, '3' ); + +static Ki_HotkeyInfo HkRecordMacros4( wxT( "Record Macros 4" ), HK_RECORD_MACROS_4, GR_KB_CTRL+'4' ); + +static Ki_HotkeyInfo HkCallMacros4( wxT( "Call Macross 4" ), HK_CALL_MACROS_4, '4' ); + +static Ki_HotkeyInfo HkRecordMacros5( wxT( "Record Macros 5" ), HK_RECORD_MACROS_5, GR_KB_CTRL+'5' ); + +static Ki_HotkeyInfo HkCallMacros5( wxT( "Call Macross 5" ), HK_CALL_MACROS_5, '5' ); + +static Ki_HotkeyInfo HkRecordMacros6( wxT( "Record Macros 6" ), HK_RECORD_MACROS_6, GR_KB_CTRL+'6' ); + +static Ki_HotkeyInfo HkCallMacros6( wxT( "Call Macross 6" ), HK_CALL_MACROS_6, '6' ); + +static Ki_HotkeyInfo HkRecordMacros7( wxT( "Record Macros 7" ), HK_RECORD_MACROS_7, GR_KB_CTRL+'7' ); + +static Ki_HotkeyInfo HkCallMacros7( wxT( "Call Macross 7" ), HK_CALL_MACROS_7, '7' ); + +static Ki_HotkeyInfo HkRecordMacros8( wxT( "Record Macros 8" ), HK_RECORD_MACROS_8, GR_KB_CTRL+'8' ); + +static Ki_HotkeyInfo HkCallMacros8( wxT( "Call Macross 8" ), HK_CALL_MACROS_8, '8' ); + +static Ki_HotkeyInfo HkRecordMacros9( wxT( "Record Macros 9" ), HK_RECORD_MACROS_9, GR_KB_CTRL+'9' ); + +static Ki_HotkeyInfo HkCallMacros9( wxT( "Call Macross 9" ), HK_CALL_MACROS_9, '9' ); // List of common hotkey descriptors Ki_HotkeyInfo* common_Hotkey_List[] = @@ -155,6 +197,7 @@ Ki_HotkeyInfo* board_edit_Hotkey_List[] = &HkAddNewTrack, &HkAddVia, &HkAddMicroVia, &HkSwitchTrackPosture, &HkDragTrackKeepSlope, + &HkPlaceItem, &HkEndTrack, &HkMoveItem, &HkFlipFootprint, &HkRotateItem, &HkDragFootprint, &HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile, @@ -163,6 +206,16 @@ Ki_HotkeyInfo* board_edit_Hotkey_List[] = &HkSwitch2InnerLayer2, &HkSwitch2InnerLayer3, &HkSwitch2InnerLayer4, &HkSwitch2InnerLayer5, &HkSwitch2InnerLayer6, &HkSwitch2ComponentLayer, &HkSwitch2NextCopperLayer, &HkSwitch2PreviousCopperLayer,&HkAddModule, + &HkRecordMacros0, &HkCallMacros0, + &HkRecordMacros1, &HkCallMacros1, + &HkRecordMacros2, &HkCallMacros2, + &HkRecordMacros3, &HkCallMacros3, + &HkRecordMacros4, &HkCallMacros4, + &HkRecordMacros5, &HkCallMacros5, + &HkRecordMacros6, &HkCallMacros6, + &HkRecordMacros7, &HkCallMacros7, + &HkRecordMacros8, &HkCallMacros8, + &HkRecordMacros9, &HkCallMacros9, NULL }; diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h index ce22cabbdb..1c3178e04c 100644 --- a/pcbnew/hotkeys.h +++ b/pcbnew/hotkeys.h @@ -30,6 +30,7 @@ enum hotkey_id_commnand { HK_SWITCH_TRACK_DISPLAY_MODE, HK_FIND_ITEM, HK_EDIT_ITEM, + HK_PLACE_ITEM, HK_SWITCH_LAYER_TO_COPPER, HK_SWITCH_LAYER_TO_COMPONENT, HK_SWITCH_LAYER_TO_NEXT, @@ -49,7 +50,27 @@ enum hotkey_id_commnand { HK_SWITCH_LAYER_TO_INNER13, HK_SWITCH_LAYER_TO_INNER14, HK_ADD_MODULE, - HK_SLIDE_TRACK + HK_SLIDE_TRACK, + HK_RECORD_MACROS_0, + HK_CALL_MACROS_0, + HK_RECORD_MACROS_1, + HK_CALL_MACROS_1, + HK_RECORD_MACROS_2, + HK_CALL_MACROS_2, + HK_RECORD_MACROS_3, + HK_CALL_MACROS_3, + HK_RECORD_MACROS_4, + HK_CALL_MACROS_4, + HK_RECORD_MACROS_5, + HK_CALL_MACROS_5, + HK_RECORD_MACROS_6, + HK_CALL_MACROS_6, + HK_RECORD_MACROS_7, + HK_CALL_MACROS_7, + HK_RECORD_MACROS_8, + HK_CALL_MACROS_8, + HK_RECORD_MACROS_9, + HK_CALL_MACROS_9 }; // Full list of hotkey descriptors for borad editor and footprint editor diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 3ef11de870..95edfb757c 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -18,6 +18,79 @@ */ +/** + * Function RecordMacros. + * Record sequence hotkeys and cursor position to macros. + * @param aDC = current device context + * @param aNumber The current number macros. + */ +void PCB_EDIT_FRAME::RecordMacros(wxDC* aDC, int aNumber) +{ + assert(aNumber >= 0); + assert(aNumber < 10); + wxString msg, tmp; + + if( m_RecordingMacros < 0 ) + { + m_RecordingMacros = aNumber; + m_Macros[aNumber].m_StartPosition = GetScreen()->GetCrossHairPosition(false); + m_Macros[aNumber].m_Record.clear(); + + msg.Printf( wxT("%s %d"), _( "Recording macros" ), aNumber); + SetStatusText(msg); + } + else + { + m_RecordingMacros = -1; + + msg.Printf( wxT("%s %d %s"), _( "Macros" ), aNumber, _( "recorded" )); + SetStatusText(msg); + } +} + + +/** + * Function CallMacros + * play hotkeys and cursor position from recorded macros. + * @param aDC = current device context + * @param aPosition The current cursor position in logical (drawing) units. + * @param aNumber The current number macros. +*/ +void PCB_EDIT_FRAME::CallMacros(wxDC* aDC, const wxPoint& aPosition, int aNumber) +{ + PCB_SCREEN* screen = GetScreen(); + wxPoint tPosition; + + wxString msg; + + msg.Printf( wxT("%s %d"), _( "Call macros"), aNumber); + SetStatusText( msg ); + + wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); + cmd.SetEventObject( this ); + + tPosition = screen->GetNearestGridPosition( aPosition ); + + DrawPanel->CrossHairOff( aDC ); + screen->SetMousePosition( tPosition ); + GeneralControl( aDC, tPosition ); + + for( std::list::iterator i = m_Macros[aNumber].m_Record.begin(); i != m_Macros[aNumber].m_Record.end(); i++ ) + { + wxPoint tmpPos = tPosition + i->m_Position; + + screen->SetMousePosition( tmpPos ); + + GeneralControl( aDC, tmpPos, i->m_HotkeyCode ); + } + + cmd.SetId( ID_ZOOM_REDRAW ); + GetEventHandler()->ProcessEvent( cmd ); + + DrawPanel->CrossHairOn( aDC ); +} + + /** * Function OnHotKey. * ** Commands are case insensitive ** @@ -53,6 +126,25 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit if( HK_Descr == NULL ) return; + if( (m_RecordingMacros != -1) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_1) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_1) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_2) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_2) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_3) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_3) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_4) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_4) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_5) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_5) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_6) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_6) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_7) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_7) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_8) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_8) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_9) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_9) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_0) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_0) ) + { + MACROS_RECORD macros_record; + macros_record.m_HotkeyCode = aHotkeyCode; + macros_record.m_Idcommand = HK_Descr->m_Idcommand; + macros_record.m_Position = screen->GetNearestGridPosition( aPosition ) - m_Macros[m_RecordingMacros].m_StartPosition; + m_Macros[m_RecordingMacros].m_Record.push_back(macros_record); + } + // Create a wxCommandEvent that will be posted in some hot keys functions wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); @@ -66,6 +158,86 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit return; break; + case HK_RECORD_MACROS_0: + RecordMacros(aDC, 0); + break; + + case HK_RECORD_MACROS_1: + RecordMacros(aDC, 1); + break; + + case HK_RECORD_MACROS_2: + RecordMacros(aDC, 2); + break; + + case HK_RECORD_MACROS_3: + RecordMacros(aDC, 3); + break; + + case HK_RECORD_MACROS_4: + RecordMacros(aDC, 4); + break; + + case HK_RECORD_MACROS_5: + RecordMacros(aDC, 5); + break; + + case HK_RECORD_MACROS_6: + RecordMacros(aDC, 6); + break; + + case HK_RECORD_MACROS_7: + RecordMacros(aDC, 7); + break; + + case HK_RECORD_MACROS_8: + RecordMacros(aDC, 8); + break; + + case HK_RECORD_MACROS_9: + RecordMacros(aDC, 9); + break; + + case HK_CALL_MACROS_0: + CallMacros(aDC, aPosition, 0); + break; + + case HK_CALL_MACROS_1: + CallMacros(aDC, aPosition, 1); + break; + + case HK_CALL_MACROS_2: + CallMacros(aDC, aPosition, 2); + break; + + case HK_CALL_MACROS_3: + CallMacros(aDC, aPosition, 3); + break; + + case HK_CALL_MACROS_4: + CallMacros(aDC, aPosition, 4); + break; + + case HK_CALL_MACROS_5: + CallMacros(aDC, aPosition, 5); + break; + + case HK_CALL_MACROS_6: + CallMacros(aDC, aPosition, 6); + break; + + case HK_CALL_MACROS_7: + CallMacros(aDC, aPosition, 7); + break; + + case HK_CALL_MACROS_8: + CallMacros(aDC, aPosition, 8); + break; + + case HK_CALL_MACROS_9: + CallMacros(aDC, aPosition, 9); + break; + case HK_SWITCH_LAYER_TO_PREVIOUS: ll = getActiveLayer(); if( (ll <= LAYER_N_BACK) || (ll > LAYER_N_FRONT) ) @@ -282,6 +454,10 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit OnHotkeyMoveItem( HK_DRAG_TRACK_KEEP_SLOPE ); break; + case HK_PLACE_ITEM: + OnHotkeyPlaceItem( aDC ); + break; + case HK_ADD_NEW_TRACK: // Start new track if( getActiveLayer() > LAYER_N_FRONT ) break; @@ -361,7 +537,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); evt.SetEventObject( this ); evt.SetId( evt_type ); - wxPostEvent( this, evt ); + GetEventHandler()->ProcessEvent( evt ); } } @@ -521,7 +697,7 @@ bool PCB_EDIT_FRAME::OnHotkeyEditItem( int aIdCommand ) wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); evt.SetEventObject( this ); evt.SetId( evt_type ); - wxPostEvent( this, evt ); + GetEventHandler()->ProcessEvent( evt ); return true; } @@ -621,13 +797,78 @@ bool PCB_EDIT_FRAME::OnHotkeyMoveItem( int aIdCommand ) wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); evt.SetEventObject( this ); evt.SetId( evt_type ); - wxPostEvent( this, evt ); + GetEventHandler()->ProcessEvent( evt ); return true; } return false; } +/** + * Function OnHotkeyPlaceItem + * Place the item (footprint, track, text .. ) found under the mouse cursor + * An item can be placed only if there is this item currently edited + * Only a footprint, a pad or a track can be placed + * @param aDC = current device context + * @return true if an item was placedd + */ +bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC ) +{ + BOARD_ITEM* item = GetCurItem(); + bool no_tool = GetToolId() == ID_NO_TOOL_SELECTED; + bool itemCurrentlyEdited = item && item->m_Flags; + + DrawPanel->m_AutoPAN_Request = false; + + if( itemCurrentlyEdited ) + { + DrawPanel->m_IgnoreMouseEvents = true; + DrawPanel->CrossHairOff( aDC ); + + switch( item->Type() ) + { + case TYPE_TRACK: + case TYPE_VIA: + if( item->m_Flags & IS_DRAGGED ) + PlaceDraggedOrMovedTrackSegment( (TRACK*) item, aDC ); + break; + + case TYPE_TEXTE: + Place_Texte_Pcb( (TEXTE_PCB*) item, aDC ); + break; + + case TYPE_TEXTE_MODULE: + PlaceTexteModule( (TEXTE_MODULE*) item, aDC ); + break; + + case TYPE_PAD: + PlacePad( (D_PAD*) item, aDC ); + break; + + case TYPE_MODULE: + Place_Module( (MODULE*) item, aDC ); + break; + + case TYPE_MIRE: + Place_Mire( (MIREPCB*) item, aDC ); + break; + + case TYPE_DRAWSEGMENT: + if( no_tool ) // when no tools: existing item moving. + Place_DrawItem( (DRAWSEGMENT*) item, aDC ); + break; + + default: + break; + } + + DrawPanel->m_IgnoreMouseEvents = false; + DrawPanel->CrossHairOn( aDC ); + + return true; + } + return false; +} /** * Function OnHotkeyRotateItem @@ -682,7 +923,7 @@ bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand ) wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); evt.SetEventObject( this ); evt.SetId( evt_type ); - wxPostEvent( this, evt ); + GetEventHandler()->ProcessEvent( evt ); return true; } diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index bca4ff3d23..be5ff97e91 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -558,6 +558,27 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() // Hotkey submenu AddHotkeyConfigMenu( configmenu ); + + + // Macros submenu + wxMenu* macrosMenu = new wxMenu; + + item = new wxMenuItem( macrosMenu, ID_PREFRENCES_MACROS_SAVE, + _( "Save macros" ), + _( "Save macros to file" ) ); + macrosMenu->Append( item ); + + item = new wxMenuItem( macrosMenu, ID_PREFRENCES_MACROS_READ, + _( "Read macros" ), + _( "Read macros from file" ) ); + macrosMenu->Append( item ); + + // Append macros menu to config menu + AddMenuItem( configmenu, macrosMenu, + -1, _( "Macros" ), + _( "Macros save/read operations" ), + add_dimension_xpm ); + configmenu->AppendSeparator(); // Save Preferences diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index c0b52665d9..78bb511fef 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -1004,7 +1004,16 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) * tested by test_1_net_connexion() ) */ int masque_layer = g_TabOneLayerMask[Track->GetLayer()]; Track->start = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_Start, masque_layer ); + if( Track->start ) + Track->SetState( BEGIN_ONPAD, ON ); + else + Track->SetState( BEGIN_ONPAD, OFF ); + Track->end = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_End, masque_layer ); + if( Track->end ) + Track->SetState( END_ONPAD, ON ); + else + Track->SetState( END_ONPAD, OFF ); } EraseDragList(); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 4c09d787e2..55898a35a4 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -116,6 +116,8 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_PCB_PAD_SETUP, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_CONFIG_SAVE, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_CONFIG_READ, PCB_EDIT_FRAME::Process_Config ) + EVT_MENU( ID_PREFRENCES_MACROS_SAVE, PCB_EDIT_FRAME::Process_Config ) + EVT_MENU( ID_PREFRENCES_MACROS_READ, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_PCB_DISPLAY_OPTIONS_SETUP, PCB_EDIT_FRAME::InstallDisplayOptionsDialog ) EVT_MENU( ID_PCB_USER_GRID_SETUP, PCB_EDIT_FRAME::Process_Special_Functions ) @@ -274,6 +276,10 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, m_show_layer_manager_tools = true; m_HotkeysZoomAndGridList = g_Board_Editor_Hokeys_Descr; + m_RecordingMacros = -1; + for ( int i = 0; i < 10; i++ ) + m_Macros[i].m_Record.clear(); + SetBoard( new BOARD( NULL, this ) ); // Create the PCB_LAYER_WIDGET *after* SetBoard(): @@ -409,6 +415,10 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, PCB_EDIT_FRAME::~PCB_EDIT_FRAME() { + m_RecordingMacros = -1; + for( int i = 0; i < 10; i++ ) + m_Macros[i].m_Record.clear(); + delete m_drc; } diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 35000da4fd..9b5aad62ee 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -2,6 +2,8 @@ /** pcbnew_config.cpp : configuration **/ /****************************************/ +#include + #include "fctsys.h" #include "appl_wxstruct.h" #include "class_drawpanel.h" @@ -114,6 +116,15 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr ); break; + /* Macros IDs*/ + case ID_PREFRENCES_MACROS_SAVE: + SaveMacros(); + break; + + case ID_PREFRENCES_MACROS_READ: + ReadMacros(); + break; + default: DisplayError( this, wxT( "PCB_EDIT_FRAME::Process_Config error" ) ); } @@ -383,6 +394,8 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() WHITE ) ); // Miscellaneous: + m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), &g_RotationAngle, + 900, 450, 900 ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "TimeOut" ), &g_TimeOut, 600, 0, 60000 ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ), &g_MaxLinksShowed, @@ -395,3 +408,123 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() true ) ); return m_configSettings; } + + +/** + */ +void PCB_EDIT_FRAME::SaveMacros() +{ + wxFileName fn; + wxXmlDocument xml; + wxXmlNode *rootNode = new wxXmlNode::wxXmlNode( NULL, wxXML_ELEMENT_NODE, wxT( "macrosrootnode" ), wxEmptyString, NULL); + wxXmlNode *macrosNode, *hkNode; + wxXmlProperty *macrosProp, *hkProp, *xProp, *yProp; + wxString str, hkStr, xStr, yStr; + + fn = GetScreen()->GetFileName(); + fn.SetExt( MacrosFileExtension ); + + wxFileDialog dlg( this, _( "Save Macros File" ), fn.GetPath(), fn.GetFullName(), + MacrosFileWildcard, wxFD_SAVE | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + xml.SetRoot( rootNode ); + + for( int number = 9; number >= 0; number--) + { + str.Printf( wxT( "%d" ), number); + macrosProp = new wxXmlProperty::wxXmlProperty( wxT("number"), str); + + macrosNode = new wxXmlNode::wxXmlNode(rootNode, wxXML_ELEMENT_NODE, wxT( "macros" ), wxEmptyString, macrosProp); + + for( std::list::reverse_iterator i = m_Macros[number].m_Record.rbegin(); i != m_Macros[number].m_Record.rend(); i++ ) + { + hkStr.Printf( wxT( "%d" ), i->m_HotkeyCode); + xStr.Printf( wxT( "%d" ), i->m_Position.x); + yStr.Printf( wxT( "%d" ), i->m_Position.y); + + yProp = new wxXmlProperty( wxT( "y" ), yStr); + xProp = new wxXmlProperty( wxT( "x" ), xStr, yProp); + hkProp = new wxXmlProperty( wxT( "hkcode" ), hkStr, xProp); + + hkNode = new wxXmlNode(macrosNode, wxXML_ELEMENT_NODE, wxT( "hotkey" ), wxEmptyString, hkProp); + } + } + + xml.SetFileEncoding(wxT("UTF-8")); + xml.Save(dlg.GetFilename()); +} + + +/** + */ +void PCB_EDIT_FRAME::ReadMacros() +{ + wxString str; + wxFileName fn; + + fn = GetScreen()->GetFileName(); + fn.SetExt( MacrosFileExtension ); + + wxFileDialog dlg( this, _( "Read Macros File" ), fn.GetPath(), + fn.GetFullName(), MacrosFileWildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + if( !wxFileExists( dlg.GetPath() ) ) + { + wxString msg; + msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); + DisplayError( this, msg ); + return; + } + + wxXmlDocument xml; + + xml.SetFileEncoding(wxT("UTF-8")); + if( !xml.Load( dlg.GetFilename() ) ) + return; + + wxXmlNode *macrosNode = xml.GetRoot()->GetChildren(); + + while( macrosNode ) + { + int number = -1; + + if( macrosNode->GetName() == wxT( "macros" ) ) + { + number = wxAtoi( macrosNode->GetPropVal( wxT( "number" ), wxT( "-1" ) ) ); + + if( number >= 0 && number < 10 ) + { + m_Macros[number].m_Record.clear(); + + wxXmlNode *hotkeyNode = macrosNode->GetChildren(); + while( hotkeyNode ) + { + if( hotkeyNode->GetName() == wxT( "hotkey" ) ) + { + int x = wxAtoi( hotkeyNode->GetPropVal( wxT( "x" ), wxT( "0" ) ) ); + int y = wxAtoi( hotkeyNode->GetPropVal( wxT( "y" ), wxT( "0" ) ) ); + int hk = wxAtoi( hotkeyNode->GetPropVal( wxT( "hkcode" ), wxT( "0" ) ) ); + + MACROS_RECORD macros_record; + macros_record.m_HotkeyCode = hk; + macros_record.m_Position.x = x; + macros_record.m_Position.y = y; + m_Macros[number].m_Record.push_back(macros_record); + } + + hotkeyNode = hotkeyNode->GetNext(); + } + } + } + + macrosNode = macrosNode->GetNext(); + } + +}