Commit 62764cd6 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Fix Pcbnew block rotate hot key and minor code cleaning.

parent c6743148
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2010 Jean-Pierre Charras, jp.charras@wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
......
This diff is collapsed.
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras@wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/** /**
* @file hotkeys_board_editor.cpp * @file hotkeys_board_editor.cpp
*/ */
...@@ -117,7 +141,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit ...@@ -117,7 +141,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
macros_record.m_HotkeyCode = aHotkeyCode; macros_record.m_HotkeyCode = aHotkeyCode;
macros_record.m_Idcommand = HK_Descr->m_Idcommand; macros_record.m_Idcommand = HK_Descr->m_Idcommand;
macros_record.m_Position = GetNearestGridPosition( aPosition ) - macros_record.m_Position = GetNearestGridPosition( aPosition ) -
m_Macros[m_RecordingMacros].m_StartPosition; m_Macros[m_RecordingMacros].m_StartPosition;
m_Macros[m_RecordingMacros].m_Record.push_back( macros_record ); m_Macros[m_RecordingMacros].m_Record.push_back( macros_record );
wxString msg; wxString msg;
msg.Printf( _( "Add key [%c] in macro %d" ), aHotkeyCode, m_RecordingMacros ); msg.Printf( _( "Add key [%c] in macro %d" ), aHotkeyCode, m_RecordingMacros );
...@@ -168,7 +192,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit ...@@ -168,7 +192,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
if( GetCanvas()->IsMouseCaptured() ) if( GetCanvas()->IsMouseCaptured() )
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );
if( GetBoard()->GetTrackWidthIndex() < GetBoard()->m_TrackWidthList.size() - 1) if( GetBoard()->GetTrackWidthIndex() < GetBoard()->m_TrackWidthList.size() - 1 )
GetBoard()->SetTrackWidthIndex( GetBoard()->GetTrackWidthIndex() + 1 ); GetBoard()->SetTrackWidthIndex( GetBoard()->GetTrackWidthIndex() + 1 );
else else
GetBoard()->SetTrackWidthIndex( 0 ); GetBoard()->SetTrackWidthIndex( 0 );
...@@ -594,7 +618,7 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC ) ...@@ -594,7 +618,7 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC )
{ {
item = PcbGeneralLocateAndDisplay(); item = PcbGeneralLocateAndDisplay();
if( item && !item->IsTrack( ) ) if( item && !item->IsTrack() )
return false; return false;
Delete_Track( aDC, (TRACK*) item ); Delete_Track( aDC, (TRACK*) item );
...@@ -945,15 +969,7 @@ bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC ) ...@@ -945,15 +969,7 @@ bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC )
return false; return false;
} }
/*
* Function OnHotkeyBeginRoute
* If the current active layer is a copper layer,
* and if no item currently edited, starta new track on
* the current copper layer
* If a new track is in progress, terminate the current segment and
* start a new one.
* Returns a reference to the track if a track is created, or NULL
*/
TRACK * PCB_EDIT_FRAME::OnHotkeyBeginRoute( wxDC* aDC ) TRACK * PCB_EDIT_FRAME::OnHotkeyBeginRoute( wxDC* aDC )
{ {
if( getActiveLayer() > LAYER_N_FRONT ) if( getActiveLayer() > LAYER_N_FRONT )
...@@ -1004,42 +1020,48 @@ bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand ) ...@@ -1004,42 +1020,48 @@ bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand )
bool itemCurrentlyEdited = item && item->GetFlags(); bool itemCurrentlyEdited = item && item->GetFlags();
int evt_type = 0; // Used to post a wxCommandEvent on demand int evt_type = 0; // Used to post a wxCommandEvent on demand
if( !itemCurrentlyEdited ) // Allows block rotate operation on hot key.
item = PcbGeneralLocateAndDisplay(); if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
{
evt_type = ID_POPUP_ROTATE_BLOCK;
}
else
{
if( !itemCurrentlyEdited )
item = PcbGeneralLocateAndDisplay();
if( item == NULL ) if( item == NULL )
return false; return false;
SetCurItem( item ); SetCurItem( item );
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_MODULE_T: case PCB_MODULE_T:
{ 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_ITEM ) // 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;
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 ) else if( aIdCommand == HK_FLIP_ITEM )
evt_type = ID_POPUP_PCB_FLIP_TEXTEPCB; evt_type = ID_POPUP_PCB_FLIP_TEXTEPCB;
break; break;
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE; evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE;
break; break;
default: default:
break; break;
}
} }
if( evt_type != 0 ) if( evt_type != 0 )
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jp.charras@wanadoo.fr
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/** /**
* @file pcbnew/protos.h * @file pcbnew/protos.h
*/ */
...@@ -17,7 +41,8 @@ class MODULE; ...@@ -17,7 +41,8 @@ class MODULE;
* Function SwapData * Function SwapData
* Used in undo / redo command: * Used in undo / redo command:
* swap data between Item and a copy * swap data between Item and a copy
* swapped data is data modified by edition, so NOT ALL values are swapped * swapped data is data modified by edition, mainly sizes and texts
* so ONLY FEW values are swapped
* @param aItem = the item * @param aItem = the item
* @param aImage = a copy of the item * @param aImage = a copy of the item
*/ */
......
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