Commit 32c54e49 authored by charras's avatar charras

More about undo/redo in pcbnew

parent a6fc1329
......@@ -18,7 +18,7 @@
/* Routines Locales */
static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ExitTextModule( WinEDA_DrawPanel* Panel, wxDC* DC );
static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC );
/* local variables */
wxPoint MoveVector; // Move vector for move edge, exported to dialog_edit mod_text.cpp
......@@ -129,9 +129,8 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text )
/*************************************************************/
static void ExitTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
/*************************************************************/
/*
* Routine de sortie du menu edit texte module
* Si un texte est selectionne, ses coord initiales sont regenerees
......@@ -151,8 +150,12 @@ static void ExitTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
Text->Draw( Panel, DC, GR_XOR, MoveVector );
/* Redessin du Texte */
// Text->Draw( Panel, DC, GR_OR );
// If the text was moved (the move does not change internal data)
// it could be rotated while moving. So set old value for orientation
if ( (Text->m_Flags & IS_MOVED) )
Text->m_Orient = TextInitialOrientation;
/* Redraw the text */
Panel->PostDirtyRect( Text->GetBoundingBox() );
// leave it at (0,0) so we can use it Rotate when not moving.
......@@ -191,7 +194,7 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
SetCurItem( Text );
DrawPanel->ManageCurseur = Show_MoveTexte_Module;
DrawPanel->ForceCloseManageCurseur = ExitTextModule;
DrawPanel->ForceCloseManageCurseur = AbortMoveTextModule;
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
}
......@@ -209,20 +212,19 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
{
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
Text->m_Pos = GetScreen()->m_Curseur;
/* mise a jour des coordonnes relatives a l'ancre */
MODULE* Module = (MODULE*) Text->GetParent();
if( Module )
{
// Prepare undo command for Board Editor:
// Prepare undo command (a rotation can be made while moving)
EXCHG(Text->m_Orient, TextInitialOrientation);
if( m_Ident == PCB_FRAME )
{
EXCHG(Text->m_Pos, TextInitialPosition);
EXCHG(Text->m_Orient, TextInitialOrientation);
SaveCopyInUndoList(Module, UR_CHANGED);
EXCHG(Text->m_Pos, TextInitialPosition);
EXCHG(Text->m_Orient, TextInitialOrientation);
}
else
SaveCopyInUndoList(Module, UR_MODEDIT);
EXCHG(Text->m_Orient, TextInitialOrientation);
Text->m_Pos = GetScreen()->m_Curseur; // Set the new position for text
wxPoint textRelPos = Text->m_Pos - Module->m_Pos;
RotatePoint( &textRelPos, -Module->m_Orient );
Text->m_Pos0 = textRelPos;
......@@ -234,6 +236,8 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
/* Redessin du Texte */
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
}
else
Text->m_Pos = GetScreen()->m_Curseur;
}
// leave it at (0,0) so we can use it Rotate when not moving.
......
......@@ -33,7 +33,6 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
switch( DrawStruct->Type() )
{
case TYPE_TEXTE_MODULE:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, DC );
break;
......@@ -64,9 +63,9 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawStruct = GetCurItem();
if( !DrawStruct || (DrawStruct->m_Flags == 0) )
{
if( !wxGetKeyState(WXK_SHIFT) && !wxGetKeyState(WXK_ALT) &&
!wxGetKeyState(WXK_CONTROL) )
DrawStruct = ModeditLocateAndDisplay();
if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT )
&& !wxGetKeyState( WXK_CONTROL ) )
DrawStruct = ModeditLocateAndDisplay();
SetCurItem( DrawStruct );
}
......@@ -90,7 +89,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
shape = S_ARC;
SetCurItem(
Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) );
Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) );
}
else if( (DrawStruct->m_Flags & IS_NEW) )
{
......@@ -120,7 +119,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawStruct = ModeditLocateAndDisplay();
if( DrawStruct == NULL || (DrawStruct->m_Flags != 0) )
break;
if( DrawStruct->Type() != TYPE_MODULE) //GetBoard()->m_Modules ) // Cannot delete the module itself
if( DrawStruct->Type() != TYPE_MODULE ) //GetBoard()->m_Modules ) // Cannot delete the module itself
{
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
RemoveStruct( DrawStruct );
......@@ -131,19 +130,20 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_MODEDIT_PLACE_ANCHOR:
{
MODULE * module = GetBoard()->m_Modules;
module->m_Flags = 0;
MODULE* module = GetBoard()->m_Modules;
module->m_Flags = 0;
SaveCopyInUndoList( module, UR_MODEDIT );
Place_Ancre( module ); // set the new relatives internal coordinates of items
GetScreen()->m_Curseur = wxPoint( 0, 0 );
Recadre_Trace( TRUE );
// Replace the module in position 0, to recalculate absolutes coordinates of items
module->SetPosition( wxPoint(0,0) );
module->SetPosition( wxPoint( 0, 0 ) );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetCurItem( NULL );
DrawPanel->Refresh();
}
break;
break;
case ID_TEXT_COMMENT_BUTT:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
......@@ -179,10 +179,10 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
* After this menu is built, the standart ZOOM menu is added
*/
{
BOARD_ITEM* DrawStruct = GetCurItem();
wxString msg;
bool append_set_width = FALSE;
bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
BOARD_ITEM* DrawStruct = GetCurItem();
wxString msg;
bool append_set_width = FALSE;
bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
// Simple localisation des elements si possible
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
......@@ -290,11 +290,14 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
}
ADD_MENUITEM( PopMenu, ID_POPUP_PCB_ROTATE_TEXTMODULE,
_( "Rotate Text Mod." ), rotate_field_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_TEXTMODULE,
_( "Edit Text Mod." ), edit_text_xpm );
if( ( (TEXTE_MODULE*) DrawStruct )->m_Type == TEXT_is_DIVERS )
ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_TEXTMODULE,
_( "Delete Text Mod." ), delete_text_xpm );
if( !flags )
{
ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_TEXTMODULE,
_( "Edit Text Mod." ), edit_text_xpm );
if( ( (TEXTE_MODULE*) DrawStruct )->m_Type == TEXT_is_DIVERS )
ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_TEXTMODULE,
_( "Delete Text Mod." ), delete_text_xpm );
}
break;
case TYPE_EDGE_MODULE:
......@@ -323,7 +326,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
_( "Delete edge" ), delete_xpm );
append_set_width = TRUE;
}
break;
break;
case TYPE_DRAWSEGMENT:
case TYPE_TEXTE:
......@@ -376,9 +379,9 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
* If the double clicked item is editable: call the corresponding editor.
*/
{
BOARD_ITEM* DrawStruct = GetCurItem();
wxPoint pos = GetPosition();
wxClientDC dc( DrawPanel );
BOARD_ITEM* DrawStruct = GetCurItem();
wxPoint pos = GetPosition();
wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext( &dc );
......@@ -414,7 +417,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
if( ret > 0 )
DrawPanel->Refresh();
}
break;
break;
case TYPE_TEXTE_MODULE:
InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc );
......
......@@ -176,10 +176,11 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST,
_( "Move Drawing" ), move_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_DRAWING, _( "Edit Drawing" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING, _( "Delete Drawing" ), delete_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING, _(
"Delete Drawing" ), delete_xpm );
if( item->GetLayer() > LAST_COPPER_LAYER )
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING_LAYER,
_( "Delete All Drawing on Layer" ), delete_body_xpm );
_( "Delete All Drawing on Layer" ), delete_body_xpm );
}
break;
......@@ -220,7 +221,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_COTATION,
_( "Edit Dimension" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_COTATION,
_( "Delete Dimension" ), delete_xpm );
_( "Delete Dimension" ), delete_xpm );
}
break;
......@@ -707,8 +708,9 @@ void WinEDA_PcbFrame::createPopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* m
ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_ROTATE_TEXTMODULE,
_( "Rotate" ), rotate_field_xpm );
ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_EDIT_TEXTMODULE,
_( "Edit" ), edit_text_xpm );
if( !flags )
ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_EDIT_TEXTMODULE,
_( "Edit" ), edit_text_xpm );
if( !flags && FpText->m_Type == TEXT_is_DIVERS ) // Graphic texts can be deleted only if are not currently edited
{
......@@ -891,4 +893,3 @@ static wxMenu* Append_Track_Width_List()
return trackwidth_menu;
}
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