Commit aa35b980 authored by charras's avatar charras

Eeschema: fixed some issues in undo/redo and ESC commands related to hierarchical sheets

parent be946a75
...@@ -92,8 +92,7 @@ void WinEDA_SchematicFrame::StartMoveBusEntry( SCH_BUS_ENTRY* BusEntry, ...@@ -92,8 +92,7 @@ void WinEDA_SchematicFrame::StartMoveBusEntry( SCH_BUS_ENTRY* BusEntry,
if( BusEntry == NULL ) if( BusEntry == NULL )
return; return;
if( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save if( (BusEntry->m_Flags & IS_NEW) == 0 ) // not already in edit, save shape
// shape */
{ {
delete g_ItemToUndoCopy; delete g_ItemToUndoCopy;
g_ItemToUndoCopy = BusEntry->GenCopy(); g_ItemToUndoCopy = BusEntry->GenCopy();
......
...@@ -208,6 +208,22 @@ void SCH_SHEET::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -208,6 +208,22 @@ void SCH_SHEET::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
return; return;
} }
} }
else /* save old text in undo list */
{
if( g_ItemToUndoCopy && ( g_ItemToUndoCopy->Type() == Type() ) )
{
/* restore old values and save new ones */
SwapData( (SCH_SHEET*) g_ItemToUndoCopy );
/* save in undo list */
frame->SaveCopyInUndoList( this, UR_CHANGED );
/* restore new values */
SwapData( (SCH_SHEET*) g_ItemToUndoCopy );
SAFE_DELETE( g_ItemToUndoCopy );
}
}
SCH_ITEM::Place( frame, DC ); //puts it on the EEDrawList. SCH_ITEM::Place( frame, DC ); //puts it on the EEDrawList.
if( isnew ) if( isnew )
......
...@@ -551,7 +551,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -551,7 +551,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
GetScreen()->SetCurItem( (SCH_ITEM*) DrawStruct ); GetScreen()->SetCurItem( (SCH_ITEM*) DrawStruct );
// Create the events for moving a component or other schematic item // Create the events for moving a component or other schematic item
wxCommandEvent eventMoveComponent( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEvent eventMoveOrDragComponent( wxEVT_COMMAND_TOOL_CLICKED,
HK_Descr->m_IdMenuEvent ); HK_Descr->m_IdMenuEvent );
wxCommandEvent eventMoveItem( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEvent eventMoveItem( wxEVT_COMMAND_TOOL_CLICKED,
ID_POPUP_SCH_MOVE_ITEM_REQUEST ); ID_POPUP_SCH_MOVE_ITEM_REQUEST );
...@@ -564,22 +564,24 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -564,22 +564,24 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
{ {
// select the correct event for moving an schematic object // select the correct event for moving an schematic object
// and add it to the event queue // and add it to the event queue
case DRAW_SHEET_STRUCT_TYPE:
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
wxPostEvent( this, eventMoveComponent ); wxPostEvent( this, eventMoveOrDragComponent );
break; break;
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL: case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL: case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
case DRAW_SHEET_STRUCT_TYPE:
case DRAW_PART_TEXT_STRUCT_TYPE: case DRAW_PART_TEXT_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE: case DRAW_BUSENTRY_STRUCT_TYPE:
wxPostEvent( this, eventMoveItem ); if( HK_Descr->m_Idcommand != HK_DRAG )
wxPostEvent( this, eventMoveItem );
break; break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
wxPostEvent( this, eventMovePinsheet ); if( HK_Descr->m_Idcommand != HK_DRAG )
wxPostEvent( this, eventMovePinsheet );
break; break;
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
......
...@@ -439,11 +439,11 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel ) ...@@ -439,11 +439,11 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
msg = AddHotkeyName( _( "Rotate Hierarchical Label" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Rotate Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_ROTATE ); HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT,
_( "Rotate Hierarchical Label" ), rotate_glabel_xpm ); msg, rotate_glabel_xpm );
msg = AddHotkeyName( _( "Edit Hierarchical Label" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Edit Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_EDIT ); HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
_( "Edit Hierarchical Label" ), edit_text_xpm ); msg, edit_text_xpm );
msg = AddHotkeyName( _( "Delete Hierarchical Label" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Delete Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_DELETE ); HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
...@@ -678,6 +678,11 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ) ...@@ -678,6 +678,11 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM ); s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
msg, move_sheet_xpm ); msg, move_sheet_xpm );
msg = AddHotkeyName( _( "Drag Sheet" ), s_Schematic_Hokeys_Descr,
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST,
msg, move_sheet_xpm );
} }
if( Sheet->m_Flags ) if( Sheet->m_Flags )
......
...@@ -181,79 +181,92 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, ...@@ -181,79 +181,92 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
} }
/* Routine to create a new copy of given struct. /** function DuplicateStruct
* Routine to create a new copy of given struct.
* The new object is not put in draw list (not linked) * The new object is not put in draw list (not linked)
* @param aDrawStruct = the SCH_ITEM to duplicate
* @param aClone (default = false)
* if true duplicate also some parameters that must be unique
* (timestamp and sheet name)
* aClone must be false. use true only is undo/redo duplications
*/ */
SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct ) SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone )
{ {
SCH_ITEM* NewDrawStruct = NULL; SCH_ITEM* NewDrawStruct = NULL;
if( DrawStruct == NULL ) if( aDrawStruct == NULL )
{ {
wxMessageBox( wxT( "DuplicateStruct error: NULL struct" ) ); wxMessageBox( wxT( "DuplicateStruct error: NULL struct" ) );
return NULL; return NULL;
} }
switch( DrawStruct->Type() ) switch( aDrawStruct->Type() )
{ {
case DRAW_POLYLINE_STRUCT_TYPE: case DRAW_POLYLINE_STRUCT_TYPE:
NewDrawStruct = ( (SCH_POLYLINE*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_POLYLINE*) aDrawStruct )->GenCopy();
break; break;
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
NewDrawStruct = ( (SCH_LINE*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_LINE*) aDrawStruct )->GenCopy();
break; break;
case DRAW_BUSENTRY_STRUCT_TYPE: case DRAW_BUSENTRY_STRUCT_TYPE:
NewDrawStruct = ( (SCH_BUS_ENTRY*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_BUS_ENTRY*) aDrawStruct )->GenCopy();
break; break;
case DRAW_JUNCTION_STRUCT_TYPE: case DRAW_JUNCTION_STRUCT_TYPE:
NewDrawStruct = ( (SCH_JUNCTION*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_JUNCTION*) aDrawStruct )->GenCopy();
break; break;
case TYPE_SCH_MARKER: case TYPE_SCH_MARKER:
NewDrawStruct = ( (SCH_MARKER*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_MARKER*) aDrawStruct )->GenCopy();
break; break;
case DRAW_NOCONNECT_STRUCT_TYPE: case DRAW_NOCONNECT_STRUCT_TYPE:
NewDrawStruct = ( (SCH_NO_CONNECT*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_NO_CONNECT*) aDrawStruct )->GenCopy();
break; break;
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
NewDrawStruct = ( (SCH_TEXT*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_TEXT*) aDrawStruct )->GenCopy();
break; break;
case TYPE_SCH_LABEL: case TYPE_SCH_LABEL:
NewDrawStruct = ( (SCH_LABEL*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_LABEL*) aDrawStruct )->GenCopy();
break; break;
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
NewDrawStruct = ( (SCH_HIERLABEL*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_HIERLABEL*) aDrawStruct )->GenCopy();
break; break;
case TYPE_SCH_GLOBALLABEL: case TYPE_SCH_GLOBALLABEL:
NewDrawStruct = ( (SCH_GLOBALLABEL*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_GLOBALLABEL*) aDrawStruct )->GenCopy();
break; break;
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
NewDrawStruct = ( (SCH_COMPONENT*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_COMPONENT*) aDrawStruct )->GenCopy();
break; break;
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
NewDrawStruct = ( (SCH_SHEET*) DrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_SHEET*) aDrawStruct )->GenCopy();
if ( aClone )
{
((SCH_SHEET*)NewDrawStruct)->m_SheetName = ((SCH_SHEET*)aDrawStruct)->m_SheetName;
}
break; break;
default: default:
{ {
wxString msg; wxString msg;
msg << wxT( "DuplicateStruct error: unexpected StructType " ) msg << wxT( "DuplicateStruct error: unexpected StructType " )
<< DrawStruct->Type() << wxT( " " ) << DrawStruct->GetClass(); << aDrawStruct->Type() << wxT( " " ) << aDrawStruct->GetClass();
wxMessageBox( msg ); wxMessageBox( msg );
} }
break; break;
} }
NewDrawStruct->m_Image = DrawStruct; if ( aClone )
NewDrawStruct->m_TimeStamp = aDrawStruct->m_TimeStamp;
NewDrawStruct->m_Image = aDrawStruct;
return NewDrawStruct; return NewDrawStruct;
} }
...@@ -71,11 +71,21 @@ bool LibItemInBox( int x1, int y1, int x2, int y2, ...@@ -71,11 +71,21 @@ bool LibItemInBox( int x1, int y1, int x2, int y2,
/************/ /************/
/* BLOCK.CPP */ /* BLOCK.CPP */
/************/ /************/
SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct );
void DeleteStruct( WinEDA_DrawPanel* panel, void DeleteStruct( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
SCH_ITEM* DrawStruct ); SCH_ITEM* DrawStruct );
// operations_on_item_lists.cpp
/** function DuplicateStruct
* Routine to create a new copy of given struct.
* @param aDrawStruct = the SCH_ITEM to duplicate
* @param aClone (defualt = true)
* if true duplicate also some parameters that must be unique
* (timestamp and sheet name)
* aClone must be false. use true only is undo/redo duplications
*/
SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct, bool aClone = false );
/*************/ /*************/
/* LOCATE.CPP */ /* LOCATE.CPP */
/*************/ /*************/
......
...@@ -397,20 +397,20 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -397,20 +397,20 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DRAG_CMP_REQUEST: case ID_POPUP_SCH_DRAG_CMP_REQUEST:
case ID_POPUP_SCH_MOVE_CMP_REQUEST: case ID_POPUP_SCH_MOVE_CMP_REQUEST:
// Ensure the struct is a component (could be a struct of a // Ensure the struct is a component (could be a struct of a
// component, like Field, text..) // component, like Field, text..) or a hierachical sheet
if( screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT ) if( (screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT)
&& (screen->GetCurItem()->Type() != DRAW_SHEET_STRUCT_TYPE) )
screen->SetCurItem( LocateSmallestComponent( screen ) ); screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL ) if( screen->GetCurItem() == NULL )
break; break;
// fall through
case ID_POPUP_SCH_MOVE_ITEM_REQUEST: case ID_POPUP_SCH_MOVE_ITEM_REQUEST:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( id == ID_POPUP_SCH_DRAG_CMP_REQUEST ) if( id == ID_POPUP_SCH_DRAG_CMP_REQUEST )
{ {
// The easiest way to handle a drag component is to simulate a // The easiest way to handle a drag component or sheet command
// block drag command // is to simulate a block drag command
if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK ) if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
{ {
if( !HandleBlockBegin( &dc, BLOCK_DRAG, if( !HandleBlockBegin( &dc, BLOCK_DRAG,
......
...@@ -180,35 +180,6 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage ) ...@@ -180,35 +180,6 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
} }
/** function CloneStruct
* must be used only in undo/redo functions
*
* Routine to create a new copy of given schatic object.
* It does the same job as DuplicateStruct, but
* but clone time stamp and sheet name when cloning a SCH_SHEET objects
* (because time stamp and sheets name must be unique
* DuplicateStruct does not copy these members
*/
static SCH_ITEM* CloneStruct( SCH_ITEM* aDrawStruct )
{
SCH_ITEM* item = DuplicateStruct( aDrawStruct );
if( item == NULL )
return NULL;
item->m_TimeStamp = aDrawStruct->m_TimeStamp;
switch( item->Type() )
{
case DRAW_SHEET_STRUCT_TYPE:
((SCH_SHEET*)item)->m_SheetName = ((SCH_SHEET*)aDrawStruct)->m_SheetName;
break;
default:
break;
}
return item;
}
/** function SaveCopyInUndoList /** function SaveCopyInUndoList
* Create a copy of the current schematic item, and put it in the undo list. * Create a copy of the current schematic item, and put it in the undo list.
...@@ -260,7 +231,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem, ...@@ -260,7 +231,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem,
switch( aCommandType ) switch( aCommandType )
{ {
case UR_CHANGED: /* Create a copy of item */ case UR_CHANGED: /* Create a copy of item */
CopyOfItem = CloneStruct( aItem ); CopyOfItem = DuplicateStruct( aItem, true );
itemWrapper.m_Link = CopyOfItem; itemWrapper.m_Link = CopyOfItem;
if ( CopyOfItem ) if ( CopyOfItem )
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
...@@ -330,7 +301,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -330,7 +301,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
* If this link is not null, the copy is already done * If this link is not null, the copy is already done
*/ */
if( commandToUndo->GetPickedItemLink(ii) == NULL ) if( commandToUndo->GetPickedItemLink(ii) == NULL )
commandToUndo->SetPickedItemLink( CloneStruct( item ), ii ); commandToUndo->SetPickedItemLink( DuplicateStruct( item, true ), ii );
wxASSERT( commandToUndo->GetPickedItemLink(ii) ); wxASSERT( commandToUndo->GetPickedItemLink(ii) );
break; break;
......
...@@ -105,6 +105,9 @@ structures and cannot be undone.\nOk to continue renaming?" ); ...@@ -105,6 +105,9 @@ structures and cannot be undone.\nOk to continue renaming?" );
aSheet->ChangeFileName( this, fileName.GetFullPath() ); aSheet->ChangeFileName( this, fileName.GetFullPath() );
} }
} }
else
SaveCopyInUndoList( aSheet, UR_CHANGED );
aSheet->m_FileNameSize = ReturnValueFromString( g_UnitMetric, aSheet->m_FileNameSize = ReturnValueFromString( g_UnitMetric,
dlg.GetFileNameTextSize(), dlg.GetFileNameTextSize(),
...@@ -202,6 +205,7 @@ static void ExitSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC ) ...@@ -202,6 +205,7 @@ static void ExitSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC )
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
aPanel->ManageCurseur = NULL; aPanel->ManageCurseur = NULL;
aPanel->ForceCloseManageCurseur = NULL; aPanel->ForceCloseManageCurseur = NULL;
SAFE_DELETE( g_ItemToUndoCopy );
} }
...@@ -213,6 +217,7 @@ static void ExitSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC ) ...@@ -213,6 +217,7 @@ static void ExitSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC )
SCH_SHEET* WinEDA_SchematicFrame::CreateSheet( wxDC* aDC ) SCH_SHEET* WinEDA_SchematicFrame::CreateSheet( wxDC* aDC )
{ {
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
SAFE_DELETE( g_ItemToUndoCopy );
SCH_SHEET* sheet = new SCH_SHEET( GetScreen()->m_Curseur ); SCH_SHEET* sheet = new SCH_SHEET( GetScreen()->m_Curseur );
...@@ -273,6 +278,12 @@ void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -273,6 +278,12 @@ void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
DrawPanel->ManageCurseur = MoveOrResizeSheet; DrawPanel->ManageCurseur = MoveOrResizeSheet;
DrawPanel->ForceCloseManageCurseur = ExitSheet; DrawPanel->ForceCloseManageCurseur = ExitSheet;
DrawPanel->ManageCurseur( DrawPanel, aDC, true ); DrawPanel->ManageCurseur( DrawPanel, aDC, true );
if( (aSheet->m_Flags & IS_NEW) == 0 ) // not already in edit, save a copy for undo/redo
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = DuplicateStruct( aSheet, true );
}
} }
...@@ -291,4 +302,10 @@ void WinEDA_SchematicFrame::StartMoveSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -291,4 +302,10 @@ void WinEDA_SchematicFrame::StartMoveSheet( SCH_SHEET* aSheet, wxDC* aDC )
DrawPanel->ForceCloseManageCurseur = ExitSheet; DrawPanel->ForceCloseManageCurseur = ExitSheet;
DrawPanel->ManageCurseur( DrawPanel, aDC, true ); DrawPanel->ManageCurseur( DrawPanel, aDC, true );
DrawPanel->CursorOn( aDC ); DrawPanel->CursorOn( aDC );
if( (aSheet->m_Flags & IS_NEW) == 0 ) // not already in edit, save a copy for undo/redo
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = DuplicateStruct( aSheet, true );
}
} }
...@@ -168,9 +168,14 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -168,9 +168,14 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
{ {
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent(); SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
SAFE_DELETE( g_ItemToUndoCopy );
int flags = m_Flags;
m_Flags = 0;
if( m_Flags & IS_NEW ) if( flags & IS_NEW )
{ {
frame->SaveCopyInUndoList( Sheet, UR_CHANGED );
if( Sheet->m_Label == NULL ) if( Sheet->m_Label == NULL )
Sheet->m_Label = this; Sheet->m_Label = this;
else else
...@@ -187,11 +192,20 @@ void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -187,11 +192,20 @@ void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
} }
} }
} }
else // pin sheet was existing and only moved
{
wxPoint tmp = m_Pos;
m_Pos = s_InitialPosition;
m_Edge = 0;
if( m_Pos.x > ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) )
m_Edge = 1;
frame->SaveCopyInUndoList( Sheet, UR_CHANGED );
m_Pos = tmp;
}
m_Flags = 0;
m_Pos.x = Sheet->m_Pos.x; m_Pos.x = Sheet->m_Pos.x;
m_Edge = 0; m_Edge = 0;
if( frame->GetScreen()->m_Curseur.x > ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) ) if( frame->GetScreen()->m_Curseur.x > ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) )
{ {
m_Edge = 1; m_Edge = 1;
...@@ -350,11 +364,13 @@ SCH_SHEET_PIN* WinEDA_SchematicFrame::Import_PinSheet( SCH_SHEET* Sheet, ...@@ -350,11 +364,13 @@ SCH_SHEET_PIN* WinEDA_SchematicFrame::Import_PinSheet( SCH_SHEET* Sheet,
if( (HLabel == NULL ) || SheetLabel ) if( (HLabel == NULL ) || SheetLabel )
{ {
DisplayError( this, _( "No new hierarchical labels found" ), 10 ); DisplayInfoMessage( this, _( "No new hierarchical labels found" ), 10 );
return NULL; return NULL;
} }
OnModify( ); OnModify( );
SAFE_DELETE( g_ItemToUndoCopy );
SaveCopyInUndoList( Sheet, UR_CHANGED );
NewSheetLabel = new SCH_SHEET_PIN( Sheet, wxPoint( 0, 0 ), HLabel->m_Text ); NewSheetLabel = new SCH_SHEET_PIN( Sheet, wxPoint( 0, 0 ), HLabel->m_Text );
NewSheetLabel->m_Flags = IS_NEW; NewSheetLabel->m_Flags = IS_NEW;
......
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