24 changed files with 1754 additions and 1568 deletions
-
10include/class_board_item.h
-
52pcbnew/CMakeLists.txt
-
85pcbnew/dialog_gendrill.cpp
-
59pcbnew/dialog_gendrill.h
-
288pcbnew/dialogs/dialog_gendrill.cpp
-
68pcbnew/dialogs/dialog_gendrill.h
-
15pcbnew/dialogs/dialog_gendrill_base.cpp
-
123pcbnew/dialogs/dialog_gendrill_base.fbp
-
13pcbnew/dialogs/dialog_gendrill_base.h
-
469pcbnew/gendrill.cpp
-
26pcbnew/gendrill.h
-
976pcbnew/hotkeys.cpp
-
19pcbnew/hotkeys.h
-
675pcbnew/hotkeys_board_editor.cpp
-
308pcbnew/hotkeys_module_editor.cpp
-
18pcbnew/menubar_pcbframe.cpp
-
20pcbnew/modedit_onclick.cpp
-
2pcbnew/moduleframe.cpp
-
60pcbnew/onrightclick.cpp
-
2pcbnew/pcbframe.cpp
-
2pcbnew/pcbnew.cpp
-
8pcbnew/pcbnew_config.cpp
-
8pcbnew/tool_modedit.cpp
-
16pcbnew/tool_pcb.cpp
@ -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); |
|||
} |
|||
|
@ -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<HOLE_INFO> & aHoleListBuffer, std::vector<DRILL_TOOL> & 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<HOLE_INFO> & aHoleListBuffer, |
|||
std::vector<DRILL_TOOL> & aToolListBuffer ); |
|||
int Gen_Liste_Tools( std::vector<DRILL_TOOL> & buffer, bool print_header ); |
|||
}; |
|||
|
|||
#endif // _DIALOG_GENDRILL_H_ |
@ -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]; |
|||
} |
@ -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<HOLE_INFO>& aHoleListBuffer, |
|||
std::vector<DRILL_TOOL>& 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<HOLE_INFO>& aHoleListBuffer, |
|||
std::vector<DRILL_TOOL>& aToolListBuffer ); |
|||
int Gen_Liste_Tools( std::vector<DRILL_TOOL>& buffer, bool print_header ); |
|||
/** |
|||
* Return the selected format for coordinates, if not decimal |
|||
*/ |
|||
DRILL_PRECISION GetPrecison(); |
|||
}; |
|||
|
|||
#endif // _DIALOG_GENDRILL_H_ |
976
pcbnew/hotkeys.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -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; |
|||
} |
@ -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; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue