Add flip to pcbnew text fields.

This commit is contained in:
Marco Mattila 2012-05-30 20:38:52 +03:00
parent b3fd915f59
commit 7bdcad155a
9 changed files with 49 additions and 13 deletions

View File

@ -928,6 +928,7 @@ public:
// Handling texts on the board // Handling texts on the board
void Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ); void Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
void FlipTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC );
TEXTE_PCB* Create_Texte_Pcb( wxDC* DC ); TEXTE_PCB* Create_Texte_Pcb( wxDC* DC );
void Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ); void Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
void StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC ); void StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC );

View File

@ -161,7 +161,10 @@ void TEXTE_PCB::Flip(const wxPoint& aCentre )
{ {
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y ); m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
// NEGATE( m_Orient ); not needed: m_Mirror handles this // 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 */ m_Mirror = not m_Mirror; /* inverse mirror */
} }

View File

@ -81,6 +81,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_TOOLBARH_PCB_SELECT_LAYER: case ID_TOOLBARH_PCB_SELECT_LAYER:
case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR: case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR:
case ID_POPUP_PCB_ROTATE_TEXTEPCB: case ID_POPUP_PCB_ROTATE_TEXTEPCB:
case ID_POPUP_PCB_FLIP_TEXTEPCB:
case ID_POPUP_PCB_EDIT_TEXTEPCB: case ID_POPUP_PCB_EDIT_TEXTEPCB:
case ID_POPUP_PCB_EDIT_MIRE: case ID_POPUP_PCB_EDIT_MIRE:
case ID_POPUP_PCB_ROTATE_TEXTMODULE: case ID_POPUP_PCB_ROTATE_TEXTMODULE:
@ -930,6 +931,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
break; break;
case ID_POPUP_PCB_FLIP_TEXTEPCB:
FlipTextePcb( (TEXTE_PCB*) GetCurItem(), &dc );
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_DELETE_TEXTEPCB: case ID_POPUP_PCB_DELETE_TEXTEPCB:
Delete_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc ); Delete_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();

View File

@ -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 ) void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
{ {
int angle = 900; int angle = 900;
int drawmode = GR_XOR;
if( TextePcb == NULL ) if( TextePcb == NULL )
return; return;
@ -228,13 +227,34 @@ void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
NORMALIZE_ANGLE_POS( TextePcb->m_Orient ); NORMALIZE_ANGLE_POS( TextePcb->m_Orient );
/* Redraw text in new position. */ /* Redraw text in new position. */
TextePcb->Draw( m_canvas, DC, drawmode ); TextePcb->Draw( m_canvas, DC, GR_XOR );
TextePcb->DisplayInfo( this ); TextePcb->DisplayInfo( this );
if( TextePcb->GetFlags() == 0 ) // i.e. not edited, or moved 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 else // set flag edit, to show it was a complex command
TextePcb->SetFlags( IN_EDIT ); TextePcb->SetFlags( IN_EDIT );
OnModify(); 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();
}

View File

@ -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 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 HkEndTrack( wxT( "End Track" ), HK_END_TRACK, WXK_END );
static EDA_HOTKEY HkEditBoardItem( wxT( "Edit Item" ), HK_EDIT_ITEM, 'E' ); 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 HkRotateItem( wxT( "Rotate Item" ), HK_ROTATE_ITEM, 'R' );
static EDA_HOTKEY HkMoveItem( wxT( "Move Item" ), HK_MOVE_ITEM, 'M' ); static EDA_HOTKEY HkMoveItem( wxT( "Move Item" ), HK_MOVE_ITEM, 'M' );
static EDA_HOTKEY HkDragFootprint( wxT( "Drag Footprint" ), HK_DRAG_ITEM, 'G' ); 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 HkDelete( wxT( "Delete Track or Footprint" ), HK_DELETE, WXK_DELETE );
static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ),
HK_RESET_LOCAL_COORD, ' ' ); 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'); HK_SWITCH_HIGHCONTRAST_MODE,'H');
/* Fit on Screen */ /* Fit on Screen */
#if !defined( __WXMAC__ ) #if !defined( __WXMAC__ )
@ -210,8 +210,8 @@ EDA_HOTKEY* board_edit_Hotkey_List[] =
&HkSwitchTrackPosture, &HkSwitchTrackPosture,
&HkDragTrackKeepSlope, &HkDragTrackKeepSlope,
&HkPlaceItem, &HkPlaceItem,
&HkEndTrack, &HkMoveItem, &HkEndTrack, &HkMoveItem, &HkFlipItem,
&HkFlipFootprint, &HkRotateItem, &HkDragFootprint, &HkRotateItem, &HkDragFootprint,
&HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile, &HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile,
&HkLoadfile, &HkFindItem, &HkEditBoardItem, &HkLoadfile, &HkFindItem, &HkEditBoardItem,
&HkSwitch2CopperLayer, &HkSwitch2InnerLayer1, &HkSwitch2CopperLayer, &HkSwitch2InnerLayer1,

View File

@ -14,9 +14,9 @@ enum hotkey_id_commnand {
HK_DELETE = HK_COMMON_END, HK_DELETE = HK_COMMON_END,
HK_BACK_SPACE, HK_BACK_SPACE,
HK_ROTATE_ITEM, HK_ROTATE_ITEM,
HK_FLIP_ITEM,
HK_MOVE_ITEM, HK_MOVE_ITEM,
HK_DRAG_ITEM, HK_DRAG_ITEM,
HK_FLIP_FOOTPRINT,
HK_GET_AND_MOVE_FOOTPRINT, HK_GET_AND_MOVE_FOOTPRINT,
HK_LOCK_UNLOCK_FOOTPRINT, HK_LOCK_UNLOCK_FOOTPRINT,
HK_ADD_NEW_TRACK, HK_ADD_NEW_TRACK,

View File

@ -624,9 +624,10 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
OnHotkeyRotateItem( HK_ROTATE_ITEM ); OnHotkeyRotateItem( HK_ROTATE_ITEM );
break; break;
case HK_FLIP_FOOTPRINT: // move to other side case HK_FLIP_ITEM:
OnHotkeyRotateItem( HK_FLIP_FOOTPRINT ); OnHotkeyRotateItem( HK_FLIP_ITEM );
break; break;
case HK_SWITCH_HIGHCONTRAST_MODE: // switch to high contrast mode and refresh the canvas case HK_SWITCH_HIGHCONTRAST_MODE: // switch to high contrast mode and refresh the canvas
DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay; DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay;
m_canvas->Refresh(); m_canvas->Refresh();
@ -1002,7 +1003,7 @@ bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand )
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE; 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; evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE;
} }
break; break;
@ -1010,6 +1011,8 @@ bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand )
case PCB_TEXT_T: case PCB_TEXT_T:
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB; evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB;
else if( aIdCommand == HK_FLIP_ITEM )
evt_type = ID_POPUP_PCB_FLIP_TEXTEPCB;
break; break;

View File

@ -685,7 +685,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu
msg, KiBitmap( rotate_module_pos_xpm ) ); msg, KiBitmap( rotate_module_pos_xpm ) );
AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE, AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE,
_( "Rotate -" ), KiBitmap( rotate_module_neg_xpm ) ); _( "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, AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_CHANGE_SIDE_MODULE,
msg, KiBitmap( invert_module_xpm ) ); 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 ); 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 ) ); 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 ); 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_EDIT_TEXTEPCB, msg, KiBitmap( edit_text_xpm ) );
AddMenuItem( sub_menu_Text, ID_POPUP_PCB_RESET_TEXT_SIZE, AddMenuItem( sub_menu_Text, ID_POPUP_PCB_RESET_TEXT_SIZE,

View File

@ -66,6 +66,7 @@ enum pcbnew_ids
ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST, ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST,
ID_POPUP_PCB_ROTATE_TEXTEPCB, ID_POPUP_PCB_ROTATE_TEXTEPCB,
ID_POPUP_PCB_FLIP_TEXTEPCB,
ID_POPUP_PCB_EDIT_TEXTEPCB, ID_POPUP_PCB_EDIT_TEXTEPCB,
ID_POPUP_PCB_DELETE_TEXTEPCB, ID_POPUP_PCB_DELETE_TEXTEPCB,