From 7c5d2ab02962e38541b110e9ac70d62f0bce78d7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 2 Jan 2013 22:49:56 +0100 Subject: [PATCH] Kicad: Fix compil issue under Linux, and minor code cleaning, about wxFileWatcher --- common/basicframe.cpp | 7 ---- kicad/kicad.h | 1 - kicad/tree_project_frame.cpp | 77 ++++++++++++++++++++---------------- pcbnew/class_module.cpp | 12 +++--- pcbnew/netlist.cpp | 6 --- 5 files changed, 49 insertions(+), 54 deletions(-) diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 42d8086063..9ae205e19d 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -532,13 +532,6 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event ) tmp << wxT( "OFF\n" ); #endif - tmp << wxT( " USE_BOOST_POLYGON_LIBRARY=" ); -#ifdef USE_BOOST_POLYGON_LIBRARY - tmp << wxT( "ON\n" ); -#else - tmp << wxT( "OFF\n" ); -#endif - tmp << wxT( " KICAD_SCRIPTING=" ); #ifdef KICAD_SCRIPTING tmp << wxT( "ON\n" ); diff --git a/kicad/kicad.h b/kicad/kicad.h index 5e3074469a..1d8cab43bc 100644 --- a/kicad/kicad.h +++ b/kicad/kicad.h @@ -183,7 +183,6 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, void SaveSettings(); #ifdef KICAD_USE_FILES_WATCHER - void FileWatcherReset(); /** * Called by sending a event with id = ID_INIT_WATCHED_PATHS * rebuild the list of wahtched paths diff --git a/kicad/tree_project_frame.cpp b/kicad/tree_project_frame.cpp index f12ed3de45..fd398fb325 100644 --- a/kicad/tree_project_frame.cpp +++ b/kicad/tree_project_frame.cpp @@ -595,7 +595,8 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName, addFile = false; // check the first 100 lines for the "Sheet 1" string - for( int i = 0; i<100; ++i ) + int l =0; + for( int i = 0; i<100; ++i, l++ ) { if( !fgets( line, sizeof(line), fp ) ) break; @@ -968,7 +969,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event ) { #ifdef KICAD_USE_FILES_WATCHER #ifndef __WINDOWS__ - m_TreeProject->FileWatcherReset(); + FileWatcherReset(); #endif #endif } @@ -1066,6 +1067,9 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir ) */ void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event ) { + wxFileName pathModified = event.GetPath(); + wxString subdir = pathModified.GetPath(); + wxString fn = pathModified.GetFullPath(); switch( event.GetChangeType() ) { @@ -1084,50 +1088,53 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir ) return; } - wxFileName pathModified = event.GetPath(); - wxString subdir = pathModified.GetPath(); - wxString fn = pathModified.GetFullPath(); wxTreeItemId root_id = findSubdirTreeItem( subdir ); if( !root_id.IsOk() ) return; - // Add item if it is created - if( event.GetChangeType() == wxFSW_EVENT_CREATE ) - AddItemToTreeProject( pathModified.GetFullPath(), root_id, false ); + wxTreeItemIdValue cookie; // dummy variable needed by GetFirstChild() + wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie ); - // search for item to delete/rename. - if( event.GetChangeType() == wxFSW_EVENT_DELETE || - event.GetChangeType() == wxFSW_EVENT_RENAME ) + switch( event.GetChangeType() ) { - wxTreeItemIdValue cookie; // dummy variable needed by GetFirstChild() - wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie ); + case wxFSW_EVENT_CREATE: + AddItemToTreeProject( pathModified.GetFullPath(), root_id, false ); + break; - while( kid.IsOk() ) - { - TREEPROJECT_ITEM* itemData = GetItemIdData( kid ); - - if( itemData && ( itemData->m_FileName == fn ) ) + case wxFSW_EVENT_DELETE: + while( kid.IsOk() ) { - if( event.GetChangeType() == wxFSW_EVENT_DELETE ) - m_TreeProject->Delete( kid ); - else - { - wxFileName newpath = event.GetNewPath(); - wxString newfn = newpath.GetFullPath(); - // Change item label and item data - // Extension could be modified and be not an usually selected file type - // However, here we do not filter files. - // This is simple, and I am not sure filtering renamed files here is better, - // because they could disappear, like deleted files - itemData->SetFileName( newpath.GetFullPath() ); - m_TreeProject->SetItemText( kid, newpath.GetFullName() ); - } - return; - } + TREEPROJECT_ITEM* itemData = GetItemIdData( kid ); - kid = m_TreeProject->GetNextChild( root_id, cookie ); + if( itemData && ( itemData->m_FileName == fn ) ) + { + m_TreeProject->Delete( kid ); + return; + } + kid = m_TreeProject->GetNextChild( root_id, cookie ); + } + break; + + case wxFSW_EVENT_RENAME : + { + wxFileName newpath = event.GetNewPath(); + wxString newfn = newpath.GetFullPath(); + while( kid.IsOk() ) + { + TREEPROJECT_ITEM* itemData = GetItemIdData( kid ); + + if( itemData && ( itemData->m_FileName == fn ) ) + { + m_TreeProject->Delete( kid ); + break; + } + + kid = m_TreeProject->GetNextChild( root_id, cookie ); + } + AddItemToTreeProject( newfn, root_id, false ); } + break; } /* Sort filenames by alphabetic order */ diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 8ce708222d..2891451aaf 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -123,8 +123,6 @@ MODULE::MODULE( const MODULE& aModule ) : } // Copy auxiliary data: Drawings - // m_Drawings.DeleteAll(); - for( BOARD_ITEM* item = aModule.m_Drawings; item; item = item->Next() ) { BOARD_ITEM* newItem; @@ -145,8 +143,6 @@ MODULE::MODULE( const MODULE& aModule ) : } // Copy auxiliary data: 3D_Drawings info - // m_3D_Drawings.DeleteAll(); - for( S3D_MASTER* item = aModule.m_3D_Drawings; item; item = item->Next() ) { if( item->m_Shape3DName.IsEmpty() ) // do not copy empty shapes. @@ -165,6 +161,9 @@ MODULE::MODULE( const MODULE& aModule ) : m_Doc = aModule.m_Doc; m_KeyWord = aModule.m_KeyWord; + + // Ensure auxiliary data is up to date + CalculateBoundingBox(); } @@ -294,6 +293,9 @@ void MODULE::Copy( MODULE* aModule ) m_Doc = aModule->m_Doc; m_KeyWord = aModule->m_KeyWord; + + // Ensure auxiliary data is up to date + CalculateBoundingBox(); } @@ -400,7 +402,7 @@ EDA_RECT MODULE::GetFootPrintRect() const area.SetOrigin( m_Pos ); area.SetEnd( m_Pos ); - area.Inflate( 50 ); // Give a min size + area.Inflate( Millimeter2iu( 0.25 ) ); // Give a min size to the area for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() ) if( edge->Type() == PCB_MODULE_EDGE_T ) diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index b38a10300d..78e3d610d7 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -54,18 +54,12 @@ #include #include #include -#include -#include -#include #include #include -#include - #include #include #include #include - #include #include