Commit b98b23a1 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Factor Eeschema rotate item hot keys into a rotate event handler.

* Add a rotate event handler to schematic frame object.
* Remove unique rotate item command IDs.
* Use process event instead of post event to eliminate the need to clean
  up the command event client object from the heap.
* Unify find next item and next DRC error hot key commands.
* Unify move and rotate hot keys commands.
parent 2476bc7f
...@@ -78,6 +78,11 @@ EDA_HOTKEY::EDA_HOTKEY( const EDA_HOTKEY* base ) ...@@ -78,6 +78,11 @@ EDA_HOTKEY::EDA_HOTKEY( const EDA_HOTKEY* base )
} }
EDA_HOTKEY_CLIENT_DATA::~EDA_HOTKEY_CLIENT_DATA()
{
}
/* class to handle the printable name and the keycode /* class to handle the printable name and the keycode
*/ */
struct hotkey_name_descr struct hotkey_name_descr
......
...@@ -103,7 +103,6 @@ enum id_eeschema_frm ...@@ -103,7 +103,6 @@ enum id_eeschema_frm
ID_POPUP_SCH_INIT_CMP, ID_POPUP_SCH_INIT_CMP,
ID_POPUP_SCH_EDIT_TEXT, ID_POPUP_SCH_EDIT_TEXT,
ID_POPUP_SCH_ROTATE_TEXT,
ID_POPUP_SCH_SET_SHAPE_TEXT, ID_POPUP_SCH_SET_SHAPE_TEXT,
ID_POPUP_END_LINE, ID_POPUP_END_LINE,
ID_POPUP_SCH_END_SHEET, ID_POPUP_SCH_END_SHEET,
...@@ -118,7 +117,6 @@ enum id_eeschema_frm ...@@ -118,7 +117,6 @@ enum id_eeschema_frm
ID_POPUP_SCH_EDIT_REF_CMP, ID_POPUP_SCH_EDIT_REF_CMP,
ID_POPUP_SCH_EDIT_FOOTPRINT_CMP, ID_POPUP_SCH_EDIT_FOOTPRINT_CMP,
ID_POPUP_SCH_EDIT_CONVERT_CMP, ID_POPUP_SCH_EDIT_CONVERT_CMP,
ID_POPUP_SCH_ROTATE_FIELD,
ID_POPUP_SCH_EDIT_FIELD, ID_POPUP_SCH_EDIT_FIELD,
ID_POPUP_SCH_DISPLAYDOC_CMP, ID_POPUP_SCH_DISPLAYDOC_CMP,
ID_POPUP_SCH_ENTER_SHEET, ID_POPUP_SCH_ENTER_SHEET,
...@@ -129,7 +127,6 @@ enum id_eeschema_frm ...@@ -129,7 +127,6 @@ enum id_eeschema_frm
ID_POPUP_SCH_GETINFO_MARKER, ID_POPUP_SCH_GETINFO_MARKER,
// Edit or change image orientation or context menu command IDs. // Edit or change image orientation or context menu command IDs.
ID_POPUP_SCH_EDIT_IMAGE, ID_POPUP_SCH_EDIT_IMAGE,
ID_POPUP_SCH_ROTATE_IMAGE,
ID_POPUP_SCH_MIRROR_X_IMAGE, ID_POPUP_SCH_MIRROR_X_IMAGE,
ID_POPUP_SCH_MIRROR_Y_IMAGE, ID_POPUP_SCH_MIRROR_Y_IMAGE,
ID_POPUP_END_RANGE, ID_POPUP_END_RANGE,
...@@ -182,6 +179,8 @@ enum id_eeschema_frm ...@@ -182,6 +179,8 @@ enum id_eeschema_frm
ID_SELECT_ITEM_START, ID_SELECT_ITEM_START,
ID_SELECT_ITEM_END = ID_SELECT_ITEM_START + MAX_SELECT_ITEM_IDS, ID_SELECT_ITEM_END = ID_SELECT_ITEM_START + MAX_SELECT_ITEM_IDS,
ID_SCH_ROTATE_ITEM,
ID_POPUP_SCH_MOVE_ITEM, ID_POPUP_SCH_MOVE_ITEM,
// Schematic editor commmands. These are command IDs that are generated by multiple // Schematic editor commmands. These are command IDs that are generated by multiple
......
...@@ -280,7 +280,10 @@ void SCH_EDIT_FRAME::OnChangeComponentOrientation( wxCommandEvent& aEvent ) ...@@ -280,7 +280,10 @@ void SCH_EDIT_FRAME::OnChangeComponentOrientation( wxCommandEvent& aEvent )
DrawPanel->MoveCursorToCrossHair(); DrawPanel->MoveCursorToCrossHair();
if( component->GetFlags() == 0 ) if( component->GetFlags() == 0 )
{
SaveCopyInUndoList( item, UR_CHANGED ); SaveCopyInUndoList( item, UR_CHANGED );
GetScreen()->SetCurItem( NULL );
}
INSTALL_UNBUFFERED_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
......
...@@ -158,7 +158,7 @@ static EDA_HOTKEY HkMirrorYComponent( wxT( "Mirror Y Component" ), HK_MIRROR_Y_C ...@@ -158,7 +158,7 @@ static EDA_HOTKEY HkMirrorYComponent( wxT( "Mirror Y Component" ), HK_MIRROR_Y_C
static EDA_HOTKEY HkMirrorXComponent( wxT( "Mirror X Component" ), HK_MIRROR_X_COMPONENT, 'X' ); static EDA_HOTKEY HkMirrorXComponent( wxT( "Mirror X Component" ), HK_MIRROR_X_COMPONENT, 'X' );
static EDA_HOTKEY HkOrientNormalComponent( wxT( "Orient Normal Component" ), static EDA_HOTKEY HkOrientNormalComponent( wxT( "Orient Normal Component" ),
HK_ORIENT_NORMAL_COMPONENT, 'N' ); HK_ORIENT_NORMAL_COMPONENT, 'N' );
static EDA_HOTKEY HkRotate( wxT( "Rotate Item" ), HK_ROTATE, 'R' ); static EDA_HOTKEY HkRotate( wxT( "Rotate Item" ), HK_ROTATE, 'R', ID_SCH_ROTATE_ITEM );
static EDA_HOTKEY HkEdit( wxT( "Edit Schematic Item" ), HK_EDIT, 'E' ); static EDA_HOTKEY HkEdit( wxT( "Edit Schematic Item" ), HK_EDIT, 'E' );
static EDA_HOTKEY HkEditComponentValue( wxT( "Edit Component Value" ), static EDA_HOTKEY HkEditComponentValue( wxT( "Edit Component Value" ),
HK_EDIT_COMPONENT_VALUE, 'V', HK_EDIT_COMPONENT_VALUE, 'V',
...@@ -182,9 +182,10 @@ static EDA_HOTKEY HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSER ...@@ -182,9 +182,10 @@ static EDA_HOTKEY HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSER
static EDA_HOTKEY HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE ); static EDA_HOTKEY HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE );
static EDA_HOTKEY HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL ); static EDA_HOTKEY HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL );
static EDA_HOTKEY HkFindNextItem( wxT( "Find Next Item" ), HK_FIND_NEXT_ITEM, WXK_F5 ); static EDA_HOTKEY HkFindNextItem( wxT( "Find Next Item" ), HK_FIND_NEXT_ITEM, WXK_F5,
wxEVT_COMMAND_FIND );
static EDA_HOTKEY HkFindNextDrcMarker( wxT( "Find Next DRC Marker" ), HK_FIND_NEXT_DRC_MARKER, static EDA_HOTKEY HkFindNextDrcMarker( wxT( "Find Next DRC Marker" ), HK_FIND_NEXT_DRC_MARKER,
WXK_F5 + GR_KB_SHIFT ); WXK_F5 + GR_KB_SHIFT, EVT_COMMAND_FIND_DRC_MARKER );
// Special keys for library editor: // Special keys for library editor:
static EDA_HOTKEY HkCreatePin( wxT( "Create Pin" ), HK_LIBEDIT_CREATE_PIN, 'P' ); static EDA_HOTKEY HkCreatePin( wxT( "Create Pin" ), HK_LIBEDIT_CREATE_PIN, 'P' );
...@@ -385,25 +386,16 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -385,25 +386,16 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
case HK_FIND_NEXT_ITEM: case HK_FIND_NEXT_ITEM:
if( notBusy )
{
wxFindDialogEvent event( wxEVT_COMMAND_FIND, GetId() );
event.SetEventObject( this );
event.SetFlags( m_findReplaceData->GetFlags() );
event.SetFindString( m_findReplaceData->GetFindString() );
GetEventHandler()->ProcessEvent( event );
}
break;
case HK_FIND_NEXT_DRC_MARKER: case HK_FIND_NEXT_DRC_MARKER:
if( notBusy ) if( notBusy )
{ {
wxFindDialogEvent event( EVT_COMMAND_FIND_DRC_MARKER, GetId() ); wxFindDialogEvent event( hotKey->m_IdMenuEvent, GetId() );
event.SetEventObject( this ); event.SetEventObject( this );
event.SetFlags( m_findReplaceData->GetFlags() ); event.SetFlags( m_findReplaceData->GetFlags() );
event.SetFindString( m_findReplaceData->GetFindString() ); event.SetFindString( m_findReplaceData->GetFindString() );
GetEventHandler()->ProcessEvent( event ); GetEventHandler()->ProcessEvent( event );
} }
break; break;
case HK_ADD_NEW_COMPONENT: // Add component case HK_ADD_NEW_COMPONENT: // Add component
...@@ -422,10 +414,11 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -422,10 +414,11 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_BEGIN_WIRE: case HK_BEGIN_WIRE:
if( notBusy ) if( notBusy )
{ {
EDA_HOTKEY_CLIENT_DATA data( aPosition );
cmd.SetInt( aHotKey ); cmd.SetInt( aHotKey );
cmd.SetClientData( new EDA_HOTKEY_CLIENT_DATA( aPosition ) ); cmd.SetClientObject( &data );
cmd.SetId( hotKey->m_IdMenuEvent ); cmd.SetId( hotKey->m_IdMenuEvent );
wxPostEvent( this, cmd ); GetEventHandler()->ProcessEvent( cmd );
} }
else if( aItem && aItem->IsNew() ) else if( aItem && aItem->IsNew() )
{ {
...@@ -454,57 +447,6 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -454,57 +447,6 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
case HK_ROTATE: // Component or other schematic item rotation
if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK )//allows bloc operation on hotkey
{
HandleBlockEndByPopUp( BLOCK_ROTATE, aDC );
break;
}
if( aItem == NULL )
{
// Find the schematic object to rotate under the cursor
aItem = LocateAndShowItem( aPosition, SCH_COLLECTOR::RotatableItems );
if( aItem == NULL )
break;
}
switch( aItem->Type() )
{
case SCH_SHEET_T: //TODO allow sheet rotate on hotkey
//wxPostEvent( this, eventRotateSheet );
break;
case SCH_COMPONENT_T:
cmd.SetId( ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE );
wxPostEvent( this, cmd );
break;
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
cmd.SetId( ID_POPUP_SCH_ROTATE_TEXT );
wxPostEvent( this, cmd );
break;
case SCH_FIELD_T:
cmd.SetId( ID_POPUP_SCH_ROTATE_FIELD );
wxPostEvent( this, cmd );
break;
case SCH_BITMAP_T:
cmd.SetId( ID_POPUP_SCH_ROTATE_IMAGE );
wxPostEvent( this, cmd );
break;
default:
break;
}
break;
case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component) case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component)
if( screen->m_BlockLocate.m_State != STATE_NO_BLOCK ) if( screen->m_BlockLocate.m_State != STATE_NO_BLOCK )
{ {
...@@ -615,12 +557,16 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -615,12 +557,16 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
case HK_ROTATE: // Component or other schematic item rotation.
case HK_MOVE_COMPONENT_OR_ITEM: // Start move schematic item. case HK_MOVE_COMPONENT_OR_ITEM: // Start move schematic item.
{
EDA_HOTKEY_CLIENT_DATA data( aPosition );
cmd.SetInt( aHotKey ); cmd.SetInt( aHotKey );
cmd.SetClientData( new EDA_HOTKEY_CLIENT_DATA( aPosition ) ); cmd.SetClientObject( &data );
cmd.SetId( hotKey->m_IdMenuEvent ); cmd.SetId( hotKey->m_IdMenuEvent );
wxPostEvent( this, cmd ); GetEventHandler()->ProcessEvent( cmd );
break; break;
}
case HK_EDIT: case HK_EDIT:
......
...@@ -250,7 +250,7 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field ) ...@@ -250,7 +250,7 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
} }
msg = AddHotkeyName( _( "Rotate Field" ), s_Schematic_Hokeys_Descr, HK_ROTATE ); msg = AddHotkeyName( _( "Rotate Field" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
AddMenuItem( PopMenu, ID_POPUP_SCH_ROTATE_FIELD, msg, KiBitmap( rotate_field_xpm ) ); AddMenuItem( PopMenu, ID_SCH_ROTATE_ITEM, msg, KiBitmap( rotate_field_xpm ) );
msg = AddHotkeyName( _( "Edit Field" ), s_Schematic_Hokeys_Descr, HK_EDIT ); msg = AddHotkeyName( _( "Edit Field" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_FIELD, msg, KiBitmap( edit_text_xpm ) ); AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_FIELD, msg, KiBitmap( edit_text_xpm ) );
} }
...@@ -384,7 +384,7 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel ) ...@@ -384,7 +384,7 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
} }
msg = AddHotkeyName( _( "Rotate Global Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE ); msg = AddHotkeyName( _( "Rotate Global Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
AddMenuItem( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg, KiBitmap( rotate_glabel_xpm ) ); AddMenuItem( PopMenu, ID_SCH_ROTATE_ITEM, msg, KiBitmap( rotate_glabel_xpm ) );
msg = AddHotkeyName( _( "Edit Global Label" ), s_Schematic_Hokeys_Descr, HK_EDIT ); msg = AddHotkeyName( _( "Edit Global Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) ); AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) );
msg = AddHotkeyName( _( "Delete Global Label" ), s_Schematic_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Global Label" ), s_Schematic_Hokeys_Descr, HK_DELETE );
...@@ -420,7 +420,7 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel ) ...@@ -420,7 +420,7 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
} }
msg = AddHotkeyName( _( "Rotate Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE ); msg = AddHotkeyName( _( "Rotate Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
AddMenuItem( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg, KiBitmap( rotate_glabel_xpm ) ); AddMenuItem( PopMenu, ID_SCH_ROTATE_ITEM, msg, KiBitmap( rotate_glabel_xpm ) );
msg = AddHotkeyName( _( "Edit Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_EDIT ); msg = AddHotkeyName( _( "Edit Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) ); AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) );
msg = AddHotkeyName( _( "Delete Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_DELETE );
...@@ -456,7 +456,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label ) ...@@ -456,7 +456,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
} }
msg = AddHotkeyName( _( "Rotate Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE ); msg = AddHotkeyName( _( "Rotate Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
AddMenuItem( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg, KiBitmap( rotate_ccw_xpm ) ); AddMenuItem( PopMenu, ID_SCH_ROTATE_ITEM, msg, KiBitmap( rotate_ccw_xpm ) );
msg = AddHotkeyName( _( "Edit Label" ), s_Schematic_Hokeys_Descr, HK_EDIT ); msg = AddHotkeyName( _( "Edit Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) ); AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) );
msg = AddHotkeyName( _( "Delete Label" ), s_Schematic_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Label" ), s_Schematic_Hokeys_Descr, HK_DELETE );
...@@ -490,7 +490,7 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ) ...@@ -490,7 +490,7 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
} }
msg = AddHotkeyName( _( "Rotate Text" ), s_Schematic_Hokeys_Descr, HK_ROTATE ); msg = AddHotkeyName( _( "Rotate Text" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
AddMenuItem( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg, KiBitmap( rotate_ccw_xpm ) ); AddMenuItem( PopMenu, ID_SCH_ROTATE_ITEM, msg, KiBitmap( rotate_ccw_xpm ) );
msg = AddHotkeyName( _( "Edit Text" ), s_Schematic_Hokeys_Descr, HK_EDIT ); msg = AddHotkeyName( _( "Edit Text" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) ); AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) );
msg = AddHotkeyName( _( "Delete Text" ), s_Schematic_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Text" ), s_Schematic_Hokeys_Descr, HK_DELETE );
...@@ -706,7 +706,7 @@ void AddMenusForBlock( wxMenu* PopMenu, SCH_EDIT_FRAME* frame ) ...@@ -706,7 +706,7 @@ void AddMenusForBlock( wxMenu* PopMenu, SCH_EDIT_FRAME* frame )
KiBitmap( mirror_h_xpm ) ); KiBitmap( mirror_h_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block --" ), AddMenuItem( PopMenu, ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block --" ),
KiBitmap( mirror_v_xpm ) ); KiBitmap( mirror_v_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_ROTATE_BLOCK, _( "Rotate Block ccw" ), AddMenuItem( PopMenu, ID_SCH_ROTATE_ITEM, _( "Rotate Block ccw" ),
KiBitmap( rotate_ccw_xpm ) ); KiBitmap( rotate_ccw_xpm ) );
#if 0 #if 0
...@@ -737,7 +737,7 @@ void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap ) ...@@ -737,7 +737,7 @@ void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap )
} }
msg = AddHotkeyName( _( "Rotate Image" ), s_Schematic_Hokeys_Descr, HK_ROTATE ); msg = AddHotkeyName( _( "Rotate Image" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
AddMenuItem( aPopMenu, ID_POPUP_SCH_ROTATE_IMAGE, msg, KiBitmap( rotate_ccw_xpm ) ); AddMenuItem( aPopMenu, ID_SCH_ROTATE_ITEM, msg, KiBitmap( rotate_ccw_xpm ) );
AddMenuItem( aPopMenu, ID_POPUP_SCH_MIRROR_X_IMAGE, AddMenuItem( aPopMenu, ID_POPUP_SCH_MIRROR_X_IMAGE,
_( "Mirror --" ), KiBitmap( mirror_v_xpm ) ); _( "Mirror --" ), KiBitmap( mirror_v_xpm ) );
AddMenuItem( aPopMenu, ID_POPUP_SCH_MIRROR_Y_IMAGE, AddMenuItem( aPopMenu, ID_POPUP_SCH_MIRROR_Y_IMAGE,
......
...@@ -71,7 +71,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -71,7 +71,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_END_LINE: case ID_POPUP_END_LINE:
case ID_POPUP_SCH_EDIT_TEXT: case ID_POPUP_SCH_EDIT_TEXT:
case ID_POPUP_SCH_SET_SHAPE_TEXT: case ID_POPUP_SCH_SET_SHAPE_TEXT:
case ID_POPUP_SCH_ROTATE_TEXT:
case ID_POPUP_SCH_EDIT_SHEET: case ID_POPUP_SCH_EDIT_SHEET:
case ID_POPUP_SCH_CLEANUP_SHEET: case ID_POPUP_SCH_CLEANUP_SHEET:
case ID_POPUP_SCH_END_SHEET: case ID_POPUP_SCH_END_SHEET:
...@@ -86,7 +85,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -86,7 +85,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_EDIT_REF_CMP: case ID_POPUP_SCH_EDIT_REF_CMP:
case ID_POPUP_SCH_EDIT_FOOTPRINT_CMP: case ID_POPUP_SCH_EDIT_FOOTPRINT_CMP:
case ID_POPUP_SCH_EDIT_CONVERT_CMP: case ID_POPUP_SCH_EDIT_CONVERT_CMP:
case ID_POPUP_SCH_ROTATE_FIELD:
case ID_POPUP_SCH_EDIT_FIELD: case ID_POPUP_SCH_EDIT_FIELD:
case ID_POPUP_DELETE_BLOCK: case ID_POPUP_DELETE_BLOCK:
case ID_POPUP_PLACE_BLOCK: case ID_POPUP_PLACE_BLOCK:
...@@ -103,7 +101,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -103,7 +101,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_ADD_JUNCTION: case ID_POPUP_SCH_ADD_JUNCTION:
case ID_POPUP_SCH_ADD_LABEL: case ID_POPUP_SCH_ADD_LABEL:
case ID_POPUP_SCH_GETINFO_MARKER: case ID_POPUP_SCH_GETINFO_MARKER:
case ID_POPUP_SCH_ROTATE_IMAGE:
case ID_POPUP_SCH_MIRROR_X_IMAGE: case ID_POPUP_SCH_MIRROR_X_IMAGE:
case ID_POPUP_SCH_MIRROR_Y_IMAGE: case ID_POPUP_SCH_MIRROR_Y_IMAGE:
...@@ -178,21 +175,11 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -178,21 +175,11 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
EditSchematicText( (SCH_TEXT*) item ); EditSchematicText( (SCH_TEXT*) item );
break; break;
case ID_POPUP_SCH_ROTATE_TEXT:
DrawPanel->MoveCursorToCrossHair();
ChangeTextOrient( (SCH_TEXT*) item, &dc );
break;
case ID_POPUP_SCH_SET_SHAPE_TEXT: case ID_POPUP_SCH_SET_SHAPE_TEXT:
// Not used // Not used
break; break;
case ID_POPUP_SCH_ROTATE_FIELD:
DrawPanel->MoveCursorToCrossHair();
RotateField( (SCH_FIELD*) item, &dc );
break;
case ID_POPUP_SCH_EDIT_FIELD: case ID_POPUP_SCH_EDIT_FIELD:
EditComponentFieldText( (SCH_FIELD*) item, &dc ); EditComponentFieldText( (SCH_FIELD*) item, &dc );
break; break;
...@@ -459,11 +446,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -459,11 +446,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
EditImage( (SCH_BITMAP*) item ); EditImage( (SCH_BITMAP*) item );
break; break;
case ID_POPUP_SCH_ROTATE_IMAGE:
if( item )
RotateImage( (SCH_BITMAP*) item );
break;
case ID_POPUP_SCH_MIRROR_X_IMAGE: case ID_POPUP_SCH_MIRROR_X_IMAGE:
if( item ) if( item )
MirrorImage( (SCH_BITMAP*) item, true ); MirrorImage( (SCH_BITMAP*) item, true );
...@@ -497,16 +479,13 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) ...@@ -497,16 +479,13 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
if( aEvent.GetInt() == 0 ) if( aEvent.GetInt() == 0 )
return; return;
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientData(); EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client data." ) ); wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::MovableItems, item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::MovableItems,
aEvent.GetInt() ); aEvent.GetInt() );
aEvent.SetClientData( NULL );
delete data;
// Exit if no item found at the current location or the item is already being edited. // Exit if no item found at the current location or the item is already being edited.
if( (item == NULL) || (item->GetFlags() != 0) ) if( (item == NULL) || (item->GetFlags() != 0) )
return; return;
...@@ -668,15 +647,12 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) ...@@ -668,15 +647,12 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
} }
// Simulate left click event if we got here from a hot key. // Simulate left click event if we got here from a hot key.
if( aEvent.GetClientData() != NULL ) if( aEvent.GetClientObject() != NULL )
{ {
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientData(); EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
wxPoint pos = data->GetPosition(); wxPoint pos = data->GetPosition();
aEvent.SetClientData( NULL );
delete data;
INSTALL_UNBUFFERED_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
OnLeftClick( &dc, pos ); OnLeftClick( &dc, pos );
} }
...@@ -824,3 +800,69 @@ void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC ) ...@@ -824,3 +800,69 @@ void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC )
moveItem( DrawPanel, aDC, wxDefaultPosition, true ); moveItem( DrawPanel, aDC, wxDefaultPosition, true );
DrawPanel->CrossHairOn( aDC ); DrawPanel->CrossHairOn( aDC );
} }
void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
{
SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem();
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
if( item == NULL )
{
// If we didn't get here by a hot key, then something has gone wrong.
if( aEvent.GetInt() == 0 )
return;
// Allows block rotate operation on hot key.
if( screen->m_BlockLocate.m_State != STATE_NO_BLOCK )
{
HandleBlockEndByPopUp( BLOCK_ROTATE, &dc );
return;
}
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::RotatableItems,
aEvent.GetInt() );
// Exit if no item found at the current location or the item is already being edited.
if( (item == NULL) || (item->GetFlags() != 0) )
return;
}
switch( item->Type() )
{
case SCH_COMPONENT_T:
aEvent.SetId( ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE );
wxPostEvent( this, aEvent );
return;
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
DrawPanel->MoveCursorToCrossHair();
ChangeTextOrient( (SCH_TEXT*) item, &dc );
break;
case SCH_FIELD_T:
DrawPanel->MoveCursorToCrossHair();
RotateField( (SCH_FIELD*) item, &dc );
break;
case SCH_BITMAP_T:
RotateImage( (SCH_BITMAP*) item );
break;
case SCH_SHEET_T: /// @todo allow sheet rotate on hotkey
default:
break;
}
if( item->GetFlags() == 0 )
screen->SetCurItem( NULL );
}
...@@ -134,14 +134,13 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) ...@@ -134,14 +134,13 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
SCH_EDIT_FRAME::OnSelectTool ) SCH_EDIT_FRAME::OnSelectTool )
EVT_MENU( ID_CANCEL_CURRENT_COMMAND, SCH_EDIT_FRAME::OnCancelCurrentCommand ) EVT_MENU( ID_CANCEL_CURRENT_COMMAND, SCH_EDIT_FRAME::OnCancelCurrentCommand )
EVT_MENU( ID_SCH_ROTATE_ITEM, SCH_EDIT_FRAME::OnRotate )
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE, EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
SCH_EDIT_FRAME::Process_Special_Functions ) SCH_EDIT_FRAME::Process_Special_Functions )
// Tools and buttons options toolbar // Tools and buttons options toolbar
EVT_TOOL( ID_TB_OPTIONS_HIDDEN_PINS, EVT_TOOL( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnSelectOptionToolbar )
SCH_EDIT_FRAME::OnSelectOptionToolbar ) EVT_TOOL( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
SCH_EDIT_FRAME::OnSelectOptionToolbar )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
SCH_EDIT_FRAME::Process_Special_Functions ) SCH_EDIT_FRAME::Process_Special_Functions )
......
...@@ -99,6 +99,8 @@ public: ...@@ -99,6 +99,8 @@ public:
EDA_HOTKEY_CLIENT_DATA( const wxPoint& aPosition = wxDefaultPosition ) : EDA_HOTKEY_CLIENT_DATA( const wxPoint& aPosition = wxDefaultPosition ) :
m_position( aPosition ) {} m_position( aPosition ) {}
~EDA_HOTKEY_CLIENT_DATA();
void SetPosition( const wxPoint& aPosition ) { m_position = aPosition; } void SetPosition( const wxPoint& aPosition ) { m_position = aPosition; }
wxPoint GetPosition() { return m_position; } wxPoint GetPosition() { return m_position; }
......
...@@ -618,6 +618,13 @@ public: ...@@ -618,6 +618,13 @@ public:
private: private:
void OnMoveItem( wxCommandEvent& aEvent ); void OnMoveItem( wxCommandEvent& aEvent );
/**
* Function OnRotate
* handles the #ID_SCH_ROTATE_ITEM event used to rotates schematic itams and blocks.
*/
void OnRotate( wxCommandEvent& aEvent );
void OnExit( wxCommandEvent& event ); void OnExit( wxCommandEvent& event );
void OnAnnotate( wxCommandEvent& event ); void OnAnnotate( wxCommandEvent& event );
void OnErc( wxCommandEvent& event ); void OnErc( wxCommandEvent& event );
......
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