Blob Blame History Raw
diff -ru kicad-2010.05.27-5.rev2363/include/wxBasePcbFrame.h kicad-2010.05.27-6.rev2363/include/wxBasePcbFrame.h
--- kicad-2010.05.27-5.rev2363/include/wxBasePcbFrame.h	2010-05-28 21:47:34.000000000 +0200
+++ kicad-2010.05.27-6.rev2363/include/wxBasePcbFrame.h	2010-06-15 22:57:22.000000000 +0200
@@ -213,7 +213,6 @@
 
     void    Archive_Modules( const wxString& LibName,
                              bool            NewModulesOnly );
-    MODULE* Select_1_Module_From_BOARD( BOARD* Pcb );
     MODULE* GetModuleByName();
 
     /** Function OnModify()
diff -ru kicad-2010.05.27-5.rev2363/include/wxPcbStruct.h kicad-2010.05.27-6.rev2363/include/wxPcbStruct.h
--- kicad-2010.05.27-5.rev2363/include/wxPcbStruct.h	2010-05-28 21:47:34.000000000 +0200
+++ kicad-2010.05.27-6.rev2363/include/wxPcbStruct.h	2010-06-15 22:59:39.000000000 +0200
@@ -1088,6 +1088,11 @@
     void         OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
     void         Show3D_Frame( wxCommandEvent& event );
     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 );
 
     /** Virtual Function OnModify()
@@ -1172,10 +1177,23 @@
     void         RemoveStruct( EDA_BaseStruct* Item );
     void         Transform( MODULE* module, int transform );
 
-    // loading Footprint
+    // loading/exporting Footprint
     MODULE*      Import_Module( wxDC* DC );
     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
 
diff -ru kicad-2010.05.27-5.rev2363/pcbnew/class_module.cpp kicad-2010.05.27-6.rev2363/pcbnew/class_module.cpp
--- kicad-2010.05.27-5.rev2363/pcbnew/class_module.cpp	2010-05-28 21:47:32.000000000 +0200
+++ kicad-2010.05.27-6.rev2363/pcbnew/class_module.cpp	2010-06-15 23:00:21.000000000 +0200
@@ -101,6 +101,7 @@
     m_CntRot90      = aModule->m_CntRot90;
     m_CntRot180     = aModule->m_CntRot180;
     m_LastEdit_Time = aModule->m_LastEdit_Time;
+    m_Link          = aModule->m_Link;
     m_Path          = aModule->m_Path; //is this correct behavior?
     m_TimeStamp     = GetTimeStamp();
     m_LocalSolderMaskMargin  = aModule->m_LocalSolderMaskMargin;
diff -ru kicad-2010.05.27-5.rev2363/pcbnew/loadcmp.cpp kicad-2010.05.27-6.rev2363/pcbnew/loadcmp.cpp
--- kicad-2010.05.27-5.rev2363/pcbnew/loadcmp.cpp	2010-05-28 21:47:32.000000000 +0200
+++ kicad-2010.05.27-6.rev2363/pcbnew/loadcmp.cpp	2010-06-15 23:05:34.000000000 +0200
@@ -41,27 +41,30 @@
 
 static ModList* MList;
 
-
-void WinEDA_ModuleEditFrame::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 WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module )
 {
     MODULE* NewModule;
     WinEDA_BasePcbFrame* parent = (WinEDA_BasePcbFrame*) GetParent();
 
     if( Module == NULL )
     {
-        if( parent->GetBoard() == NULL
-            || parent->GetBoard()->m_Modules == NULL )
-            return;
+        if( ! parent->GetBoard() || ! parent->GetBoard()->m_Modules )
+            return false;
 
         Module = Select_1_Module_From_BOARD( parent->GetBoard() );
     }
 
     if( Module == NULL )
-        return;
+        return false;
 
     SetCurItem( NULL );
 
-    Clear_Pcb( TRUE );
+    Clear_Pcb( false );
 
     GetBoard()->m_Status_Pcb = 0;
     NewModule = new MODULE( GetBoard() );
@@ -80,9 +83,11 @@
     Place_Module( Module, NULL );
     if( Module->GetLayer() != LAYER_N_FRONT )
         Module->Flip( Module->m_Pos );
-    Rotate_Module( NULL, Module, 0, FALSE );
+    Rotate_Module( NULL, Module, 0, false );
     GetScreen()->ClrModify();
     Zoom_Automatique( TRUE );
+
+    return true;
 }
 
 
@@ -117,7 +122,7 @@
 
     if( ModuleName[0] == '=' )   // Selection by keywords
     {
-        AllowWildSeach = FALSE;
+        AllowWildSeach = false;
         keys = ModuleName.AfterFirst( '=' );
         ModuleName = Select_1_Module_From_List( this, library, wxEmptyString,
                                                 keys );
@@ -130,7 +135,7 @@
     else if( ( ModuleName.Contains( wxT( "?" ) ) )
             || ( ModuleName.Contains( wxT( "*" ) ) ) )  // Selection wild card
     {
-        AllowWildSeach = FALSE;
+        AllowWildSeach = false;
         ModuleName     = Select_1_Module_From_List( this, library, ModuleName,
                                                     wxEmptyString );
         if( ModuleName.IsEmpty() )
@@ -140,11 +145,11 @@
         }
     }
 
-    module = Get_Librairie_Module( library, ModuleName, FALSE );
+    module = Get_Librairie_Module( library, ModuleName, false );
 
     if( ( module == NULL ) && AllowWildSeach )    /* Search with wildcard */
     {
-        AllowWildSeach = FALSE;
+        AllowWildSeach = false;
         wxString wildname = wxChar( '*' ) + ModuleName + wxChar( '*' );
         ModuleName = wildname;
         ModuleName = Select_1_Module_From_List( this, library, ModuleName,
@@ -445,7 +450,7 @@
                         ListBox->Append( msg );
                         NbModules++;
                     }
-                    else if( WildCompareString( aMask, msg, FALSE ) )
+                    else if( WildCompareString( aMask, msg, false ) )
                     {
                         ListBox->Append( msg );
                         NbModules++;
@@ -594,11 +599,12 @@
 }
 
 
-/* Display the list of modules currently PCB
- * Returns a pointer if module selected
- * Returns NULL otherwise
+/** 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* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb )
+MODULE* WinEDA_ModuleEditFrame::Select_1_Module_From_BOARD( BOARD* aPcb )
 {
     int             ii;
     MODULE*         Module;
@@ -610,7 +616,7 @@
                                                  wxColour( 200, 200, 255 ) );
 
     ii     = 0;
-    Module = Pcb->m_Modules;
+    Module = aPcb->m_Modules;
     for( ; Module != NULL; Module = (MODULE*) Module->Next() )
     {
         ii++;
@@ -635,7 +641,7 @@
 
     OldName = CmpName;
 
-    Module = Pcb->m_Modules;
+    Module = aPcb->m_Modules;
     for( ; Module != NULL; Module = (MODULE*) Module->Next() )
     {
         if( CmpName.CmpNoCase( Module->m_Reference->m_Text ) == 0 )
diff -ru kicad-2010.05.27-5.rev2363/pcbnew/modedit.cpp kicad-2010.05.27-6.rev2363/pcbnew/modedit.cpp
--- kicad-2010.05.27-5.rev2363/pcbnew/modedit.cpp	2010-05-28 21:47:32.000000000 +0200
+++ kicad-2010.05.27-6.rev2363/pcbnew/modedit.cpp	2010-06-15 23:08:06.000000000 +0200
@@ -131,11 +131,23 @@
     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 )
 {
+    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();
-    Load_Module_From_BOARD( NULL );
     GetScreen()->ClrModify();
 
     if( m_Draw3DFrame )
@@ -333,9 +345,10 @@
     break;
 
     case ID_MODEDIT_IMPORT_PART:
+        if( ! Clear_Pcb( true ) )
+            break;                  // //this command is aborted
         GetScreen()->ClearUndoRedoList();
         SetCurItem( NULL );
-        Clear_Pcb( true );
         GetScreen()->m_Curseur = wxPoint( 0, 0 );
         Import_Module( NULL );
         redraw = true;