From 7bdcad155a6aed8bf18bc5d2e8a005c6fc632c0a Mon Sep 17 00:00:00 2001 From: Marco Mattila Date: Wed, 30 May 2012 20:38:52 +0300 Subject: [PATCH] Add flip to pcbnew text fields. --- include/wxPcbStruct.h | 1 + pcbnew/class_pcb_text.cpp | 5 ++++- pcbnew/edit.cpp | 6 ++++++ pcbnew/edit_pcb_text.cpp | 26 +++++++++++++++++++++++--- pcbnew/hotkeys.cpp | 8 ++++---- pcbnew/hotkeys.h | 2 +- pcbnew/hotkeys_board_editor.cpp | 9 ++++++--- pcbnew/onrightclick.cpp | 4 +++- pcbnew/pcbnew_id.h | 1 + 9 files changed, 49 insertions(+), 13 deletions(-) diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index c7acd0093c..3cf5496d1e 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -928,6 +928,7 @@ public: // Handling texts on the board void Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ); + void FlipTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC ); TEXTE_PCB* Create_Texte_Pcb( wxDC* DC ); void Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ); void StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC ); diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index e5099e9543..ed98248d9d 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -161,7 +161,10 @@ void TEXTE_PCB::Flip(const wxPoint& aCentre ) { m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y ); // NEGATE( m_Orient ); not needed: m_Mirror handles this - if( ( GetLayer() == LAYER_N_BACK ) || ( GetLayer() == LAYER_N_FRONT ) ) + if( GetLayer() == LAYER_N_BACK + || GetLayer() == LAYER_N_FRONT + || GetLayer() == SILKSCREEN_N_BACK + || GetLayer() == SILKSCREEN_N_FRONT ) { m_Mirror = not m_Mirror; /* inverse mirror */ } diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index c21616962d..fe488532cd 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -81,6 +81,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_TOOLBARH_PCB_SELECT_LAYER: case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR: case ID_POPUP_PCB_ROTATE_TEXTEPCB: + case ID_POPUP_PCB_FLIP_TEXTEPCB: case ID_POPUP_PCB_EDIT_TEXTEPCB: case ID_POPUP_PCB_EDIT_MIRE: case ID_POPUP_PCB_ROTATE_TEXTMODULE: @@ -930,6 +931,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) m_canvas->MoveCursorToCrossHair(); break; + case ID_POPUP_PCB_FLIP_TEXTEPCB: + FlipTextePcb( (TEXTE_PCB*) GetCurItem(), &dc ); + m_canvas->MoveCursorToCrossHair(); + break; + case ID_POPUP_PCB_DELETE_TEXTEPCB: Delete_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc ); m_canvas->MoveCursorToCrossHair(); diff --git a/pcbnew/edit_pcb_text.cpp b/pcbnew/edit_pcb_text.cpp index a059552f4e..249c223b65 100644 --- a/pcbnew/edit_pcb_text.cpp +++ b/pcbnew/edit_pcb_text.cpp @@ -216,7 +216,6 @@ TEXTE_PCB* PCB_EDIT_FRAME::Create_Texte_Pcb( wxDC* DC ) void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) { int angle = 900; - int drawmode = GR_XOR; if( TextePcb == NULL ) return; @@ -228,13 +227,34 @@ void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) NORMALIZE_ANGLE_POS( TextePcb->m_Orient ); /* Redraw text in new position. */ - TextePcb->Draw( m_canvas, DC, drawmode ); + TextePcb->Draw( m_canvas, DC, GR_XOR ); TextePcb->DisplayInfo( this ); if( TextePcb->GetFlags() == 0 ) // i.e. not edited, or moved - SaveCopyInUndoList( TextePcb, UR_ROTATED, TextePcb->m_Pos ); + SaveCopyInUndoList( TextePcb, UR_ROTATED, TextePcb->GetPosition() ); else // set flag edit, to show it was a complex command TextePcb->SetFlags( IN_EDIT ); OnModify(); } + + +void PCB_EDIT_FRAME::FlipTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC ) +{ + if( aTextePcb == NULL ) + return; + + aTextePcb->Draw( m_canvas, aDC, GR_XOR ); + + aTextePcb->Flip( aTextePcb->GetPosition() ); + + aTextePcb->Draw( m_canvas, aDC, GR_XOR ); + aTextePcb->DisplayInfo( this ); + + if( aTextePcb->GetFlags() == 0 ) // i.e. not edited, or moved + SaveCopyInUndoList( aTextePcb, UR_FLIPPED, aTextePcb->GetPosition() ); + else // set flag edit, to show it was a complex command + aTextePcb->SetFlags( IN_EDIT ); + + OnModify(); +} diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 0ee3290907..bc64a74db8 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -67,7 +67,7 @@ static EDA_HOTKEY HkPlaceItem( wxT( "Place Item" ), HK_PLACE_ITEM, 'P' ); static EDA_HOTKEY HkAddMicroVia( wxT( "Add MicroVia" ), HK_ADD_MICROVIA, 'V' + GR_KB_CTRL ); static EDA_HOTKEY HkEndTrack( wxT( "End Track" ), HK_END_TRACK, WXK_END ); static EDA_HOTKEY HkEditBoardItem( wxT( "Edit Item" ), HK_EDIT_ITEM, 'E' ); -static EDA_HOTKEY HkFlipFootprint( wxT( "Flip Footprint" ), HK_FLIP_FOOTPRINT, 'F' ); +static EDA_HOTKEY HkFlipItem( wxT( "Flip Item" ), HK_FLIP_ITEM, 'F' ); static EDA_HOTKEY HkRotateItem( wxT( "Rotate Item" ), HK_ROTATE_ITEM, 'R' ); static EDA_HOTKEY HkMoveItem( wxT( "Move Item" ), HK_MOVE_ITEM, 'M' ); static EDA_HOTKEY HkDragFootprint( wxT( "Drag Footprint" ), HK_DRAG_ITEM, 'G' ); @@ -78,7 +78,7 @@ static EDA_HOTKEY HkLock_Unlock_Footprint( wxT( "Lock/Unlock Footprint" ), static EDA_HOTKEY HkDelete( wxT( "Delete Track or Footprint" ), HK_DELETE, WXK_DELETE ); static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' ); -static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"), +static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"), HK_SWITCH_HIGHCONTRAST_MODE,'H'); /* Fit on Screen */ #if !defined( __WXMAC__ ) @@ -210,8 +210,8 @@ EDA_HOTKEY* board_edit_Hotkey_List[] = &HkSwitchTrackPosture, &HkDragTrackKeepSlope, &HkPlaceItem, - &HkEndTrack, &HkMoveItem, - &HkFlipFootprint, &HkRotateItem, &HkDragFootprint, + &HkEndTrack, &HkMoveItem, &HkFlipItem, + &HkRotateItem, &HkDragFootprint, &HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile, &HkLoadfile, &HkFindItem, &HkEditBoardItem, &HkSwitch2CopperLayer, &HkSwitch2InnerLayer1, diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h index d3246fd2ad..c6f4413f44 100644 --- a/pcbnew/hotkeys.h +++ b/pcbnew/hotkeys.h @@ -14,9 +14,9 @@ enum hotkey_id_commnand { HK_DELETE = HK_COMMON_END, HK_BACK_SPACE, HK_ROTATE_ITEM, + HK_FLIP_ITEM, HK_MOVE_ITEM, HK_DRAG_ITEM, - HK_FLIP_FOOTPRINT, HK_GET_AND_MOVE_FOOTPRINT, HK_LOCK_UNLOCK_FOOTPRINT, HK_ADD_NEW_TRACK, diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 8338ed362e..4b71934430 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -624,9 +624,10 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit OnHotkeyRotateItem( HK_ROTATE_ITEM ); break; - case HK_FLIP_FOOTPRINT: // move to other side - OnHotkeyRotateItem( HK_FLIP_FOOTPRINT ); + case HK_FLIP_ITEM: + OnHotkeyRotateItem( HK_FLIP_ITEM ); break; + case HK_SWITCH_HIGHCONTRAST_MODE: // switch to high contrast mode and refresh the canvas DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay; m_canvas->Refresh(); @@ -1002,7 +1003,7 @@ bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand ) if( aIdCommand == HK_ROTATE_ITEM ) // Rotation evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE; - if( aIdCommand == HK_FLIP_FOOTPRINT ) // move to other side + if( aIdCommand == HK_FLIP_ITEM ) // move to other side evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE; } break; @@ -1010,6 +1011,8 @@ bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand ) case PCB_TEXT_T: if( aIdCommand == HK_ROTATE_ITEM ) // Rotation evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB; + else if( aIdCommand == HK_FLIP_ITEM ) + evt_type = ID_POPUP_PCB_FLIP_TEXTEPCB; break; diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index cc3f769e0d..0548b4061e 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -685,7 +685,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu msg, KiBitmap( rotate_module_pos_xpm ) ); AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE, _( "Rotate -" ), KiBitmap( rotate_module_neg_xpm ) ); - msg = AddHotkeyName( _( "Flip" ), g_Board_Editor_Hokeys_Descr, HK_FLIP_FOOTPRINT ); + msg = AddHotkeyName( _( "Flip" ), g_Board_Editor_Hokeys_Descr, HK_FLIP_ITEM ); AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_CHANGE_SIDE_MODULE, msg, KiBitmap( invert_module_xpm ) ); @@ -839,6 +839,8 @@ void PCB_EDIT_FRAME::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu ) msg = AddHotkeyName( _( "Rotate" ), g_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM ); AddMenuItem( sub_menu_Text, ID_POPUP_PCB_ROTATE_TEXTEPCB, msg, KiBitmap( rotate_ccw_xpm ) ); + msg = AddHotkeyName( _( "Flip" ), g_Board_Editor_Hokeys_Descr, HK_FLIP_ITEM ); + AddMenuItem( sub_menu_Text, ID_POPUP_PCB_FLIP_TEXTEPCB, msg, KiBitmap( invert_module_xpm ) ); msg = AddHotkeyName( _( "Edit" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); AddMenuItem( sub_menu_Text, ID_POPUP_PCB_EDIT_TEXTEPCB, msg, KiBitmap( edit_text_xpm ) ); AddMenuItem( sub_menu_Text, ID_POPUP_PCB_RESET_TEXT_SIZE, diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 7f49e0bf3d..1e1d33247c 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -66,6 +66,7 @@ enum pcbnew_ids ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST, ID_POPUP_PCB_ROTATE_TEXTEPCB, + ID_POPUP_PCB_FLIP_TEXTEPCB, ID_POPUP_PCB_EDIT_TEXTEPCB, ID_POPUP_PCB_DELETE_TEXTEPCB,