Commit 9f98995a authored by Andrey Fedorushkov's avatar Andrey Fedorushkov

pcbnew:

* Add hotkey "P" - place item
* Add record and play macros for sequence hotkey.
Macros set to numeric key 0..9.
<Ctrl>+<numkey> - start record macros
<hotkey> <mouse move> ... <hotkey>|<mouse place>
<Ctrl>+<numkey> - end record macros
<numkey> - 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
parent 750f84c1
......@@ -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 <andrf@mail.ru>
================================================================================
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:
<Ctrl>+<numkey> - start record macros
<hotkey> <mouse move> ... <hotkey>|<mouse place>
<Ctrl>+<numkey> - end record macros
<numkey> - 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 <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
Add Fabrizio Tappero <fabrizio-dot-tappero[at]gmail-dot-com> in contribuotors list.
......
......@@ -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 (*)|*" ) );
......
......@@ -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( "<tr><td>" ) + hk_decr->m_InfoMsg + wxT("</td>");
msg += wxT("<td><b>&nbsp;&nbsp;") + keyname + wxT( "</b></td></tr>" );
if( !hk_decr->m_InfoMsg.Contains( wxT( "Macros" ) ) )
{
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
msg += wxT( "<tr><td>" ) + hk_decr->m_InfoMsg + wxT("</td>");
msg += wxT("<td><b>&nbsp;&nbsp;") + keyname + wxT( "</b></td></tr>" );
}
}
}
......
......@@ -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
......
......@@ -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;
......
......@@ -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,
......
......@@ -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
......
......@@ -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 );
/**
......
......@@ -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();
......
///////////////////////////////////////////////////////////////////////////
// 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 );
}
This source diff could not be displayed because it is too large. You can view the blob instead.
///////////////////////////////////////////////////////////////////////////
// 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 <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/spinctrl.h>
#include <wx/choice.h>
#include <wx/checkbox.h>
#include <wx/statbox.h>
#include <wx/button.h>
......@@ -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();
......
......@@ -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:
......
......@@ -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
};
......
......@@ -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
......
......@@ -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<MACROS_RECORD>::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;
}
......
......@@ -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
......
......@@ -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();
......
......@@ -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;
}
......
......@@ -2,6 +2,8 @@
/** pcbnew_config.cpp : configuration **/
/****************************************/
#include <wx-2.8/wx/xml/xml.h>
#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<MACROS_RECORD>::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();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment