Pcbnew: fix 45 degree rotation angle undo and global variable elimination.
This commit is contained in:
commit
8f6d69e57e
|
@ -55,9 +55,6 @@ LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = {
|
|||
|
||||
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_ModuleTextCMPColor = LIGHTGRAY;
|
||||
int g_ModuleTextCUColor = MAGENTA;
|
||||
|
|
|
@ -25,8 +25,6 @@ extern DISPLAY_OPTIONS DisplayOpt;
|
|||
|
||||
extern int g_CurrentVersionPCB;
|
||||
|
||||
extern int g_RotationAngle;
|
||||
|
||||
/// List of segments of the trace currently being drawn.
|
||||
extern DLIST<TRACK> g_CurrentTrackList;
|
||||
|
||||
|
|
|
@ -87,6 +87,9 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME
|
|||
/// The global footprint library table.
|
||||
FP_LIB_TABLE* m_globalFootprintTable;
|
||||
|
||||
/// User defined rotation angle (in tenths of a degree).
|
||||
int m_rotationAngle;
|
||||
|
||||
/**
|
||||
* Function loadFootprints
|
||||
* loads the footprints for each #COMPONENT in \a aNetlist from the list of libraries.
|
||||
|
@ -330,6 +333,9 @@ public:
|
|||
*/
|
||||
virtual void SetGridColor(EDA_COLOR_T aColor);
|
||||
|
||||
int GetRotationAngle() const { return m_rotationAngle; }
|
||||
void SetRotationAngle( int aRotationAngle );
|
||||
|
||||
// Configurations:
|
||||
void InstallConfigFrame();
|
||||
void Process_Config( wxCommandEvent& event );
|
||||
|
|
|
@ -504,11 +504,13 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
break;
|
||||
|
||||
case UR_ROTATED:
|
||||
item->Rotate( aList->m_TransformPoint, aRedoCommand ? 900 : -900 );
|
||||
item->Rotate( aList->m_TransformPoint,
|
||||
aRedoCommand ? m_rotationAngle : -m_rotationAngle );
|
||||
break;
|
||||
|
||||
case UR_ROTATED_CLOCKWISE:
|
||||
item->Rotate( aList->m_TransformPoint, aRedoCommand ? -900 : 900 );
|
||||
item->Rotate( aList->m_TransformPoint,
|
||||
aRedoCommand ? -m_rotationAngle : m_rotationAngle );
|
||||
break;
|
||||
|
||||
case UR_FLIPPED:
|
||||
|
|
|
@ -69,7 +69,7 @@ void DIALOG_GENERALOPTIONS::init()
|
|||
m_CursorShape->SetSelection( GetParent()->GetCursorShape() ? 1 : 0 );
|
||||
|
||||
|
||||
switch( g_RotationAngle )
|
||||
switch( GetParent()->GetRotationAngle() )
|
||||
{
|
||||
case 450:
|
||||
m_RotationAngle->SetSelection( 0 );
|
||||
|
@ -121,8 +121,7 @@ void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event )
|
|||
|
||||
GetParent()->SetCursorShape( m_CursorShape->GetSelection() );
|
||||
GetParent()->SetAutoSaveInterval( m_SaveTime->GetValue() * 60 );
|
||||
|
||||
g_RotationAngle = 10 * wxAtoi( m_RotationAngle->GetStringSelection() );
|
||||
GetParent()->SetRotationAngle( 10 * wxAtoi( m_RotationAngle->GetStringSelection() ) );
|
||||
|
||||
/* Updating the combobox to display the active layer. */
|
||||
g_MaxLinksShowed = m_MaxShowLinks->GetValue();
|
||||
|
|
|
@ -747,7 +747,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
if( !GetCurItem()->IsMoving() )
|
||||
SaveCopyInUndoList( GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->GetPosition() );
|
||||
|
||||
Rotate_Module( &dc, (MODULE*) GetCurItem(), g_RotationAngle, true );
|
||||
Rotate_Module( &dc, (MODULE*) GetCurItem(), m_rotationAngle, true );
|
||||
break;
|
||||
|
||||
case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
|
||||
|
@ -776,7 +776,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
SaveCopyInUndoList( GetCurItem(), UR_ROTATED_CLOCKWISE,
|
||||
((MODULE*)GetCurItem())->GetPosition() );
|
||||
|
||||
Rotate_Module( &dc, (MODULE*) GetCurItem(), -g_RotationAngle, true );
|
||||
Rotate_Module( &dc, (MODULE*) GetCurItem(), -m_rotationAngle, true );
|
||||
break;
|
||||
|
||||
case ID_POPUP_PCB_CHANGE_SIDE_MODULE:
|
||||
|
|
|
@ -317,6 +317,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
|
|||
|
||||
m_footprintLibTable = NULL;
|
||||
m_globalFootprintTable = NULL;
|
||||
m_rotationAngle = 900;
|
||||
|
||||
#ifdef KICAD_SCRIPTING_WXPYTHON
|
||||
m_pythonPanel = NULL;
|
||||
|
@ -1072,3 +1073,12 @@ void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event )
|
|||
DIALOG_PLOT dlg( this );
|
||||
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 )
|
|||
break;
|
||||
|
||||
case ID_CONFIG_READ:
|
||||
{
|
||||
fn = GetBoard()->GetFileName();
|
||||
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 )
|
||||
break;
|
||||
|
||||
if( !wxFileExists( dlg.GetPath() ) )
|
||||
{
|
||||
fn = GetBoard()->GetFileName();
|
||||
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 )
|
||||
break;
|
||||
|
||||
if( !wxFileExists( dlg.GetPath() ) )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) );
|
||||
DisplayError( this, msg );
|
||||
break;
|
||||
}
|
||||
|
||||
LoadProjectSettings( dlg.GetPath() );
|
||||
wxString msg;
|
||||
msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) );
|
||||
DisplayError( this, msg );
|
||||
break;
|
||||
}
|
||||
|
||||
LoadProjectSettings( dlg.GetPath() );
|
||||
}
|
||||
break;
|
||||
|
||||
// Hotkey IDs
|
||||
|
@ -478,7 +478,7 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
|
|||
WHITE ) );
|
||||
|
||||
// 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 ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ), &g_MaxLinksShowed,
|
||||
3, 0, 15 ) );
|
||||
|
@ -486,8 +486,8 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
|
|||
&g_Show_Module_Ratsnest, true ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "TwoSegT" ),
|
||||
&g_TwoSegmentTrackBuild, true ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "SegmPcb45Only" ), &g_Segments_45_Only,
|
||||
true ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "SegmPcb45Only" )
|
||||
, &g_Segments_45_Only, true ) );
|
||||
return m_configSettings;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue