Commit 12a0e494 authored by jean-pierre charras's avatar jean-pierre charras

fixed bugs 593546 ( 'Update module' in module editor becomes sometimes...

fixed bugs 593546  ( 'Update module' in module editor becomes sometimes unavailable after undo ) and 593547  ('no' confirmation in module editor overlaps modules)
parent 6eb66721
...@@ -213,7 +213,6 @@ public: ...@@ -213,7 +213,6 @@ public:
void Archive_Modules( const wxString& LibName, void Archive_Modules( const wxString& LibName,
bool NewModulesOnly ); bool NewModulesOnly );
MODULE* Select_1_Module_From_BOARD( BOARD* Pcb );
MODULE* GetModuleByName(); MODULE* GetModuleByName();
/** Function OnModify() /** Function OnModify()
......
...@@ -1089,6 +1089,11 @@ public: ...@@ -1089,6 +1089,11 @@ public:
void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct ); void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
void Show3D_Frame( wxCommandEvent& event ); void Show3D_Frame( wxCommandEvent& event );
void GeneralControle( wxDC* DC, wxPoint Mouse ); void GeneralControle( wxDC* DC, wxPoint Mouse );
/** function LoadModuleFromBoard
* called from the main toolbar
* to load a footprint from board mainly to edit it
*/
void LoadModuleFromBoard( wxCommandEvent& event ); void LoadModuleFromBoard( wxCommandEvent& event );
/** Virtual Function OnModify() /** Virtual Function OnModify()
...@@ -1173,10 +1178,23 @@ public: ...@@ -1173,10 +1178,23 @@ public:
void RemoveStruct( EDA_BaseStruct* Item ); void RemoveStruct( EDA_BaseStruct* Item );
void Transform( MODULE* module, int transform ); void Transform( MODULE* module, int transform );
// loading Footprint // loading/exporting Footprint
MODULE* Import_Module( wxDC* DC ); MODULE* Import_Module( wxDC* DC );
void Export_Module( MODULE* ptmod, bool createlib ); void Export_Module( MODULE* ptmod, bool createlib );
void Load_Module_From_BOARD( MODULE* Module );
/** function Load_Module_From_BOARD
* load in Modedit a footfrint from the main board
* @param Module = the module to load. If NULL, a module reference will we asked to user
* @return true if a module isloaded, false otherwise.
*/
bool Load_Module_From_BOARD( MODULE* Module );
/** Function Select_1_Module_From_BOARD
* Display the list of modules currently existing on the BOARD
* @return a pointer to a module if this module is selected or NULL otherwise
* @param aPcb = the board from modules can be loaded
*/
MODULE* Select_1_Module_From_BOARD( BOARD* aPcb );
// functions to edit footprint edges // functions to edit footprint edges
......
...@@ -101,6 +101,7 @@ void MODULE::Copy( MODULE* aModule ) ...@@ -101,6 +101,7 @@ void MODULE::Copy( MODULE* aModule )
m_CntRot90 = aModule->m_CntRot90; m_CntRot90 = aModule->m_CntRot90;
m_CntRot180 = aModule->m_CntRot180; m_CntRot180 = aModule->m_CntRot180;
m_LastEdit_Time = aModule->m_LastEdit_Time; m_LastEdit_Time = aModule->m_LastEdit_Time;
m_Link = aModule->m_Link;
m_Path = aModule->m_Path; //is this correct behavior? m_Path = aModule->m_Path; //is this correct behavior?
m_TimeStamp = GetTimeStamp(); m_TimeStamp = GetTimeStamp();
m_LocalSolderMaskMargin = aModule->m_LocalSolderMaskMargin; m_LocalSolderMaskMargin = aModule->m_LocalSolderMaskMargin;
......
...@@ -41,27 +41,30 @@ static void ReadDocLib( const wxString& ModLibName ); ...@@ -41,27 +41,30 @@ static void ReadDocLib( const wxString& ModLibName );
static ModList* MList; static ModList* MList;
/** function Load_Module_From_BOARD
void WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module ) * load in Modedit a footfrint from the main board
* @param Module = the module to load. If NULL, a module reference will we asked to user
* @return true if a module isloaded, false otherwise.
*/
bool WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module )
{ {
MODULE* NewModule; MODULE* NewModule;
WinEDA_BasePcbFrame* parent = (WinEDA_BasePcbFrame*) GetParent(); WinEDA_BasePcbFrame* parent = (WinEDA_BasePcbFrame*) GetParent();
if( Module == NULL ) if( Module == NULL )
{ {
if( parent->GetBoard() == NULL if( ! parent->GetBoard() || ! parent->GetBoard()->m_Modules )
|| parent->GetBoard()->m_Modules == NULL ) return false;
return;
Module = Select_1_Module_From_BOARD( parent->GetBoard() ); Module = Select_1_Module_From_BOARD( parent->GetBoard() );
} }
if( Module == NULL ) if( Module == NULL )
return; return false;
SetCurItem( NULL ); SetCurItem( NULL );
Clear_Pcb( TRUE ); Clear_Pcb( false );
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
NewModule = new MODULE( GetBoard() ); NewModule = new MODULE( GetBoard() );
...@@ -80,9 +83,11 @@ void WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module ) ...@@ -80,9 +83,11 @@ void WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module )
Place_Module( Module, NULL ); Place_Module( Module, NULL );
if( Module->GetLayer() != LAYER_N_FRONT ) if( Module->GetLayer() != LAYER_N_FRONT )
Module->Flip( Module->m_Pos ); Module->Flip( Module->m_Pos );
Rotate_Module( NULL, Module, 0, FALSE ); Rotate_Module( NULL, Module, 0, false );
GetScreen()->ClrModify(); GetScreen()->ClrModify();
Zoom_Automatique( TRUE ); Zoom_Automatique( TRUE );
return true;
} }
...@@ -117,7 +122,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, ...@@ -117,7 +122,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
if( ModuleName[0] == '=' ) // Selection by keywords if( ModuleName[0] == '=' ) // Selection by keywords
{ {
AllowWildSeach = FALSE; AllowWildSeach = false;
keys = ModuleName.AfterFirst( '=' ); keys = ModuleName.AfterFirst( '=' );
ModuleName = Select_1_Module_From_List( this, library, wxEmptyString, ModuleName = Select_1_Module_From_List( this, library, wxEmptyString,
keys ); keys );
...@@ -130,7 +135,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, ...@@ -130,7 +135,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
else if( ( ModuleName.Contains( wxT( "?" ) ) ) else if( ( ModuleName.Contains( wxT( "?" ) ) )
|| ( ModuleName.Contains( wxT( "*" ) ) ) ) // Selection wild card || ( ModuleName.Contains( wxT( "*" ) ) ) ) // Selection wild card
{ {
AllowWildSeach = FALSE; AllowWildSeach = false;
ModuleName = Select_1_Module_From_List( this, library, ModuleName, ModuleName = Select_1_Module_From_List( this, library, ModuleName,
wxEmptyString ); wxEmptyString );
if( ModuleName.IsEmpty() ) if( ModuleName.IsEmpty() )
...@@ -140,11 +145,11 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, ...@@ -140,11 +145,11 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
} }
} }
module = Get_Librairie_Module( library, ModuleName, FALSE ); module = Get_Librairie_Module( library, ModuleName, false );
if( ( module == NULL ) && AllowWildSeach ) /* Search with wildcard */ if( ( module == NULL ) && AllowWildSeach ) /* Search with wildcard */
{ {
AllowWildSeach = FALSE; AllowWildSeach = false;
wxString wildname = wxChar( '*' ) + ModuleName + wxChar( '*' ); wxString wildname = wxChar( '*' ) + ModuleName + wxChar( '*' );
ModuleName = wildname; ModuleName = wildname;
ModuleName = Select_1_Module_From_List( this, library, ModuleName, ModuleName = Select_1_Module_From_List( this, library, ModuleName,
...@@ -445,7 +450,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( ...@@ -445,7 +450,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
ListBox->Append( msg ); ListBox->Append( msg );
NbModules++; NbModules++;
} }
else if( WildCompareString( aMask, msg, FALSE ) ) else if( WildCompareString( aMask, msg, false ) )
{ {
ListBox->Append( msg ); ListBox->Append( msg );
NbModules++; NbModules++;
...@@ -594,11 +599,12 @@ static void ReadDocLib( const wxString& ModLibName ) ...@@ -594,11 +599,12 @@ static void ReadDocLib( const wxString& ModLibName )
} }
/* Display the list of modules currently PCB /** Function Select_1_Module_From_BOARD
* Returns a pointer if module selected * Display the list of modules currently existing on the BOARD
* Returns NULL otherwise * @return a pointer to a module if this module is selected or NULL otherwise
* @param aPcb = the board from modules can be loaded
*/ */
MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb ) MODULE* WinEDA_ModuleEditFrame::Select_1_Module_From_BOARD( BOARD* aPcb )
{ {
int ii; int ii;
MODULE* Module; MODULE* Module;
...@@ -610,7 +616,7 @@ MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb ) ...@@ -610,7 +616,7 @@ MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb )
wxColour( 200, 200, 255 ) ); wxColour( 200, 200, 255 ) );
ii = 0; ii = 0;
Module = Pcb->m_Modules; Module = aPcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() ) for( ; Module != NULL; Module = (MODULE*) Module->Next() )
{ {
ii++; ii++;
...@@ -635,7 +641,7 @@ MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb ) ...@@ -635,7 +641,7 @@ MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb )
OldName = CmpName; OldName = CmpName;
Module = Pcb->m_Modules; Module = aPcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() ) for( ; Module != NULL; Module = (MODULE*) Module->Next() )
{ {
if( CmpName.CmpNoCase( Module->m_Reference->m_Text ) == 0 ) if( CmpName.CmpNoCase( Module->m_Reference->m_Text ) == 0 )
......
...@@ -131,11 +131,23 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode ) ...@@ -131,11 +131,23 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
return item; return item;
} }
/** function LoadModuleFromBoard
* called from the main toolbar
* to load a footprint from board mainly to edit it
*/
void WinEDA_ModuleEditFrame::LoadModuleFromBoard( wxCommandEvent& event ) void WinEDA_ModuleEditFrame::LoadModuleFromBoard( wxCommandEvent& event )
{ {
if( GetScreen()->IsModify() )
{
if( !IsOK( this,
_( "Current footprint changes will be lost and this operation cannot be undone. Continue ?" ) ) )
return;
}
if( ! Load_Module_From_BOARD( NULL ) )
return;
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
Load_Module_From_BOARD( NULL );
GetScreen()->ClrModify(); GetScreen()->ClrModify();
if( m_Draw3DFrame ) if( m_Draw3DFrame )
...@@ -333,9 +345,10 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -333,9 +345,10 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_MODEDIT_IMPORT_PART: case ID_MODEDIT_IMPORT_PART:
if( ! Clear_Pcb( true ) )
break; // //this command is aborted
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
SetCurItem( NULL ); SetCurItem( NULL );
Clear_Pcb( true );
GetScreen()->m_Curseur = wxPoint( 0, 0 ); GetScreen()->m_Curseur = wxPoint( 0, 0 );
Import_Module( NULL ); Import_Module( NULL );
redraw = true; redraw = true;
......
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