Commit 5699ee3b authored by charras's avatar charras

More about pcbnew undo/redo

parent d9ea63a8
......@@ -34,7 +34,7 @@
ITEM_PICKER::ITEM_PICKER( EDA_BaseStruct* aItem, UndoRedoOpType aUndoRedoStatus )
{
m_UndoRedoStatus = aUndoRedoStatus;
m_PickedItem = aItem;
m_PickedItem = aItem;
m_PickedItemType = TYPE_NOT_INIT;
m_Link = NULL;
}
......@@ -50,12 +50,20 @@ PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST()
}
void PICKED_ITEMS_LIST::PushItem( ITEM_PICKER& aItem)
/** PushItem
* push a picker to the top of the list
* @param aItem = picker to push
*/
void PICKED_ITEMS_LIST::PushItem( ITEM_PICKER& aItem )
{
m_ItemsList.push_back( aItem );
}
/** PopItem
* @return the picker from the top of the list
* the picker is removed from the list
*/
ITEM_PICKER PICKED_ITEMS_LIST::PICKED_ITEMS_LIST::PopItem()
{
ITEM_PICKER item;
......@@ -69,19 +77,87 @@ ITEM_PICKER PICKED_ITEMS_LIST::PICKED_ITEMS_LIST::PopItem()
}
void PICKED_ITEMS_LIST::PICKED_ITEMS_LIST::ClearItemsList()
/* delete only the list of EDA_BaseStruct * pointers, NOT the pointed data itself
/** Function ClearItemsList
* delete only the list of pickers, NOT the picked data itself
*/
void PICKED_ITEMS_LIST::PICKED_ITEMS_LIST::ClearItemsList()
{
m_ItemsList.clear();
}
/** Function ClearListAndDeleteItems
* delete the list of pickers, AND the data pointed
* by m_PickedItem or m_PickedItemLink, according to the type of undo/redo command recorded
*/
void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
{
for(unsigned ii = 0; ii < m_ItemsList.size(); ii++ )
delete m_ItemsList[ii].m_PickedItem;
m_ItemsList.clear();
bool show_error_message = true;
// Delete items is they are not flagged UR_NEW, or if this is a block operation
while( GetCount() > 0 )
{
ITEM_PICKER wrapper = PopItem();
if( wrapper.m_PickedItem == NULL ) // No more item in list.
break;
switch( wrapper.m_UndoRedoStatus )
{
case UR_UNSPECIFIED:
if( show_error_message )
wxMessageBox( wxT( "ClearUndoORRedoList() error: UR_UNSPECIFIED command type" ) );
show_error_message = false;
break;
case UR_WIRE_IMAGE:
{
// Specific to eeschema: a linked list of wires is stored.
// the wrapper picks only the first item (head of list), and is owner of all picked items
EDA_BaseStruct* item = wrapper.m_PickedItem;
while( item )
{
// Delete old copy of wires
EDA_BaseStruct* nextitem = item->Next();
delete item;
item = nextitem;
}
}
break;
case UR_MOVED:
case UR_FLIPPED:
case UR_MIRRORED_X:
case UR_MIRRORED_Y:
case UR_ROTATED:
case UR_ROTATED_CLOCKWISE:
case UR_NEW: // Do nothing, items are in use, the picker is not owner of items
break;
case UR_CHANGED:
delete wrapper.m_Link; // the picker is owner of this item
break;
case UR_DELETED: // the picker is owner of this item
case UR_LIBEDIT: /* Libedit save always a copy of the current item
* So, the picker is always owner of the picked item
*/
case UR_MODEDIT: /* Specific to the module editor
* (modedit creates a full copy of the current module when changed),
* and the picker is owner of this item
*/
delete wrapper.m_PickedItem;
break;
default:
{
wxString msg;
msg.Printf( wxT(
"ClearUndoORRedoList() error: unknown command type %d" ),
wrapper.m_UndoRedoStatus );
wxMessageBox( msg );
}
break;
}
}
}
......@@ -94,12 +170,14 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx )
{
ITEM_PICKER picker;
if( aIdx < m_ItemsList.size() )
picker = m_ItemsList[aIdx];
return picker;
}
/** function GetPickedItem
* @return a pointer to the picked item, or null if does not exist
* @param aIdx = index of the picked item in the picked list
......@@ -181,11 +259,13 @@ bool PICKED_ITEMS_LIST::SetPickedItemLink( EDA_BaseStruct* aLink, unsigned aIdx
* @param aIdx = index of the picker in the picked list
* @return true if the picker exists, or false if does not exist
*/
bool PICKED_ITEMS_LIST::SetPickedItem( EDA_BaseStruct* aItem, UndoRedoOpType aStatus, unsigned aIdx )
bool PICKED_ITEMS_LIST::SetPickedItem( EDA_BaseStruct* aItem,
UndoRedoOpType aStatus,
unsigned aIdx )
{
if( aIdx < m_ItemsList.size() )
{
m_ItemsList[aIdx].m_PickedItem = aItem;
m_ItemsList[aIdx].m_PickedItem = aItem;
m_ItemsList[aIdx].m_UndoRedoStatus = aStatus;
return true;
}
......@@ -225,17 +305,19 @@ bool PICKED_ITEMS_LIST::RemovePickedItem( unsigned aIdx )
return true;
}
/** Function CopyList
* copy all data from aSource
* Items picked are not copied. just pointer on them are copied
*/
void PICKED_ITEMS_LIST::CopyList(const PICKED_ITEMS_LIST & aSource)
void PICKED_ITEMS_LIST::CopyList( const PICKED_ITEMS_LIST& aSource )
{
ITEM_PICKER picker;
for(unsigned ii = 0; ii < aSource.GetCount(); ii++ )
for( unsigned ii = 0; ii < aSource.GetCount(); ii++ )
{
picker = aSource.m_ItemsList[ii];
PushItem(picker);
PushItem( picker );
}
}
......
......@@ -290,12 +290,13 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
itemWrapper.m_PickedItem = item;
itemWrapper.m_PickedItemType = item->Type();
itemWrapper.m_UndoRedoStatus = command;
itemWrapper.m_Link = aItemsList.GetPickedItemLink( ii );
switch( command )
{
case UR_CHANGED: /* Create a copy of item */
CopyOfItem = DuplicateStruct( item );
itemWrapper.m_Link = CopyOfItem;
if ( CopyOfItem )
if( itemWrapper.m_Link == NULL )
itemWrapper.m_Link = DuplicateStruct( item );
if ( itemWrapper.m_Link )
commandToUndo->PushItem( itemWrapper );
break;
......@@ -495,56 +496,7 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
// Delete items is they are not flagged UR_NEW, or if this is a block operation
while( 1 )
{
ITEM_PICKER wrapper = curr_cmd->PopItem();
EDA_BaseStruct* item = wrapper.m_PickedItem;
if( item == NULL ) // No more item in list.
break;
switch( wrapper.m_UndoRedoStatus )
{
case UR_WIRE_IMAGE:
while( item )
{ // Delete old copy of wires
EDA_BaseStruct* nextitem = item->Next();
delete item;
item = nextitem;
}
break;
case UR_MOVED:
case UR_MIRRORED_X:
case UR_MIRRORED_Y:
case UR_ROTATED:
case UR_NEW: // Do nothing, items are in use
break;
case UR_LIBEDIT: // Libedit save always a copy of the current item
delete item; // So, the picker is always owner of the picked item
break;
case UR_DELETED:
delete item; // Delete the picked item, because it was deleted from schematic
break;
case UR_CHANGED:
delete wrapper.m_Link; // Delete the copy of item (the item is itself in use)
break;
default:
{
wxString msg;
msg.Printf(
wxT("ClearUndoORRedoList() error: unexpected undo/redo type %d"),
wrapper.m_UndoRedoStatus );
wxMessageBox( msg );
break;
}
}
}
curr_cmd->ClearListAndDeleteItems();
delete curr_cmd; // Delete command
}
}
......@@ -58,7 +58,8 @@ enum UndoRedoOpType {
UR_MOVED, // moved item, undo by move it
UR_MIRRORED_X, // mirrored item, undo by mirror X
UR_MIRRORED_Y, // mirrored item, undo by mirror Y
UR_ROTATED, // Rotated item, undo by rotating it
UR_ROTATED, // Rotated item (counterclockwise), undo by rotating it
UR_ROTATED_CLOCKWISE, // Rotated item (clockwise), undo by rotating it
UR_FLIPPED, // flipped (board items only), undo by flipping it
UR_WIRE_IMAGE, // Specific to eeschema: handle wires changes
UR_MODEDIT, // Specific to the module editor (modedit creates a full copy of the current module when changed)
......@@ -104,19 +105,33 @@ private:
public:
PICKED_ITEMS_LIST();
~PICKED_ITEMS_LIST();
/** PushItem
* push a picker to the top of the list
* @param aItem = picker to push
*/
void PushItem( ITEM_PICKER& aItem );
/** PopItem
* @return the picker from the top of the list
* the picker is removed from the list
*/
ITEM_PICKER PopItem();
/** Function ClearItemsList
* delete only the list of EDA_BaseStruct * pointers, NOT the pointed data itself
* delete only the list of pickers, NOT the picked data itself
*/
void ClearItemsList();
/** Function ClearListAndDeleteItems
* delete only the list of EDA_BaseStruct * pointers, AND the data pinted by m_Item
* delete the list of pickers, AND the data pointed
* by m_PickedItem or m_PickedItemLink, according to the type of undo/redo command recorded
*/
void ClearListAndDeleteItems();
/** function GetCount()
* @return the count of pickers stored in this list
*/
unsigned GetCount() const
{
return m_ItemsList.size();
......
......@@ -178,9 +178,6 @@ public:
// Gestion des modules
void InstallModuleOptionsFrame( MODULE* Module, wxDC * DC );
MODULE* Copie_Module( MODULE* module );
MODULE* Exchange_Module( wxWindow* winaff,
MODULE* old_module,
MODULE* new_module );
/** Function Save_Module_In_Library
* Save in an existing library a given footprint
......@@ -207,7 +204,6 @@ public:
int angle,
bool incremental );
void Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreateRatsnest = false );
void InstallExchangeModuleFrame( MODULE* ExchangeModuleModule );
// Graphic items edition:
void InstallGraphicItemPropertiesDialog( DRAWSEGMENT* aItem, wxDC* aDC );
......
......@@ -330,6 +330,20 @@ public:
// Footprint edition (see also WinEDA_BasePcbFrame)
void StartMove_Module( MODULE* module, wxDC* DC );
bool Delete_Module( MODULE* module, wxDC* DC, bool aAskBeforeDeleting );
void Change_Side_Module( MODULE* Module, wxDC* DC );
void InstallExchangeModuleFrame( MODULE* ExchangeModuleModule );
/** function Exchange_Module
* Replaces OldModule by NewModule, using OldModule settings:
* position, orientation, pad netnames ...)
* OldModule is deleted or put in undo list.
* @param aOldModule = footprint to replace
* @param aNewModule = footprint to put
* @param aUndoPickList = the undo list used to save OldModule. If null, OldModule is deleted
*/
void Exchange_Module( MODULE* aOldModule,
MODULE* aNewModule,
PICKED_ITEMS_LIST* aUndoPickList);
// loading modules: see WinEDA_BasePcbFrame
......
......@@ -125,6 +125,7 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
return;
}
// Swap layers:
int layer, layerimg;
layer = aItem->GetLayer();
layerimg = aImage->GetLayer();
......@@ -183,9 +184,14 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
break;
case TYPE_COTATION:
{
wxString txt = ( (COTATION*) aItem )->GetText();
( (COTATION*) aItem )->SetText( ((COTATION*) aImage )->GetText() );
( (COTATION*) aImage )->SetText( txt );
EXCHG( ( (COTATION*) aItem )->m_Text->m_Size, ( (COTATION*) aImage )->m_Text->m_Size );
EXCHG( ( (COTATION*) aItem )->m_Text->m_Width, ( (COTATION*) aImage )->m_Text->m_Width );
EXCHG( ( (COTATION*) aItem )->m_Text->m_Mirror, ( (COTATION*) aImage )->m_Text->m_Mirror );
}
break;
default:
......@@ -316,7 +322,6 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItem,
if( aItem == NULL ) // Nothing to save
return;
BOARD_ITEM* CopyOfItem;
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint;
......@@ -327,9 +332,9 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItem,
switch( aCommandType )
{
case UR_CHANGED: /* Create a copy of schematic */
CopyOfItem = DuplicateStruct( aItem );
itemWrapper.m_Link = CopyOfItem;
if( CopyOfItem )
if( itemWrapper.m_Link == NULL ) // When not null, the copy is already done
itemWrapper.m_Link = DuplicateStruct( aItem );;
if( itemWrapper.m_Link )
commandToUndo->PushItem( itemWrapper );
break;
......@@ -337,6 +342,7 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItem,
case UR_MOVED:
case UR_FLIPPED:
case UR_ROTATED:
case UR_ROTATED_CLOCKWISE:
case UR_DELETED:
commandToUndo->PushItem( itemWrapper );
break;
......@@ -371,7 +377,6 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint )
{
BOARD_ITEM* CopyOfItem;
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint;
......@@ -389,17 +394,19 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
itemWrapper.m_PickedItem = item;
itemWrapper.m_PickedItemType = item->Type();
itemWrapper.m_UndoRedoStatus = command;
itemWrapper.m_Link = aItemsList.GetPickedItemLink( ii );
switch( command )
{
case UR_CHANGED: /* Create a copy of item, and put in undo list */
CopyOfItem = DuplicateStruct( item );
itemWrapper.m_Link = CopyOfItem;
if( CopyOfItem )
case UR_CHANGED: /* If needed, create a copy of item, and put in undo list */
if( itemWrapper.m_Link == NULL ) // When not null, the copy is already done
itemWrapper.m_Link = DuplicateStruct( item );
if( itemWrapper.m_Link )
commandToUndo->PushItem( itemWrapper );
break;
case UR_MOVED:
case UR_ROTATED:
case UR_ROTATED_CLOCKWISE:
case UR_FLIPPED:
case UR_NEW:
case UR_DELETED:
......@@ -500,6 +507,10 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRe
item->Rotate( aList->m_TransformPoint, aRedoCommand ? 900 : -900 );
break;
case UR_ROTATED_CLOCKWISE:
item->Rotate( aList->m_TransformPoint, aRedoCommand ? -900 : 900 );
break;
case UR_FLIPPED:
item->Flip( aList->m_TransformPoint );
break;
......@@ -609,45 +620,7 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
// Delete items is they are not flagged UR_NEW, or if this is a block operation
while( 1 )
{
ITEM_PICKER wrapper = curr_cmd->PopItem();
if( wrapper.m_PickedItem == NULL ) // No more item in list.
break;
switch( wrapper.m_UndoRedoStatus )
{
case UR_UNSPECIFIED:
if( displ_error )
wxMessageBox( wxT( "ClearUndoORRedoList() error: unspecified item type" ) );
displ_error = false;
break;
case UR_MOVED:
case UR_FLIPPED:
case UR_MIRRORED_X:
case UR_MIRRORED_Y:
case UR_ROTATED:
case UR_NEW: // Do nothing, items are in use, the picker is not owner of items
break;
case UR_CHANGED:
delete wrapper.m_Link; // the picker is owner of this item
break;
case UR_MODEDIT: /* Specific to the module editor
* (modedit creates a full copy of the current module when changed),
* and the picker is owner of this item
*/
delete wrapper.m_PickedItem;
break;
default:
delete wrapper.m_PickedItem; // the picker is owner of this item
break;
}
}
curr_cmd->ClearListAndDeleteItems();
delete curr_cmd; // Delete command
}
}
......@@ -380,10 +380,6 @@ public:
#endif
/**************************/
/* footprint operations : */
/**************************/
void Change_Side_Module( MODULE* Module, wxDC* DC );
/*************************/
/* Copper Areas handling */
......
......@@ -11,7 +11,7 @@
/* Routines Locales */
static void Exit_EditCotation( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Montre_Position_New_Cotation( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Ajuste_Details_Cotation( COTATION* pts );
static void Ajuste_Details_Cotation( COTATION* pts, bool aDoNotChangeText = false );
/* Variables "locales" : */
static int status_cotation; /* = 0 : pas de cotation en cours
......@@ -349,7 +349,7 @@ void WinEDA_PcbFrame::Install_Edit_Cotation( COTATION* Cotation,
WinEDA_CotationPropertiesFrame* frame = new WinEDA_CotationPropertiesFrame( this,
Cotation, DC, pos );
Ajuste_Details_Cotation( Cotation );
Ajuste_Details_Cotation( Cotation, true );
frame->ShowModal();
frame->Destroy();
}
......@@ -372,7 +372,7 @@ void WinEDA_PcbFrame::Delete_Cotation( COTATION* Cotation, wxDC* DC )
/*****************************************************/
static void Ajuste_Details_Cotation( COTATION* Cotation )
static void Ajuste_Details_Cotation( COTATION* Cotation, bool aDoNotChangeText )
/*****************************************************/
/* Calcule les details des coordonnees des differents segments constitutifs
......@@ -411,8 +411,8 @@ static void Ajuste_Details_Cotation( COTATION* Cotation )
/* On tient compte de l'inclinaison de la cote */
if( mesure )
{
hx = (abs) ( (int) ( ( (float) deltay * hx ) / mesure ) );
hy = (abs) ( (int) ( ( (float) deltax * hy ) / mesure ) );
hx = (abs) ( (int) ( ( (double) deltay * hx ) / mesure ) );
hy = (abs) ( (int) ( ( (double) deltax * hy ) / mesure ) );
if( Cotation->TraitG_ox > Cotation->Barre_ox )
hx = -hx;
......@@ -476,7 +476,10 @@ static void Ajuste_Details_Cotation( COTATION* Cotation )
if( (Cotation->m_Text->m_Orient > 900) && (Cotation->m_Text->m_Orient <2700) )
Cotation->m_Text->m_Orient -= 1800;
Cotation->m_Value = mesure;
valeur_param( Cotation->m_Value, msg );
Cotation->SetText( msg );
if( !aDoNotChangeText )
{
Cotation->m_Value = mesure;
valeur_param( Cotation->m_Value, msg );
Cotation->SetText( msg );
}
}
......@@ -14,6 +14,7 @@
#include "gestfich.h"
#include "3d_struct.h"
#include "3d_viewer.h"
#include "wxPcbStruct.h"
#include "dialog_edit_module.h"
extern bool GoToEditor;
......@@ -569,7 +570,7 @@ void WinEDA_ModulePropertiesFrame::OnOkClick( wxCommandEvent& event )
if( change_layer )
{
m_Parent->GetBoard()->Change_Side_Module( m_CurrentModule, m_DC );
((WinEDA_PcbFrame*)m_Parent)->Change_Side_Module( m_CurrentModule, m_DC );
}
if( m_AutoPlaceCtrl->GetSelection() == 1 )
......@@ -668,7 +669,7 @@ void WinEDA_ModulePropertiesFrame::GotoModuleEditor( wxCommandEvent& event )
void WinEDA_ModulePropertiesFrame::ExchangeModule( wxCommandEvent& event )
/**********************************************************************/
{
m_Parent->InstallExchangeModuleFrame( m_CurrentModule );
((WinEDA_PcbFrame*)m_Parent)->InstallExchangeModuleFrame( m_CurrentModule );
// Attention: si il y a eu echange, m_CurrentModule a t delete!
m_Parent->SetCurItem( NULL );
......
......@@ -765,7 +765,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break;
Rotate_Module( &dc, (MODULE*) GetCurItem(), -900, true );
if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */
SaveCopyInUndoList(GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->m_Pos);
Rotate_Module( &dc, (MODULE*) GetCurItem(), 900, true );
break;
case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
......@@ -777,7 +780,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break;
Rotate_Module( &dc, (MODULE*) GetCurItem(), 900, true );
if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */
SaveCopyInUndoList(GetCurItem(), UR_ROTATED_CLOCKWISE, ((MODULE*)GetCurItem())->m_Pos);
Rotate_Module( &dc, (MODULE*) GetCurItem(), -900, true );
break;
case ID_POPUP_PCB_CHANGE_SIDE_MODULE:
......@@ -788,7 +793,11 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break;
GetBoard()->Change_Side_Module( (MODULE*) GetCurItem(), &dc );
if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple flip, no other edition in progress */
SaveCopyInUndoList(GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->m_Pos);
Change_Side_Module( (MODULE*) GetCurItem(), &dc );
break;
case ID_POPUP_PCB_EDIT_MODULE:
......
......@@ -100,7 +100,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
module->flag = 0;
if( module->GetLayer() == COPPER_LAYER_N )
{
GetBoard()->Change_Side_Module( module, NULL );
module->Flip( module->m_Pos );
module->flag = 1;
}
}
......@@ -132,7 +132,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
{
if( module->flag )
{
GetBoard()->Change_Side_Module( module, NULL );
module->Flip( module->m_Pos );
module->flag = 0;
}
}
......
......@@ -513,7 +513,7 @@ void WinEDA_PcbFrame::OnHotKey(wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct)
break;
case HK_FLIP_FOOTPRINT: // move to other side
GetBoard()->Change_Side_Module(module, DC);
Change_Side_Module(module, DC);
break;
case HK_DRAG_FOOTPRINT: // Start move (and drag) module
......
......@@ -83,7 +83,7 @@ void WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module )
GetScreen()->m_Curseur.x = GetScreen()->m_Curseur.y = 0;
Place_Module( Module, NULL );
if( Module->GetLayer() != CMP_N )
GetBoard()->Change_Side_Module( Module, NULL );
Module->Flip( Module->m_Pos );
Rotate_Module( NULL, Module, 0, FALSE );
GetScreen()->ClrModify();
Zoom_Automatique( TRUE );
......
......@@ -291,10 +291,14 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
if( source_module ) // this is an update command
{
// The new module replace the old module (pos, orient, ref, value and connexions are kept)
// In the main board,
// the new module replace the old module (pos, orient, ref, value and connexions are kept)
// and the source_module (old module) is deleted
newmodule = pcbframe->Exchange_Module( this, source_module, newmodule );
PICKED_ITEMS_LIST pickList;
pcbframe->Exchange_Module( source_module, newmodule, &pickList );
newmodule->m_TimeStamp = module_in_edit->m_Link;
if( pickList.GetCount() )
pcbframe->SaveCopyInUndoList( pickList, UR_UNSPECIFIED );
}
else // This is an insert command
{
......
This diff is collapsed.
......@@ -475,7 +475,10 @@ MODULE* ReadNetModule( WinEDA_PcbFrame* aFrame,
MODULE* NewModule =
aFrame->Get_Librairie_Module( wxEmptyString, NameLibCmp, true );
if( NewModule ) /* Change old module to the new module (and delete the old one)*/
Module = aFrame->Exchange_Module( NULL, Module, NewModule );
{
aFrame->Exchange_Module( Module, NewModule, NULL );
Module = NewModule;
}
}
else
{
......
......@@ -22,75 +22,7 @@
/* Bitmaps */
#include "bitmaps.h"
/********************************************/
static wxMenu* Append_Track_Width_List()
/********************************************/
/* create a wxMenu * which shows the last used track widths and via diameters
* @return a pointeur to the menu
*/
{
#define TRACK_HISTORY_NUMBER_MAX 6
#define VIA_HISTORY_NUMBER_MAX 4
int ii;
wxString msg;
wxMenu* trackwidth_menu;
double value;
trackwidth_menu = new wxMenu;
ADD_MENUITEM( trackwidth_menu, ID_PCB_TRACK_SIZE_SETUP,
_( "New Width/Size" ), showtrack_xpm );
trackwidth_menu->Append( ID_POPUP_PCB_SELECT_AUTO_WIDTH,
_( "Auto Width" ),
_(
"Use the track width when starting on a track, otherwise the current track width" ),
TRUE );
if( g_DesignSettings.m_UseConnectedTrackWidth )
trackwidth_menu->Check( ID_POPUP_PCB_SELECT_AUTO_WIDTH, TRUE );
for( ii = 0; (ii < HISTORY_NUMBER) && (ii < TRACK_HISTORY_NUMBER_MAX); ii++ )
{
if( g_DesignSettings.m_TrackWidthHistory[ii] == 0 )
break;
value = To_User_Unit( g_UnitMetric,
g_DesignSettings.m_TrackWidthHistory[ii],
PCB_INTERNAL_UNIT );
if( g_UnitMetric == INCHES ) // Affichage en mils
msg.Printf( _( "Track %.1f" ), value * 1000 );
else
msg.Printf( _( "Track %.3f" ), value );
trackwidth_menu->Append( ID_POPUP_PCB_SELECT_WIDTH1 + ii, msg, wxEmptyString, TRUE );
if( (g_DesignSettings.m_TrackWidthHistory[ii] == g_DesignSettings.m_CurrentTrackWidth)
&& !g_DesignSettings.m_UseConnectedTrackWidth )
trackwidth_menu->Check( ID_POPUP_PCB_SELECT_WIDTH1 + ii, TRUE );
}
trackwidth_menu->AppendSeparator();
for( ii = 0; (ii < HISTORY_NUMBER) && (ii < VIA_HISTORY_NUMBER_MAX); ii++ )
{
if( g_DesignSettings.m_ViaSizeHistory[ii] == 0 )
break;
value = To_User_Unit( g_UnitMetric,
g_DesignSettings.m_ViaSizeHistory[ii],
PCB_INTERNAL_UNIT );
if( g_UnitMetric == INCHES )
msg.Printf( _( "Via %.1f" ), value * 1000 );
else
msg.Printf( _( "Via %.3f" ), value );
trackwidth_menu->Append( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, msg, wxEmptyString, TRUE );
if( g_DesignSettings.m_ViaSizeHistory[ii] == g_DesignSettings.m_CurrentViaSize )
trackwidth_menu->Check( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, TRUE );
}
return trackwidth_menu;
}
static wxMenu* Append_Track_Width_List();
/******************************************************************************/
......@@ -732,19 +664,19 @@ void WinEDA_PcbFrame::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* men
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_DRAG_MODULE_REQUEST,
msg, drag_module_xpm );
}
msg = AddHotkeyName( _( "Rotate +" ), s_Board_Editor_Hokeys_Descr, HK_ROTATE_FOOTPRINT );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE,
msg, rotate_module_pos_xpm );
msg = AddHotkeyName( _( "Rotate +" ), s_Board_Editor_Hokeys_Descr, HK_ROTATE_FOOTPRINT );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE,
msg, rotate_module_pos_xpm );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE,
_( "Rotate -" ), rotate_module_neg_xpm );
msg = AddHotkeyName( _( "Flip" ), s_Board_Editor_Hokeys_Descr, HK_FLIP_FOOTPRINT );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_CHANGE_SIDE_MODULE,
msg, invert_module_xpm );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE,
_( "Edit" ), edit_module_xpm );
if( !flags )
{
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE,
_( "Edit" ), edit_module_xpm );
sub_menu_footprint->AppendSeparator();
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_DELETE_MODULE,
_( "Delete Module" ), delete_module_xpm );
......@@ -887,3 +819,73 @@ void WinEDA_PcbFrame::createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aP
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_MARKER, _( "Delete Marker" ), delete_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_GETINFO_MARKER, _( "Marker Error Info" ), info_xpm );
}
/********************************************/
static wxMenu* Append_Track_Width_List()
/********************************************/
/* create a wxMenu * which shows the last used track widths and via diameters
* @return a pointeur to the menu
*/
{
#define TRACK_HISTORY_NUMBER_MAX 6
#define VIA_HISTORY_NUMBER_MAX 4
int ii;
wxString msg;
wxMenu* trackwidth_menu;
double value;
trackwidth_menu = new wxMenu;
ADD_MENUITEM( trackwidth_menu, ID_PCB_TRACK_SIZE_SETUP,
_( "New Width/Size" ), showtrack_xpm );
trackwidth_menu->Append( ID_POPUP_PCB_SELECT_AUTO_WIDTH,
_( "Auto Width" ),
_(
"Use the track width when starting on a track, otherwise the current track width" ),
TRUE );
if( g_DesignSettings.m_UseConnectedTrackWidth )
trackwidth_menu->Check( ID_POPUP_PCB_SELECT_AUTO_WIDTH, TRUE );
for( ii = 0; (ii < HISTORY_NUMBER) && (ii < TRACK_HISTORY_NUMBER_MAX); ii++ )
{
if( g_DesignSettings.m_TrackWidthHistory[ii] == 0 )
break;
value = To_User_Unit( g_UnitMetric,
g_DesignSettings.m_TrackWidthHistory[ii],
PCB_INTERNAL_UNIT );
if( g_UnitMetric == INCHES ) // Affichage en mils
msg.Printf( _( "Track %.1f" ), value * 1000 );
else
msg.Printf( _( "Track %.3f" ), value );
trackwidth_menu->Append( ID_POPUP_PCB_SELECT_WIDTH1 + ii, msg, wxEmptyString, TRUE );
if( (g_DesignSettings.m_TrackWidthHistory[ii] == g_DesignSettings.m_CurrentTrackWidth)
&& !g_DesignSettings.m_UseConnectedTrackWidth )
trackwidth_menu->Check( ID_POPUP_PCB_SELECT_WIDTH1 + ii, TRUE );
}
trackwidth_menu->AppendSeparator();
for( ii = 0; (ii < HISTORY_NUMBER) && (ii < VIA_HISTORY_NUMBER_MAX); ii++ )
{
if( g_DesignSettings.m_ViaSizeHistory[ii] == 0 )
break;
value = To_User_Unit( g_UnitMetric,
g_DesignSettings.m_ViaSizeHistory[ii],
PCB_INTERNAL_UNIT );
if( g_UnitMetric == INCHES )
msg.Printf( _( "Via %.1f" ), value * 1000 );
else
msg.Printf( _( "Via %.3f" ), value );
trackwidth_menu->Append( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, msg, wxEmptyString, TRUE );
if( g_DesignSettings.m_ViaSizeHistory[ii] == g_DesignSettings.m_CurrentViaSize )
trackwidth_menu->Check( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, TRUE );
}
return trackwidth_menu;
}
......@@ -34,7 +34,7 @@
#include "specctra.h"
#include "collectors.h"
#include "wxPcbStruct.h" // Change_Side_Module()
#include "wxPcbStruct.h"
#include "pcbstruct.h" // HISTORY_NUMBER
#include "confirm.h" // DisplayError()
#include "gestfich.h" // EDA_FileSelector()
......@@ -113,7 +113,7 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event )
db.RevertMODULEs( GetBoard() );
// The two calls below to BOARD::Change_Side_Module(), both set the
// The two calls below to MODULE::Flip(), both set the
// modified flag, yet their actions cancel each other out, so it should
// be ok to clear the modify flag.
if( !wasModified )
......@@ -1451,7 +1451,7 @@ void SPECCTRA_DB::FlipMODULEs( BOARD* aBoard )
module->flag = 0;
if( module->GetLayer() == COPPER_LAYER_N )
{
aBoard->Change_Side_Module( module, NULL );
module->Flip( module->m_Pos );
module->flag = 1;
}
}
......@@ -1471,7 +1471,7 @@ void SPECCTRA_DB::RevertMODULEs( BOARD* aBoard )
{
if( module->flag )
{
aBoard->Change_Side_Module( module, NULL );
module->Flip( module->m_Pos );
module->flag = 0;
}
}
......
......@@ -413,7 +413,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
if( module->GetLayer() != CMP_N )
{
// module is on copper layer (back)
aBoard->Change_Side_Module( module, 0 );
module->Flip( module->m_Pos );
}
module->SetOrientation( orientation );
}
......@@ -423,8 +423,8 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
if( module->GetLayer() != COPPER_LAYER_N )
{
// module is on component layer (front)
aBoard->Change_Side_Module( module, 0 );
}
module->Flip( module->m_Pos );
}
module->SetOrientation( orientation );
}
else
......
This diff is collapsed.
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