Fix Pcbnew block rotate hot key and minor code cleaning.
This commit is contained in:
parent
c674314859
commit
62764cd618
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* 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
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/*************************************************************/
|
|
||||||
/* board editor: undo and redo functions for board editor */
|
|
||||||
/*************************************************************/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
|
@ -45,8 +41,8 @@
|
||||||
|
|
||||||
|
|
||||||
/* Functions to undo and redo edit commands.
|
/* Functions to undo and redo edit commands.
|
||||||
* commmands to undo are stored in CurrentScreen->m_UndoList
|
* commands to undo are stored in CurrentScreen->m_UndoList
|
||||||
* commmands to redo are stored in CurrentScreen->m_RedoList
|
* commands to redo are stored in CurrentScreen->m_RedoList
|
||||||
*
|
*
|
||||||
* m_UndoList and m_RedoList handle a std::vector of PICKED_ITEMS_LIST
|
* m_UndoList and m_RedoList handle a std::vector of PICKED_ITEMS_LIST
|
||||||
* Each PICKED_ITEMS_LIST handle a std::vector of pickers (class ITEM_PICKER),
|
* Each PICKED_ITEMS_LIST handle a std::vector of pickers (class ITEM_PICKER),
|
||||||
|
@ -89,8 +85,8 @@
|
||||||
* => The list of item(s) is used to create a deleted list in undo list(same as a delete
|
* => The list of item(s) is used to create a deleted list in undo list(same as a delete
|
||||||
* command)
|
* command)
|
||||||
*
|
*
|
||||||
* Some block operations that change items can be undoed without memorise items, just the
|
* Some block operations that change items can be undone without memorize items, just the
|
||||||
* coordiantes of the transform:
|
* coordinates of the transform:
|
||||||
* move list of items (undo/redo is made by moving with the opposite move vector)
|
* move list of items (undo/redo is made by moving with the opposite move vector)
|
||||||
* mirror (Y) and flip list of items (undo/redo is made by mirror or flip items)
|
* mirror (Y) and flip list of items (undo/redo is made by mirror or flip items)
|
||||||
* so they are handled specifically.
|
* so they are handled specifically.
|
||||||
|
@ -101,7 +97,7 @@
|
||||||
/**
|
/**
|
||||||
* Function TestForExistingItem
|
* Function TestForExistingItem
|
||||||
* test if aItem exists somewhere in lists of items
|
* test if aItem exists somewhere in lists of items
|
||||||
* This is a function unsed by PutDataInPreviousState to be sure an item was not deleted
|
* This is a function used by PutDataInPreviousState to be sure an item was not deleted
|
||||||
* since an undo or redo.
|
* since an undo or redo.
|
||||||
* This could be possible:
|
* This could be possible:
|
||||||
* - if a call to SaveCopyInUndoList was forgotten in Pcbnew
|
* - if a call to SaveCopyInUndoList was forgotten in Pcbnew
|
||||||
|
@ -177,15 +173,6 @@ static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SwapData
|
|
||||||
* Used in undo / redo command:
|
|
||||||
* swap data between Item and a copy
|
|
||||||
* swapped data is data modified by edition, mainly sizes and texts
|
|
||||||
* so ONLY FEW values are swapped
|
|
||||||
* @param aItem = the item
|
|
||||||
* @param aImage = a copy of the item
|
|
||||||
*/
|
|
||||||
void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
|
void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
|
||||||
{
|
{
|
||||||
if( aItem == NULL || aImage == NULL )
|
if( aItem == NULL || aImage == NULL )
|
||||||
|
@ -287,16 +274,6 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
|
||||||
|
|
||||||
case PCB_TEXT_T:
|
case PCB_TEXT_T:
|
||||||
std::swap( *((TEXTE_PCB*)aItem), *((TEXTE_PCB*)aImage) );
|
std::swap( *((TEXTE_PCB*)aItem), *((TEXTE_PCB*)aImage) );
|
||||||
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Mirror, ( (TEXTE_PCB*) aImage )->m_Mirror );
|
|
||||||
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Size, ( (TEXTE_PCB*) aImage )->m_Size );
|
|
||||||
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Pos, ( (TEXTE_PCB*) aImage )->m_Pos );
|
|
||||||
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Thickness, ( (TEXTE_PCB*) aImage )->m_Thickness );
|
|
||||||
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Orient, ( (TEXTE_PCB*) aImage )->m_Orient );
|
|
||||||
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Text, ( (TEXTE_PCB*) aImage )->m_Text );
|
|
||||||
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Italic, ( (TEXTE_PCB*) aImage )->m_Italic );
|
|
||||||
// EXCHG( ( (TEXTE_PCB*) aItem )->m_Bold, ( (TEXTE_PCB*) aImage )->m_Bold );
|
|
||||||
// EXCHG( ( (TEXTE_PCB*) aItem )->m_HJustify, ( (TEXTE_PCB*) aImage )->m_HJustify );
|
|
||||||
// EXCHG( ( (TEXTE_PCB*) aItem )->m_VJustify, ( (TEXTE_PCB*) aImage )->m_VJustify );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_TARGET_T:
|
case PCB_TARGET_T:
|
||||||
|
@ -304,19 +281,7 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_DIMENSION_T:
|
case PCB_DIMENSION_T:
|
||||||
{
|
std::swap( *((DIMENSION*)aItem), *((DIMENSION*)aImage) );
|
||||||
std::swap( *((DIMENSION*)aItem), *((DIMENSION*)aImage) );
|
|
||||||
// wxString txt = ( (DIMENSION*) aItem )->GetText();
|
|
||||||
// ( (DIMENSION*) aItem )->SetText( ( (DIMENSION*) aImage )->GetText() );
|
|
||||||
// ( (DIMENSION*) aImage )->SetText( txt );
|
|
||||||
// EXCHG( ( (DIMENSION*) aItem )->m_Width, ( (DIMENSION*) aImage )->m_Width );
|
|
||||||
// EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Size, ( (DIMENSION*) aImage )->m_Text.m_Size );
|
|
||||||
// EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Pos, ( (DIMENSION*) aImage )->m_Text.m_Pos );
|
|
||||||
// EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Thickness,
|
|
||||||
// ( (DIMENSION*) aImage )->m_Text.m_Thickness );
|
|
||||||
// EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Mirror,
|
|
||||||
// ( (DIMENSION*) aImage )->m_Text.m_Mirror );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_ZONE_T:
|
case PCB_ZONE_T:
|
||||||
|
@ -327,18 +292,6 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function SaveCopyInUndoList
|
|
||||||
* Create a copy of the current board item, and put it in the undo list.
|
|
||||||
*
|
|
||||||
* aCommandType =
|
|
||||||
* UR_CHANGED
|
|
||||||
* UR_NEW
|
|
||||||
* UR_DELETED
|
|
||||||
* UR_MOVED
|
|
||||||
* UR_FLIPPED
|
|
||||||
* UR_ROTATED
|
|
||||||
*/
|
|
||||||
void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
|
void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
|
||||||
UNDO_REDO_T aCommandType,
|
UNDO_REDO_T aCommandType,
|
||||||
const wxPoint& aTransformPoint )
|
const wxPoint& aTransformPoint )
|
||||||
|
@ -364,7 +317,7 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
|
||||||
case UR_DELETED:
|
case UR_DELETED:
|
||||||
#ifdef USE_WX_OVERLAY
|
#ifdef USE_WX_OVERLAY
|
||||||
// Avoid to redraw when autoplacing
|
// Avoid to redraw when autoplacing
|
||||||
if( aItem->Type() == PCB_MODULE_T )
|
if( aItem->Type() == PCB_MODULE_T )
|
||||||
if( ((MODULE*)aItem)->GetFlags() & MODULE_to_PLACE )
|
if( ((MODULE*)aItem)->GetFlags() & MODULE_to_PLACE )
|
||||||
break;
|
break;
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
|
@ -400,12 +353,6 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SaveCopyInUndoList
|
|
||||||
* @param aItemsList = a PICKED_ITEMS_LIST of items to save
|
|
||||||
* @param aTypeCommand = type of comand ( UR_CHANGED, UR_NEW, UR_DELETED ...
|
|
||||||
* @param aTransformPoint - Transform items around this point.
|
|
||||||
*/
|
|
||||||
void PCB_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
|
void PCB_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
|
||||||
UNDO_REDO_T aTypeCommand,
|
UNDO_REDO_T aTypeCommand,
|
||||||
const wxPoint& aTransformPoint )
|
const wxPoint& aTransformPoint )
|
||||||
|
@ -478,15 +425,6 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function PutDataInPreviousState
|
|
||||||
* Used in undo or redo command.
|
|
||||||
* Put data pointed by List in the previous state, i.e. the state memorised by List
|
|
||||||
* @param aList = a PICKED_ITEMS_LIST pointer to the list of items to undo/redo
|
|
||||||
* @param aRedoCommand = a bool: true for redo, false for undo
|
|
||||||
* @param aRebuildRatsnet = a bool: true to rebuid ratsnet (normal use, and default), false
|
|
||||||
* to just retrieve las state (used in abort commands that do not need to rebuild ratsnest)
|
|
||||||
*/
|
|
||||||
void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand,
|
void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand,
|
||||||
bool aRebuildRatsnet )
|
bool aRebuildRatsnet )
|
||||||
{
|
{
|
||||||
|
@ -497,7 +435,8 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
||||||
// Undo in the reverse order of list creation: (this can allow stacked changes
|
// Undo in the reverse order of list creation: (this can allow stacked changes
|
||||||
// like the same item can be changes and deleted in the same complex command
|
// like the same item can be changes and deleted in the same complex command
|
||||||
|
|
||||||
bool build_item_list = true; // if true the list of esiting items must be rebuilt
|
bool build_item_list = true; // if true the list of existing items must be rebuilt
|
||||||
|
|
||||||
for( int ii = aList->GetCount()-1; ii >= 0 ; ii-- )
|
for( int ii = aList->GetCount()-1; ii >= 0 ; ii-- )
|
||||||
{
|
{
|
||||||
item = (BOARD_ITEM*) aList->GetPickedItem( ii );
|
item = (BOARD_ITEM*) aList->GetPickedItem( ii );
|
||||||
|
@ -508,19 +447,21 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
||||||
* - if a call to SaveCopyInUndoList was forgotten in Pcbnew
|
* - if a call to SaveCopyInUndoList was forgotten in Pcbnew
|
||||||
* - in zones outlines, when a change in one zone merges this zone with an other
|
* - in zones outlines, when a change in one zone merges this zone with an other
|
||||||
* This test avoids a Pcbnew crash
|
* This test avoids a Pcbnew crash
|
||||||
* Obviouly, this test is not made for deleted items
|
* Obviously, this test is not made for deleted items
|
||||||
*/
|
*/
|
||||||
UNDO_REDO_T status = aList->GetPickedItemStatus( ii );
|
UNDO_REDO_T status = aList->GetPickedItemStatus( ii );
|
||||||
|
|
||||||
if( status != UR_DELETED )
|
if( status != UR_DELETED )
|
||||||
{
|
{
|
||||||
if( build_item_list )
|
if( build_item_list )
|
||||||
// Build list of existing items, for integrity test
|
// Build list of existing items, for integrity test
|
||||||
TestForExistingItem( GetBoard(), NULL );
|
TestForExistingItem( GetBoard(), NULL );
|
||||||
|
|
||||||
build_item_list = false;
|
build_item_list = false;
|
||||||
|
|
||||||
if( !TestForExistingItem( GetBoard(), item ) )
|
if( !TestForExistingItem( GetBoard(), item ) )
|
||||||
{
|
{
|
||||||
// Remove this non existant item
|
// Remove this non existent item
|
||||||
aList->RemovePicker( ii );
|
aList->RemovePicker( ii );
|
||||||
ii++; // the current item was removed, ii points now the next item
|
ii++; // the current item was removed, ii points now the next item
|
||||||
// decrement it because it will be incremented later
|
// decrement it because it will be incremented later
|
||||||
|
@ -595,18 +536,12 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
||||||
if( not_found )
|
if( not_found )
|
||||||
wxMessageBox( wxT( "Incomplete undo/redo operation: some items not found" ) );
|
wxMessageBox( wxT( "Incomplete undo/redo operation: some items not found" ) );
|
||||||
|
|
||||||
// Rebuild pointers and rastnest that can be changed.
|
// Rebuild pointers and ratsnest that can be changed.
|
||||||
if( reBuild_ratsnest && aRebuildRatsnet )
|
if( reBuild_ratsnest && aRebuildRatsnet )
|
||||||
Compile_Ratsnest( NULL, true );
|
Compile_Ratsnest( NULL, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetBoardFromUndoList
|
|
||||||
* Undo the last edition:
|
|
||||||
* - Save the current board state in Redo list
|
|
||||||
* - Get an old version of the board state from Undo list
|
|
||||||
*/
|
|
||||||
void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event )
|
void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
if( GetScreen()->GetUndoCommandCount() <= 0 )
|
if( GetScreen()->GetUndoCommandCount() <= 0 )
|
||||||
|
@ -626,13 +561,6 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetBoardFromRedoList
|
|
||||||
* Redo the last edition:
|
|
||||||
* - Save the current board in Undo list
|
|
||||||
* - Get an old version of the board from Redo list
|
|
||||||
* @return none
|
|
||||||
*/
|
|
||||||
void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& event )
|
void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
if( GetScreen()->GetRedoCommandCount() == 0 )
|
if( GetScreen()->GetRedoCommandCount() == 0 )
|
||||||
|
@ -654,17 +582,6 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function ClearUndoORRedoList
|
|
||||||
* free the undo or redo list from List element
|
|
||||||
* Wrappers are deleted.
|
|
||||||
* datas pointed by wrappers are deleted if not in use in schematic
|
|
||||||
* i.e. when they are copy of a schematic item or they are no more in use (DELETED)
|
|
||||||
* @param aList = the UNDO_REDO_CONTAINER to clear
|
|
||||||
* @param aItemCount = the count of items to remove. < 0 for all items
|
|
||||||
* items (commands stored in list) are removed from the beginning of the list.
|
|
||||||
* So this function can be called to remove old commands
|
|
||||||
*/
|
|
||||||
void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
|
void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
|
||||||
{
|
{
|
||||||
if( aItemCount == 0 )
|
if( aItemCount == 0 )
|
||||||
|
|
|
@ -1,3 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
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
|
||||||
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 )
|
||||||
{
|
{
|
||||||
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 )
|
||||||
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 )
|
||||||
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 )
|
||||||
|
|
||||||
if( item == NULL )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SetCurItem( item );
|
|
||||||
|
|
||||||
switch( item->Type() )
|
|
||||||
{
|
{
|
||||||
case PCB_MODULE_T:
|
evt_type = ID_POPUP_ROTATE_BLOCK;
|
||||||
{
|
|
||||||
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
|
||||||
evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE;
|
|
||||||
|
|
||||||
if( aIdCommand == HK_FLIP_ITEM ) // move to other side
|
|
||||||
evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE;
|
|
||||||
}
|
}
|
||||||
break;
|
else
|
||||||
|
{
|
||||||
|
if( !itemCurrentlyEdited )
|
||||||
|
item = PcbGeneralLocateAndDisplay();
|
||||||
|
|
||||||
case PCB_TEXT_T:
|
if( item == NULL )
|
||||||
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
return false;
|
||||||
evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB;
|
|
||||||
else if( aIdCommand == HK_FLIP_ITEM )
|
|
||||||
evt_type = ID_POPUP_PCB_FLIP_TEXTEPCB;
|
|
||||||
|
|
||||||
break;
|
SetCurItem( item );
|
||||||
|
|
||||||
case PCB_MODULE_TEXT_T:
|
switch( item->Type() )
|
||||||
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
{
|
||||||
evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE;
|
case PCB_MODULE_T:
|
||||||
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
||||||
|
evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE;
|
||||||
|
|
||||||
break;
|
if( aIdCommand == HK_FLIP_ITEM ) // move to other side
|
||||||
|
evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
case PCB_TEXT_T:
|
||||||
break;
|
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;
|
||||||
|
|
||||||
|
case PCB_MODULE_TEXT_T:
|
||||||
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
||||||
|
evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( evt_type != 0 )
|
if( evt_type != 0 )
|
||||||
|
|
|
@ -1,3 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue