Commit 75777f4a authored by Wayne Stambaugh's avatar Wayne Stambaugh

Pcbnew: rotate footprint hot key fixes (fixes lp:1066182).

* Change general properties dialog to allow for entry of arbitrary rotation
  angles for greater than 0 to 90.
* Move global rotation angle variable into PCB_EDIT_FRAME object where it is
  used and add accessors.
* Change rotate footprint undo operation from UR_ROTATE_XXXX to UR_CHANGE.
* Create function to remove trailing zeros from floating point wxString
  objects.
parents bb8741c7 ca11fcb5
...@@ -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;
......
...@@ -477,3 +477,18 @@ bool ReplaceIllegalFileNameChars( std::string* aName ) ...@@ -477,3 +477,18 @@ bool ReplaceIllegalFileNameChars( std::string* aName )
return changed; return changed;
} }
wxString RemoveTrailingZeros( const wxString& aString )
{
wxString retv = aString;
int i = retv.Length();
while( --i > 0 && retv[i] == wxChar( '0' ) )
retv.RemoveLast();
if( retv[i] == wxChar( '.' ) )
retv.RemoveLast();
return retv;
}
...@@ -164,6 +164,18 @@ wxString GetIllegalFileNameWxChars(); ...@@ -164,6 +164,18 @@ wxString GetIllegalFileNameWxChars();
*/ */
bool ReplaceIllegalFileNameChars( std::string* aName ); bool ReplaceIllegalFileNameChars( std::string* aName );
/**
* Function RemoveTrailingZeros
* removes the trailing zeros from \a aString.
*
* All trailing zeros and the '.' character from floating point numbers are removed from
* \a aString.
*
* @param aString is a wxString object to remove the trailing zeros from.
* @return a wxString with the trailing zeros removed.
*/
wxString RemoveTrailingZeros( const wxString& aString );
#ifndef HAVE_STRTOKR #ifndef HAVE_STRTOKR
// common/strtok_r.c optionally: // common/strtok_r.c optionally:
extern "C" char* strtok_r( char* str, const char* delim, char** nextp ); extern "C" char* strtok_r( char* str, const char* delim, char** nextp );
......
...@@ -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:
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <wxPcbStruct.h> #include <wxPcbStruct.h>
#include <class_board_design_settings.h> #include <class_board_design_settings.h>
#include <pcbcommon.h> #include <pcbcommon.h>
#include <kicad_string.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include <class_board.h> #include <class_board.h>
...@@ -69,15 +69,9 @@ void DIALOG_GENERALOPTIONS::init() ...@@ -69,15 +69,9 @@ void DIALOG_GENERALOPTIONS::init()
m_CursorShape->SetSelection( GetParent()->GetCursorShape() ? 1 : 0 ); m_CursorShape->SetSelection( GetParent()->GetCursorShape() ? 1 : 0 );
switch( g_RotationAngle ) wxString rotationAngle;
{ rotationAngle.Printf( wxT( "%.1f" ), ((double)GetParent()->GetRotationAngle()) / 10.0 );
case 450: m_RotationAngle->SetValue( RemoveTrailingZeros( rotationAngle ) );
m_RotationAngle->SetSelection( 0 );
break;
default:
m_RotationAngle->SetSelection( 1 );
}
wxString timevalue; wxString timevalue;
timevalue << GetParent()->GetAutoSaveInterval() / 60; timevalue << GetParent()->GetAutoSaveInterval() / 60;
...@@ -121,8 +115,7 @@ void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event ) ...@@ -121,8 +115,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( wxRound( 10.0 * wxAtof( m_RotationAngle->GetValue() ) ) );
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();
......
...@@ -79,13 +79,10 @@ DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE::DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE( ...@@ -79,13 +79,10 @@ DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE::DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE(
m_staticTextRotationAngle->Wrap( -1 ); m_staticTextRotationAngle->Wrap( -1 );
fgSizer1->Add( m_staticTextRotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); fgSizer1->Add( m_staticTextRotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxString m_RotationAngleChoices[] = { _("45"), _("90") }; m_RotationAngle = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
int m_RotationAngleNChoices = sizeof( m_RotationAngleChoices ) / sizeof( wxString ); m_RotationAngle->SetToolTip( _("Context menu and hot key footprint rotation increment.") );
m_RotationAngle = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_RotationAngleNChoices, m_RotationAngleChoices, 0 );
m_RotationAngle->SetSelection( 0 );
m_RotationAngle->SetToolTip( _("Footprints rotation increment, for rotate menu or hot key.") );
fgSizer1->Add( m_RotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); fgSizer1->Add( m_RotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 );
bMiddleLeftSizer->Add( fgSizer1, 0, wxEXPAND, 5 ); bMiddleLeftSizer->Add( fgSizer1, 0, wxEXPAND, 5 );
......
...@@ -831,9 +831,9 @@ ...@@ -831,9 +831,9 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property> <property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxChoice" expanded="1"> <object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
<property name="RightDockable">1</property> <property name="RightDockable">1</property>
...@@ -847,7 +847,6 @@ ...@@ -847,7 +847,6 @@
<property name="caption"></property> <property name="caption"></property>
<property name="caption_visible">1</property> <property name="caption_visible">1</property>
<property name="center_pane">0</property> <property name="center_pane">0</property>
<property name="choices">&quot;45&quot; &quot;90&quot;</property>
<property name="close_button">1</property> <property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
...@@ -865,6 +864,7 @@ ...@@ -865,6 +864,7 @@
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
...@@ -877,22 +877,21 @@ ...@@ -877,22 +877,21 @@
<property name="pin_button">1</property> <property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property> <property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style"></property> <property name="style"></property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip">Footprints rotation increment, for rotate menu or hot key.</property> <property name="tooltip">Context menu and hot key footprint rotation increment.</property>
<property name="validator_data_type"></property> <property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property> <property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property> <property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property> <property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnChoice"></event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event> <event name="OnKeyDown"></event>
...@@ -914,6 +913,10 @@ ...@@ -914,6 +913,10 @@
<event name="OnRightUp"></event> <event name="OnRightUp"></event>
<event name="OnSetFocus"></event> <event name="OnSetFocus"></event>
<event name="OnSize"></event> <event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
</object> </object>
......
...@@ -23,7 +23,7 @@ class DIALOG_SHIM; ...@@ -23,7 +23,7 @@ class DIALOG_SHIM;
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/spinctrl.h> #include <wx/spinctrl.h>
#include <wx/choice.h> #include <wx/textctrl.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/statbox.h> #include <wx/statbox.h>
#include <wx/statline.h> #include <wx/statline.h>
...@@ -64,7 +64,7 @@ class DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE : public DIALOG_SHIM ...@@ -64,7 +64,7 @@ class DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE : public DIALOG_SHIM
wxStaticText* m_staticTextautosave; wxStaticText* m_staticTextautosave;
wxSpinCtrl* m_SaveTime; wxSpinCtrl* m_SaveTime;
wxStaticText* m_staticTextRotationAngle; wxStaticText* m_staticTextRotationAngle;
wxChoice* m_RotationAngle; wxTextCtrl* m_RotationAngle;
wxCheckBox* m_DrcOn; wxCheckBox* m_DrcOn;
wxCheckBox* m_ShowGlobalRatsnest; wxCheckBox* m_ShowGlobalRatsnest;
wxCheckBox* m_ShowModuleRatsnest; wxCheckBox* m_ShowModuleRatsnest;
......
...@@ -745,9 +745,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -745,9 +745,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// This is a simple rotation, no other editing in progress // This is a simple rotation, no other editing in progress
if( !GetCurItem()->IsMoving() ) if( !GetCurItem()->IsMoving() )
SaveCopyInUndoList( GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->GetPosition() ); SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((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:
...@@ -773,10 +773,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -773,10 +773,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// This is a simple rotation, no other editing in progress // This is a simple rotation, no other editing in progress
if( !GetCurItem()->IsMoving() ) if( !GetCurItem()->IsMoving() )
SaveCopyInUndoList( GetCurItem(), UR_ROTATED_CLOCKWISE, SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((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;
}
...@@ -478,16 +478,16 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() ...@@ -478,16 +478,16 @@ 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, 1, 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 ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowMRa" ), m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowMRa" ),
&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