Commit 5d5eb7d3 authored by jean-pierre charras's avatar jean-pierre charras

Fix a serious bug in EDA_RECT::Intersects

Kicad manager: code cleaning. Dead code removed and minor fixes. support of new .kicad_brd extension.
parent 8c0dc01f
...@@ -344,11 +344,11 @@ bool EDA_RECT::Intersects( const EDA_RECT& aRect ) const ...@@ -344,11 +344,11 @@ bool EDA_RECT::Intersects( const EDA_RECT& aRect ) const
// calculate the left common area coordinate: // calculate the left common area coordinate:
int left = MAX( me.m_Pos.x, rect.m_Pos.x ); int left = MAX( me.m_Pos.x, rect.m_Pos.x );
// calculate the right common area coordinate: // calculate the right common area coordinate:
int right = MIN( me.m_Pos.x + m_Size.x, rect.m_Pos.x + rect.m_Size.x ); int right = MIN( me.m_Pos.x + me.m_Size.x, rect.m_Pos.x + rect.m_Size.x );
// calculate the upper common area coordinate: // calculate the upper common area coordinate:
int top = MAX( me.m_Pos.y, aRect.m_Pos.y ); int top = MAX( me.m_Pos.y, aRect.m_Pos.y );
// calculate the lower common area coordinate: // calculate the lower common area coordinate:
int bottom = MIN( me.m_Pos.y + m_Size.y, rect.m_Pos.y + rect.m_Size.y ); int bottom = MIN( me.m_Pos.y + me.m_Size.y, rect.m_Pos.y + rect.m_Size.y );
// if a common area exists, it must have a positive (null accepted) size // if a common area exists, it must have a positive (null accepted) size
if( left <= right && top <= bottom ) if( left <= right && top <= bottom )
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <gestfich.h> #include <gestfich.h>
#include <macros.h>
#include <kicad.h> #include <kicad.h>
#include <tree_project_frame.h> #include <tree_project_frame.h>
...@@ -214,8 +215,9 @@ bool TREEPROJECT_ITEM::Delete( bool check ) ...@@ -214,8 +215,9 @@ bool TREEPROJECT_ITEM::Delete( bool check )
/*******************************************/ /*******************************************/
/* delete a file */ /* delete a file */
{ {
wxMessageDialog dialog( m_Parent, wxString msg;
_ ("Do you really want to delete ") + GetFileName(), msg.Printf( _("Do you really want to delete '%s'"), GetChars(GetFileName() ) );
wxMessageDialog dialog( m_Parent, msg,
_( "Delete File" ), wxYES_NO | wxICON_QUESTION ); _( "Delete File" ), wxYES_NO | wxICON_QUESTION );
if( !check || wxID_YES == dialog.ShowModal() ) if( !check || wxID_YES == dialog.ShowModal() )
...@@ -264,7 +266,8 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) ...@@ -264,7 +266,8 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
ExecuteFile( m_Parent, EESCHEMA_EXE, FullFileName ); ExecuteFile( m_Parent, EESCHEMA_EXE, FullFileName );
break; break;
case TREE_PCB: case TREE_LEGACY_PCB:
case TREE_SEXP_PCB:
ExecuteFile( m_Parent, PCBNEW_EXE, FullFileName ); ExecuteFile( m_Parent, PCBNEW_EXE, FullFileName );
break; break;
......
...@@ -2,6 +2,30 @@ ...@@ -2,6 +2,30 @@
* @file class_treeprojectfiles.cpp * @file class_treeprojectfiles.cpp
* this is the wxTreeCtrl that shows a KiCad tree project files * this is the wxTreeCtrl that shows a KiCad tree project files
*/ */
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2012 Jean-Pierre Charras
* Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h> #include <fctsys.h>
...@@ -38,7 +62,8 @@ TREEPROJECTFILES::TREEPROJECTFILES( TREE_PROJECT_FRAME* parent ) : ...@@ -38,7 +62,8 @@ TREEPROJECTFILES::TREEPROJECTFILES( TREE_PROJECT_FRAME* parent ) :
m_ImageList->Add( KiBitmap( kicad_icon_small_xpm ) ); // TREE_PROJECT m_ImageList->Add( KiBitmap( kicad_icon_small_xpm ) ); // TREE_PROJECT
m_ImageList->Add( KiBitmap( eeschema_xpm ) ); // TREE_SCHEMA m_ImageList->Add( KiBitmap( eeschema_xpm ) ); // TREE_SCHEMA
m_ImageList->Add( KiBitmap( pcbnew_xpm ) ); // TREE_PCB m_ImageList->Add( KiBitmap( pcbnew_xpm ) ); // TREE_LEGACY_PCB
m_ImageList->Add( KiBitmap( pcbnew_xpm ) ); // TREE_SFMT_PCB
m_ImageList->Add( KiBitmap( icon_gerbview_small_xpm ) ); // TREE_GERBER m_ImageList->Add( KiBitmap( icon_gerbview_small_xpm ) ); // TREE_GERBER
m_ImageList->Add( KiBitmap( datasheet_xpm ) ); // TREE_PDF m_ImageList->Add( KiBitmap( datasheet_xpm ) ); // TREE_PDF
m_ImageList->Add( KiBitmap( icon_txt_xpm ) ); // TREE_TXT m_ImageList->Add( KiBitmap( icon_txt_xpm ) ); // TREE_TXT
......
...@@ -3,6 +3,31 @@ ...@@ -3,6 +3,31 @@
* @brief Frame showing fast launch buttons and messages box * @brief Frame showing fast launch buttons and messages box
*/ */
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2012 Jean-Pierre Charras
* Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h> #include <fctsys.h>
#include <macros.h> #include <macros.h>
......
...@@ -2,9 +2,29 @@ ...@@ -2,9 +2,29 @@
/* files-io.cpp */ /* files-io.cpp */
/****************/ /****************/
#ifdef __GNUG__ /*
#pragma implementation * This program source code file is part of KiCad, a free EDA CAD application.
#endif *
* Copyright (C) 2004-2012 Jean-Pierre Charras
* Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h> #include <fctsys.h>
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
...@@ -110,7 +130,8 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) ...@@ -110,7 +130,8 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event )
{ {
/* List of file extensions to save. */ /* List of file extensions to save. */
static const wxChar* extentionList[] = { static const wxChar* extentionList[] = {
wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.cmp" ), wxT( "*.brd" ), wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.cmp" ),
wxT( "*.brd" ), wxT( "*.kicad_brd" ),
wxT( "*.net" ), wxT( "*.pro" ), wxT( "*.pho" ), wxT( "*.py" ), wxT( "*.net" ), wxT( "*.pro" ), wxT( "*.pho" ), wxT( "*.py" ),
wxT( "*.pdf" ), wxT( "*.txt" ), wxT( "*.dcm" ), wxT( "*.pdf" ), wxT( "*.txt" ), wxT( "*.dcm" ),
NULL NULL
......
...@@ -157,7 +157,8 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, ...@@ -157,7 +157,8 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
enum TreeFileType { enum TreeFileType {
TREE_PROJECT = 1, TREE_PROJECT = 1,
TREE_SCHEMA, // Schematic file (.sch) TREE_SCHEMA, // Schematic file (.sch)
TREE_PCB, // board file (.brd) TREE_LEGACY_PCB, // board file (.brd) legacy format
TREE_SEXP_PCB, // board file (.kicad_brd) new s expression format
TREE_GERBER, // Gerber file (.pho, .g*) TREE_GERBER, // Gerber file (.pho, .g*)
TREE_PDF, // PDF file (.pdf) TREE_PDF, // PDF file (.pdf)
TREE_TXT, // ascii text file (.txt) TREE_TXT, // ascii text file (.txt)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004-2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2004-2012 Jean-Pierre Charras
* Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <confirm.h> #include <confirm.h>
#include <gestfich.h> #include <gestfich.h>
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
#include <macros.h>
#include <kicad.h> #include <kicad.h>
#include <tree_project_frame.h> #include <tree_project_frame.h>
...@@ -20,6 +21,8 @@ ...@@ -20,6 +21,8 @@
#include <wx/imaglist.h> #include <wx/imaglist.h>
#include <menus_helpers.h> #include <menus_helpers.h>
// TODO: use the wxString defined in wildcards_and_files_ext.h, when exists
const wxString PcbSexpFileExtension( wxT("kicad_brd") );
/* Note about the tree project build process: /* Note about the tree project build process:
* Building the tree project can be *very* long if there are a lot of subdirectories * Building the tree project can be *very* long if there are a lot of subdirectories
...@@ -39,7 +42,8 @@ const wxChar* s_AllowedExtensionsToList[] = ...@@ -39,7 +42,8 @@ const wxChar* s_AllowedExtensionsToList[] =
{ {
wxT( "^.*\\.pro$" ), wxT( "^.*\\.pro$" ),
wxT( "^.*\\.pdf$" ), wxT( "^.*\\.pdf$" ),
wxT( "^[^$].*\\.brd$" ), // Pcbnew files wxT( "^[^$].*\\.brd$" ), // Legacy Pcbnew files
wxT( "^[^$].*\\.kicad_brd$" ), // S format Pcbnew files
wxT( "^.*\\.net$" ), wxT( "^.*\\.net$" ),
wxT( "^.*\\.txt$" ), wxT( "^.*\\.txt$" ),
wxT( "^.*\\.pho$" ), // Gerber file (Kicad extension) wxT( "^.*\\.pho$" ), // Gerber file (Kicad extension)
...@@ -89,7 +93,7 @@ BEGIN_EVENT_TABLE( TREE_PROJECT_FRAME, wxSashLayoutWindow ) ...@@ -89,7 +93,7 @@ BEGIN_EVENT_TABLE( TREE_PROJECT_FRAME, wxSashLayoutWindow )
EVT_TREE_BEGIN_DRAG( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnDragStart ) EVT_TREE_BEGIN_DRAG( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnDragStart )
EVT_TREE_END_DRAG( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnDragEnd ) EVT_TREE_END_DRAG( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnDragEnd )
EVT_MENU( ID_PROJECT_TXTEDIT, TREE_PROJECT_FRAME::OnTxtEdit ) EVT_MENU( ID_PROJECT_TXTEDIT, TREE_PROJECT_FRAME::OnTxtEdit )
EVT_MENU( ID_PROJECT_NEWDIR, TREE_PROJECT_FRAME::OnNewDirectory ) EVT_MENU( ID_PROJECT_NEWDIR, TREE_PROJECT_FRAME::OnCreateNewDirectory )
EVT_MENU( ID_PROJECT_DELETE, TREE_PROJECT_FRAME::OnDeleteFile ) EVT_MENU( ID_PROJECT_DELETE, TREE_PROJECT_FRAME::OnDeleteFile )
EVT_MENU( ID_PROJECT_RENAME, TREE_PROJECT_FRAME::OnRenameFile ) EVT_MENU( ID_PROJECT_RENAME, TREE_PROJECT_FRAME::OnRenameFile )
END_EVENT_TABLE() END_EVENT_TABLE()
...@@ -155,12 +159,11 @@ TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) : ...@@ -155,12 +159,11 @@ TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) :
menu = m_ContextMenus[i]; menu = m_ContextMenus[i];
// ID_PROJECT_RENAME // ID_PROJECT_RENAME
item = new wxMenuItem( menu, item = new wxMenuItem( menu, ID_PROJECT_RENAME,
ID_PROJECT_RENAME,
TREE_DIRECTORY != i ? _( "&Rename file" ) : TREE_DIRECTORY != i ? _( "&Rename file" ) :
_( "&Rename directory" ), _( "&Rename directory" ),
TREE_DIRECTORY != i ? _( "Rename file" ) : TREE_DIRECTORY != i ? _( "Rename file" ) :
_( "&Rename directory" ) ); _( "Rename directory" ) );
item->SetBitmap( KiBitmap( right_xpm ) ); item->SetBitmap( KiBitmap( right_xpm ) );
menu->Append( item ); menu->Append( item );
...@@ -182,7 +185,7 @@ TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) : ...@@ -182,7 +185,7 @@ TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) :
TREE_DIRECTORY != i ? _( "&Delete File" ) : TREE_DIRECTORY != i ? _( "&Delete File" ) :
_( "&Delete Directory" ), _( "&Delete Directory" ),
TREE_DIRECTORY != i ? _( "Delete the File" ) : TREE_DIRECTORY != i ? _( "Delete the File" ) :
_( "&Delete the Directory and its content" ) ); _( "Delete the Directory and its content" ) );
item->SetBitmap( KiBitmap( delete_xpm ) ); item->SetBitmap( KiBitmap( delete_xpm ) );
menu->Append( item ); menu->Append( item );
} }
...@@ -321,50 +324,17 @@ wxMenu* TREE_PROJECT_FRAME::GetContextMenu( int type ) ...@@ -321,50 +324,17 @@ wxMenu* TREE_PROJECT_FRAME::GetContextMenu( int type )
/** /**
* @brief TODO * Called by the popup menu in the tree frame
* Creates a new subdirectory inside the current kicad project directory
* the user is prompted to enter a directory name
*/ */
/*****************************************************************************/ void TREE_PROJECT_FRAME::OnCreateNewDirectory( wxCommandEvent& event )
void TREE_PROJECT_FRAME::OnNewDirectory( wxCommandEvent& event )
/*****************************************************************************/
{ {
NewFile( TREE_DIRECTORY ); // Get the root directory name:
} TREEPROJECT_ITEM* treeData = GetSelectedData();
/**
* @brief TODO
*/
/*****************************************************************************/
void TREE_PROJECT_FRAME::NewFile( TreeFileType type )
/*****************************************************************************/
{
wxString mask = GetFileExt( type );
wxString wildcard = GetFileWildcard( type );
// Get the directory:
wxString dir;
wxString title;
TREEPROJECT_ITEM* treeData;
title = ( TREE_DIRECTORY != type ) ? _( "Create New File" ) :
_( "Create New Directory" );
treeData = GetSelectedData();
if( !treeData ) if( !treeData )
return; return;
dir = wxGetCwd() + wxFileName().GetPathSeparator() + treeData->GetDir();
// Ask for the new file name
wxString nameless_prj = NAMELESS_PROJECT;
nameless_prj += wxT(".") + mask;
wxFileDialog dlg( this, title, dir, nameless_prj,
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return;
TreeFileType rootType = treeData->GetType(); TreeFileType rootType = treeData->GetType();
wxTreeItemId root; wxTreeItemId root;
...@@ -375,34 +345,31 @@ void TREE_PROJECT_FRAME::NewFile( TreeFileType type ) ...@@ -375,34 +345,31 @@ void TREE_PROJECT_FRAME::NewFile( TreeFileType type )
else else
{ {
root = m_TreeProject->GetItemParent( m_TreeProject->GetSelection() ); root = m_TreeProject->GetItemParent( m_TreeProject->GetSelection() );
if( !root.IsOk() ) if( !root.IsOk() )
root = m_TreeProject->GetSelection(); root = m_TreeProject->GetSelection();
} }
NewFile( dlg.GetPath(), type, root ); // Ask for the new sub directory name
} wxString curr_dir = treeData->GetDir();
/** // Make the current subdir relative to the current path:
* @brief TODO if( !curr_dir.IsEmpty() ) // A subdir is selected
*/
/*****************************************************************************/
void TREE_PROJECT_FRAME::NewFile( const wxString& name,
TreeFileType type,
wxTreeItemId& root )
/*****************************************************************************/
{
if( TREE_DIRECTORY != type )
{
wxFile( name, wxFile::write );
}
else
{ {
wxMkdir( name ); curr_dir += wxFileName::GetPathSeparator();
curr_dir += wxT("dummy");
wxFileName fn(curr_dir);
fn.MakeRelativeTo();
curr_dir = fn.GetPath() + wxFileName::GetPathSeparator();
} }
wxString msg;
msg.Printf( wxT("Current working directory:\n%s"), GetChars( wxGetCwd() ) );
wxString subdir = wxGetTextFromUser( msg, _( "Create New Directory" ), curr_dir );
AddFile( name, root ); if( subdir.IsEmpty() )
return;
if( wxMkdir( subdir ) )
AddFileToTree( subdir, root );
} }
...@@ -425,10 +392,14 @@ wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type ) ...@@ -425,10 +392,14 @@ wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type )
ext = SchematicFileExtension; ext = SchematicFileExtension;
break; break;
case TREE_PCB: case TREE_LEGACY_PCB:
ext = PcbFileExtension; ext = PcbFileExtension;
break; break;
case TREE_SEXP_PCB:
ext = PcbSexpFileExtension;
break;
case TREE_GERBER: case TREE_GERBER:
ext = GerberFileExtension; ext = GerberFileExtension;
break; break;
...@@ -485,7 +456,8 @@ wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type ) ...@@ -485,7 +456,8 @@ wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type )
ext = SchematicFileWildcard; ext = SchematicFileWildcard;
break; break;
case TREE_PCB: case TREE_LEGACY_PCB:
case TREE_SEXP_PCB:
ext = PcbFileWildcard; ext = PcbFileWildcard;
break; break;
...@@ -530,7 +502,7 @@ wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type ) ...@@ -530,7 +502,7 @@ wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type )
/** /**
* Function AddFile * Function AddFileToTree
* @brief Add filename "name" to the tree \n * @brief Add filename "name" to the tree \n
* if name is a directory, add the sub directory file names * if name is a directory, add the sub directory file names
* @param aName = the filename or the dirctory name to add * @param aName = the filename or the dirctory name to add
...@@ -539,7 +511,7 @@ wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type ) ...@@ -539,7 +511,7 @@ wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type )
* false to stop file add. * false to stop file add.
* @return true if the file (or directory) is added. * @return true if the file (or directory) is added.
*/ */
bool TREE_PROJECT_FRAME::AddFile( const wxString& aName, bool TREE_PROJECT_FRAME::AddFileToTree( const wxString& aName,
wxTreeItemId& aRoot, bool aRecurse ) wxTreeItemId& aRoot, bool aRecurse )
{ {
wxTreeItemId cellule; wxTreeItemId cellule;
...@@ -681,7 +653,7 @@ bool TREE_PROJECT_FRAME::AddFile( const wxString& aName, ...@@ -681,7 +653,7 @@ bool TREE_PROJECT_FRAME::AddFile( const wxString& aName,
{ {
do // Add name in tree, but do not recurse do // Add name in tree, but do not recurse
{ {
AddFile( aName + sep + dir_filename, cellule, false ); AddFileToTree( aName + sep + dir_filename, cellule, false );
} while( dir.GetNext( &dir_filename ) ); } while( dir.GetNext( &dir_filename ) );
} }
...@@ -743,7 +715,7 @@ void TREE_PROJECT_FRAME::ReCreateTreePrj() ...@@ -743,7 +715,7 @@ void TREE_PROJECT_FRAME::ReCreateTreePrj()
while( cont ) while( cont )
{ {
if( filename != fn.GetFullName() ) if( filename != fn.GetFullName() )
AddFile( dir.GetName() + wxFileName::GetPathSeparator() + AddFileToTree( dir.GetName() + wxFileName::GetPathSeparator() +
filename, m_root ); filename, m_root );
cont = dir.GetNext( &filename ); cont = dir.GetNext( &filename );
...@@ -980,7 +952,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event ) ...@@ -980,7 +952,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
{ {
do // Add name to tree item, but do not recurse in subdirs: do // Add name to tree item, but do not recurse in subdirs:
{ {
AddFile( fileName + sep + dir_filename, kid, false ); AddFileToTree( fileName + sep + dir_filename, kid, false );
} while( dir.GetNext( &dir_filename ) ); } while( dir.GetNext( &dir_filename ) );
} }
itemData->m_WasPopulated = true; // set state to populated itemData->m_WasPopulated = true; // set state to populated
......
...@@ -47,9 +47,7 @@ private: ...@@ -47,9 +47,7 @@ private:
protected: protected:
wxMenu* GetContextMenu( int type ); wxMenu* GetContextMenu( int type );
void NewFile( TreeFileType type );
void NewFile( const wxString& name, TreeFileType type,
wxTreeItemId& root );
/** /**
* Function GetSelectedData * Function GetSelectedData
* return the item data from item currently selected (highlighted) * return the item data from item currently selected (highlighted)
...@@ -91,63 +89,28 @@ public: ...@@ -91,63 +89,28 @@ public:
void OnDeleteFile( wxCommandEvent& event ); void OnDeleteFile( wxCommandEvent& event );
void OnRenameFile( wxCommandEvent& event ); void OnRenameFile( wxCommandEvent& event );
void OnNewDirectory( wxCommandEvent& event ); /**
void OnNewPyFile( wxCommandEvent& event ); * Function OnCreateNewDirectory
* Creates a new subdirectory inside the current kicad project directory
* the user is prompted to enter a directory name
*/
void OnCreateNewDirectory( wxCommandEvent& event );
void ClearFilters(); void ClearFilters();
const std::vector<wxString>& GetFilters(); const std::vector<wxString>& GetFilters();
void RemoveFilter( const wxString& filter ); void RemoveFilter( const wxString& filter );
#ifdef KICAD_PYTHON
boost::python::object ToWx();
TREE_PROJECT_FRAME()
{
}
TREE_PROJECT_FRAME( const TREE_PROJECT_FRAME& )
{
}
void OnRunPy( wxCommandEvent& event );
boost::python::object GetMenuPy( TreeFileType );
boost::python::object GetFtExPy( TreeFileType ) const;
void RemoveFilterPy( const boost::python::str& filter );
void AddFilter( const boost::python::str& filter );
boost::python::object GetTreeCtrl();
TREEPROJECT_ITEM* GetItemData( const boost::python::object& item );
void AddFilePy( const boost::python::str& name,
boost::python::object& root );
void NewFilePy( const boost::python::str& name,
TreeFileType type,
boost::python::object& root );
TREEPROJECT_ITEM* FindItemData( const boost::python::str& name );
boost::python::object GetCurrentMenu();
int AddStatePy( boost::python::object& bitmap );
#endif
/** /**
* Function AddFile * Function AddFileToTree
* @brief Add filename "name" to the tree \n * @brief Add the file or directory aName to the project tree
* if name is a directory, add the sub directory file names * @param aName = the filename or the directory name to add in tree
* @param aName = the filename or the dirctory name to add
* @param aRoot = the wxTreeItemId item where to add sub tree items * @param aRoot = the wxTreeItemId item where to add sub tree items
* @param aRecurse = true to filenames or sub dir names to the current tree item * @param aRecurse = true to filenames or sub dir names to the current tree item
* false to stop file add. * false to stop file add.
* @return true if the file (or directory) is added. * @return true if the file (or directory) is added.
*/ */
bool AddFile( const wxString& aName, bool AddFileToTree( const wxString& aName,
wxTreeItemId& aRoot, bool aRecurse = true); wxTreeItemId& aRoot, bool aRecurse = true);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
......
...@@ -386,55 +386,55 @@ EDA_RECT DRAWSEGMENT::GetBoundingBox() const ...@@ -386,55 +386,55 @@ EDA_RECT DRAWSEGMENT::GetBoundingBox() const
switch( m_Shape ) switch( m_Shape )
{ {
case S_SEGMENT: case S_SEGMENT:
bbox.SetEnd( m_End ); bbox.SetEnd( m_End );
bbox.Inflate( (m_Width / 2) + 1 ); break;
break;
case S_CIRCLE:
bbox.Inflate( GetRadius() + 1 );
break;
case S_ARC: case S_CIRCLE:
{ bbox.Inflate( GetRadius() );
bbox.Merge( m_End ); break;
wxPoint end = m_End;
RotatePoint( &end, m_Start, -m_Angle );
bbox.Merge( end );
}
break;
case S_POLYGON: case S_ARC:
{ {
wxPoint p_end; bbox.Merge( m_End );
MODULE* module = GetParentModule(); wxPoint end = m_End;
RotatePoint( &end, m_Start, -m_Angle );
bbox.Merge( end );
}
break;
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) case S_POLYGON:
{ {
wxPoint pt = m_PolyPoints[ii]; wxPoint p_end;
MODULE* module = GetParentModule();
if( module ) // Transform, if we belong to a module for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
{ {
RotatePoint( &pt, module->GetOrientation() ); wxPoint pt = m_PolyPoints[ii];
pt += module->m_Pos;
}
if( ii == 0 ) if( module ) // Transform, if we belong to a module
p_end = pt; {
RotatePoint( &pt, module->GetOrientation() );
pt += module->m_Pos;
}
bbox.SetX( MIN( bbox.GetX(), pt.x ) ); if( ii == 0 )
bbox.SetY( MIN( bbox.GetY(), pt.y ) ); p_end = pt;
p_end.x = MAX( p_end.x, pt.x );
p_end.y = MAX( p_end.y, pt.y );
}
bbox.SetEnd( p_end ); bbox.SetX( MIN( bbox.GetX(), pt.x ) );
bbox.Inflate( 1 ); bbox.SetY( MIN( bbox.GetY(), pt.y ) );
break; p_end.x = MAX( p_end.x, pt.x );
} p_end.y = MAX( p_end.y, pt.y );
}
bbox.SetEnd( p_end );
break;
}
} }
bbox.Inflate( (m_Width+1) / 2 ); bbox.Inflate( ((m_Width+1) / 2) + 1 );
bbox.Normalize();
return bbox; return bbox;
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -25,62 +25,28 @@ ...@@ -25,62 +25,28 @@
<property name="use_enum">1</property> <property name="use_enum">1</property>
<property name="use_microsoft_bom">0</property> <property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1"> <object class="Dialog" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_managed">0</property> <property name="aui_managed">0</property>
<property name="aui_name"></property> <property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center"></property> <property name="center"></property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="event_handler">impl_virtual</property> <property name="event_handler">impl_virtual</property>
<property name="extra_style"></property> <property name="extra_style"></property>
<property name="fg"></property> <property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property> <property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE</property> <property name="name">DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size">611,346</property> <property name="size">611,346</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="title">General settings</property> <property name="title">General settings</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
...@@ -478,10 +444,6 @@ ...@@ -478,10 +444,6 @@
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
...@@ -567,10 +529,6 @@ ...@@ -567,10 +529,6 @@
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip">Adjust the number of ratsnets shown from cursor to closest pads</property> <property name="tooltip">Adjust the number of ratsnets shown from cursor to closest pads</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value">1</property> <property name="value">1</property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
...@@ -656,10 +614,6 @@ ...@@ -656,10 +614,6 @@
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
...@@ -745,10 +699,6 @@ ...@@ -745,10 +699,6 @@
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip">Delay after the first change to create a backup file of the board on disk.</property> <property name="tooltip">Delay after the first change to create a backup file of the board on disk.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value">0</property> <property name="value">0</property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
...@@ -834,10 +784,6 @@ ...@@ -834,10 +784,6 @@
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
...@@ -2111,10 +2057,6 @@ ...@@ -2111,10 +2057,6 @@
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
......
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project> <wxFormBuilder_Project>
<FileVersion major="1" minor="10" /> <FileVersion major="1" minor="11" />
<object class="Project" expanded="1"> <object class="Project" expanded="1">
<property name="class_decoration" /> <property name="class_decoration" />
<property name="code_generation">C++</property> <property name="code_generation">C++</property>
......
...@@ -302,7 +302,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -302,7 +302,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
} }
// Add graphic items (copper texts) and board edges // Add graphic items (copper texts) and board edges
for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() )
{ {
if( item->GetLayer() != GetLayer() && item->GetLayer() != EDGE_N ) if( item->GetLayer() != GetLayer() && item->GetLayer() != EDGE_N )
continue; continue;
......
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