Commit 8f6d69e5 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Pcbnew: fix 45 degree rotation angle undo and global variable elimination.

parents 2d9385b4 efd99637
...@@ -55,9 +55,6 @@ LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = { ...@@ -55,9 +55,6 @@ LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = {
DISPLAY_OPTIONS DisplayOpt; // Display options for board items DISPLAY_OPTIONS DisplayOpt; // Display options for board items
// This will be always be 450 or 900 (by UI design) at the moment
int g_RotationAngle;
int g_AnchorColor = BLUE; int g_AnchorColor = BLUE;
int g_ModuleTextCMPColor = LIGHTGRAY; int g_ModuleTextCMPColor = LIGHTGRAY;
int g_ModuleTextCUColor = MAGENTA; int g_ModuleTextCUColor = MAGENTA;
......
...@@ -25,8 +25,6 @@ extern DISPLAY_OPTIONS DisplayOpt; ...@@ -25,8 +25,6 @@ extern DISPLAY_OPTIONS DisplayOpt;
extern int g_CurrentVersionPCB; extern int g_CurrentVersionPCB;
extern int g_RotationAngle;
/// List of segments of the trace currently being drawn. /// List of segments of the trace currently being drawn.
extern DLIST<TRACK> g_CurrentTrackList; extern DLIST<TRACK> g_CurrentTrackList;
......
...@@ -87,6 +87,9 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME ...@@ -87,6 +87,9 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME
/// The global footprint library table. /// The global footprint library table.
FP_LIB_TABLE* m_globalFootprintTable; FP_LIB_TABLE* m_globalFootprintTable;
/// User defined rotation angle (in tenths of a degree).
int m_rotationAngle;
/** /**
* Function loadFootprints * Function loadFootprints
* loads the footprints for each #COMPONENT in \a aNetlist from the list of libraries. * loads the footprints for each #COMPONENT in \a aNetlist from the list of libraries.
...@@ -330,6 +333,9 @@ public: ...@@ -330,6 +333,9 @@ public:
*/ */
virtual void SetGridColor(EDA_COLOR_T aColor); virtual void SetGridColor(EDA_COLOR_T aColor);
int GetRotationAngle() const { return m_rotationAngle; }
void SetRotationAngle( int aRotationAngle );
// Configurations: // Configurations:
void InstallConfigFrame(); void InstallConfigFrame();
void Process_Config( wxCommandEvent& event ); void Process_Config( wxCommandEvent& event );
......
...@@ -504,11 +504,13 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed ...@@ -504,11 +504,13 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
break; break;
case UR_ROTATED: case UR_ROTATED:
item->Rotate( aList->m_TransformPoint, aRedoCommand ? 900 : -900 ); item->Rotate( aList->m_TransformPoint,
aRedoCommand ? m_rotationAngle : -m_rotationAngle );
break; break;
case UR_ROTATED_CLOCKWISE: case UR_ROTATED_CLOCKWISE:
item->Rotate( aList->m_TransformPoint, aRedoCommand ? -900 : 900 ); item->Rotate( aList->m_TransformPoint,
aRedoCommand ? -m_rotationAngle : m_rotationAngle );
break; break;
case UR_FLIPPED: case UR_FLIPPED:
......
...@@ -69,7 +69,7 @@ void DIALOG_GENERALOPTIONS::init() ...@@ -69,7 +69,7 @@ void DIALOG_GENERALOPTIONS::init()
m_CursorShape->SetSelection( GetParent()->GetCursorShape() ? 1 : 0 ); m_CursorShape->SetSelection( GetParent()->GetCursorShape() ? 1 : 0 );
switch( g_RotationAngle ) switch( GetParent()->GetRotationAngle() )
{ {
case 450: case 450:
m_RotationAngle->SetSelection( 0 ); m_RotationAngle->SetSelection( 0 );
...@@ -121,8 +121,7 @@ void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event ) ...@@ -121,8 +121,7 @@ void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event )
GetParent()->SetCursorShape( m_CursorShape->GetSelection() ); GetParent()->SetCursorShape( m_CursorShape->GetSelection() );
GetParent()->SetAutoSaveInterval( m_SaveTime->GetValue() * 60 ); GetParent()->SetAutoSaveInterval( m_SaveTime->GetValue() * 60 );
GetParent()->SetRotationAngle( 10 * wxAtoi( m_RotationAngle->GetStringSelection() ) );
g_RotationAngle = 10 * wxAtoi( m_RotationAngle->GetStringSelection() );
/* Updating the combobox to display the active layer. */ /* Updating the combobox to display the active layer. */
g_MaxLinksShowed = m_MaxShowLinks->GetValue(); g_MaxLinksShowed = m_MaxShowLinks->GetValue();
......
...@@ -747,7 +747,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -747,7 +747,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( !GetCurItem()->IsMoving() ) if( !GetCurItem()->IsMoving() )
SaveCopyInUndoList( GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->GetPosition() ); SaveCopyInUndoList( GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->GetPosition() );
Rotate_Module( &dc, (MODULE*) GetCurItem(), g_RotationAngle, true ); Rotate_Module( &dc, (MODULE*) GetCurItem(), m_rotationAngle, true );
break; break;
case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
...@@ -776,7 +776,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -776,7 +776,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SaveCopyInUndoList( GetCurItem(), UR_ROTATED_CLOCKWISE, SaveCopyInUndoList( GetCurItem(), UR_ROTATED_CLOCKWISE,
((MODULE*)GetCurItem())->GetPosition() ); ((MODULE*)GetCurItem())->GetPosition() );
Rotate_Module( &dc, (MODULE*) GetCurItem(), -g_RotationAngle, true ); Rotate_Module( &dc, (MODULE*) GetCurItem(), -m_rotationAngle, true );
break; break;
case ID_POPUP_PCB_CHANGE_SIDE_MODULE: case ID_POPUP_PCB_CHANGE_SIDE_MODULE:
......
...@@ -317,6 +317,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, ...@@ -317,6 +317,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
m_footprintLibTable = NULL; m_footprintLibTable = NULL;
m_globalFootprintTable = NULL; m_globalFootprintTable = NULL;
m_rotationAngle = 900;
#ifdef KICAD_SCRIPTING_WXPYTHON #ifdef KICAD_SCRIPTING_WXPYTHON
m_pythonPanel = NULL; m_pythonPanel = NULL;
...@@ -1072,3 +1073,12 @@ void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event ) ...@@ -1072,3 +1073,12 @@ void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event )
DIALOG_PLOT dlg( this ); DIALOG_PLOT dlg( this );
dlg.ShowModal(); dlg.ShowModal();
} }
void PCB_EDIT_FRAME::SetRotationAngle( int aRotationAngle )
{
wxCHECK2_MSG( aRotationAngle > 0 && aRotationAngle < 900, aRotationAngle = 900,
wxT( "Invalid rotation angle, defaulting to 90." ) );
m_rotationAngle = aRotationAngle;
}
...@@ -158,27 +158,27 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) ...@@ -158,27 +158,27 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
break; break;
case ID_CONFIG_READ: case ID_CONFIG_READ:
{ {
fn = GetBoard()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
fn.GetFullName(), ProjectFileWildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
if( dlg.ShowModal() == wxID_CANCEL ) wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
break; fn.GetFullName(), ProjectFileWildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
if( !wxFileExists( dlg.GetPath() ) ) if( dlg.ShowModal() == wxID_CANCEL )
{ break;
wxString msg;
msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) );
DisplayError( this, msg );
break;
}
LoadProjectSettings( dlg.GetPath() ); if( !wxFileExists( dlg.GetPath() ) )
{
wxString msg;
msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) );
DisplayError( this, msg );
break;
} }
LoadProjectSettings( dlg.GetPath() );
}
break; break;
// Hotkey IDs // Hotkey IDs
...@@ -478,7 +478,7 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() ...@@ -478,7 +478,7 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
WHITE ) ); WHITE ) );
// Miscellaneous: // Miscellaneous:
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), &g_RotationAngle, m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), &m_rotationAngle,
900, 450, 900 ) ); 900, 450, 900 ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ), &g_MaxLinksShowed, m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ), &g_MaxLinksShowed,
3, 0, 15 ) ); 3, 0, 15 ) );
...@@ -486,8 +486,8 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() ...@@ -486,8 +486,8 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
&g_Show_Module_Ratsnest, true ) ); &g_Show_Module_Ratsnest, true ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "TwoSegT" ), m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "TwoSegT" ),
&g_TwoSegmentTrackBuild, true ) ); &g_TwoSegmentTrackBuild, true ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "SegmPcb45Only" ), &g_Segments_45_Only, m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "SegmPcb45Only" )
true ) ); , &g_Segments_45_Only, true ) );
return m_configSettings; return m_configSettings;
} }
......
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