Commit 0a055c04 authored by charras's avatar charras

kicad: cleaned code

parent 1a139a7f
No preview for this file type
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -9,6 +9,7 @@ set(KICAD_SRCS
commandframe.cpp
files-io.cpp
kicad.cpp
kicad-python.cpp
mainframe.cpp
preferences.cpp
prjconfig.cpp
......
......@@ -19,12 +19,8 @@ BEGIN_EVENT_TABLE( WinEDA_MainFrame, WinEDA_BasicFrame )
/* Window events */
EVT_SIZE( WinEDA_MainFrame::OnSize )
EVT_CLOSE( WinEDA_MainFrame::OnCloseWindow )
#if !defined(KICAD_AUIMANAGER)
/* Sash drag events */
EVT_SASH_DRAGGED( ID_LEFT_FRAME, WinEDA_MainFrame::OnSashDrag )
EVT_SASH_DRAGGED( ID_BOTTOM_FRAME, WinEDA_MainFrame::OnSashDrag )
EVT_SASH_DRAGGED( ID_MAIN_COMMAND, WinEDA_MainFrame::OnSashDrag )
#endif
/* Toolbar events */
EVT_TOOL( ID_NEW_PROJECT, WinEDA_MainFrame::OnLoadProject )
EVT_TOOL( ID_LOAD_PROJECT, WinEDA_MainFrame::OnLoadProject )
......
......@@ -9,29 +9,55 @@
#include "kicad.h"
RIGHT_KM_FRAME::RIGHT_KM_FRAME( WinEDA_MainFrame* parent ) :
wxSashLayoutWindow( parent, wxID_ANY )
{
m_Parent = parent;
m_DialogWin = NULL;
m_ButtPanel = new wxPanel( this, wxID_ANY );
m_ButtonSeparation = 10; // control of command buttons position
m_ButtonLastPosition.x = 20; // control of command buttons position
m_ButtonLastPosition.y = 20; // control of command buttons position
m_ButtonsPanelHeight = (m_ButtonLastPosition.y * 2) + 32;
CreateCommandToolbar();
m_DialogWin = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY );
/************************************************************************************/
WinEDA_CommandFrame::WinEDA_CommandFrame( wxWindow* parent, int id,
wxPoint pos, wxSize size, long style ) :
wxSashLayoutWindow( parent, id, pos, size, style )
/************************************************************************************/
};
/** WinEDA_CommandFrame constructor
* create the window which the buttons to call eeschema and others...
*/
void RIGHT_KM_FRAME::OnSize( wxSizeEvent& event )
{
SetDefaultSize( wxSize( size.x, 100 ) );
SetOrientation( wxLAYOUT_HORIZONTAL );
SetAlignment( wxLAYOUT_TOP );
SetSashVisible( wxSASH_BOTTOM, TRUE );
SetSashVisible( wxSASH_LEFT, TRUE );
SetExtraBorderSize( 2 );
CreateCommandToolbar();
#define EXTRA_MARGE 4
wxSize wsize = GetClientSize();
wsize.x -= EXTRA_MARGE;
wsize.y -= m_ButtonsPanelHeight + EXTRA_MARGE;
wxPoint wpos;
wpos.x = EXTRA_MARGE/2;
wpos.y = m_ButtonsPanelHeight + (EXTRA_MARGE/2);
if( m_DialogWin )
{
m_DialogWin->SetSize( wsize );
m_DialogWin->SetPosition(wpos );
}
wpos.y = EXTRA_MARGE/2;
m_ButtPanel->SetPosition(wpos );
wsize.y -= m_ButtonsPanelHeight - EXTRA_MARGE;
m_ButtPanel->SetSize( wsize );
m_ButtPanel->Refresh();
event.Skip();
}
BEGIN_EVENT_TABLE( RIGHT_KM_FRAME, wxSashLayoutWindow )
EVT_SIZE( RIGHT_KM_FRAME::OnSize )
END_EVENT_TABLE()
/*************************************************/
void WinEDA_CommandFrame::CreateCommandToolbar( void )
void RIGHT_KM_FRAME::CreateCommandToolbar( void )
/*************************************************/
/** Function CreateCommandToolbar
......@@ -40,30 +66,28 @@ void WinEDA_CommandFrame::CreateCommandToolbar( void )
{
wxBitmapButton* btn;
m_ButtonSeparation = 10;
m_ButtonLastPosition.x = 20;
m_ButtonLastPosition.y = 20;
wxWindow* parent = m_ButtPanel;
btn = new wxBitmapButton( this, ID_TO_EESCHEMA, wxBitmap( icon_eeschema_xpm ) );
btn = new wxBitmapButton( parent, ID_TO_EESCHEMA, wxBitmap( icon_eeschema_xpm ) );
btn->SetToolTip( _( "EESchema (Schematic editor)" ) );
AddFastLaunch( btn );
btn = new wxBitmapButton( this, ID_TO_CVPCB, wxBitmap( icon_cvpcb_xpm ) );
btn = new wxBitmapButton( parent, ID_TO_CVPCB, wxBitmap( icon_cvpcb_xpm ) );
btn->SetToolTip( _( "CVpcb (Components to modules)" ) );
AddFastLaunch( btn );
btn = new wxBitmapButton( this, ID_TO_PCB, wxBitmap( a_icon_pcbnew_xpm ) );
btn = new wxBitmapButton( parent, ID_TO_PCB, wxBitmap( a_icon_pcbnew_xpm ) );
btn->SetToolTip( _( "PCBnew (PCB editor)" ) );
AddFastLaunch( btn );
btn = new wxBitmapButton( this, ID_TO_GERBVIEW, wxBitmap( icon_gerbview_xpm ) );
btn = new wxBitmapButton( parent, ID_TO_GERBVIEW, wxBitmap( icon_gerbview_xpm ) );
btn->SetToolTip( _( "GerbView (Gerber viewer)" ) );
AddFastLaunch( btn );
// Set up toolbar
#ifdef KICAD_PYTHON
btn = new wxBitmapButton( this, ID_RUN_PYTHON, wxBitmap( icon_python_xpm ) );
btn = new wxBitmapButton( parent, ID_RUN_PYTHON, wxBitmap( icon_python_xpm ) );
btn->SetToolTip( _( "Run Python Script" ) );
AddFastLaunch( btn );
#endif
......@@ -71,11 +95,12 @@ void WinEDA_CommandFrame::CreateCommandToolbar( void )
/****************************************************************/
void WinEDA_CommandFrame::AddFastLaunch( wxBitmapButton * button )
void RIGHT_KM_FRAME::AddFastLaunch( wxBitmapButton* button )
/****************************************************************/
/** Function AddFastLaunch
* add a Bitmap Button (fast launch button) to the window
* @param button = wxBitmapButton to add to the window
* add a Bitmap Button (fast launch button) to the window
* @param button = wxBitmapButton to add to the window
*/
{
button->Move( m_ButtonLastPosition );
......
......@@ -28,6 +28,7 @@
#ifdef KICAD_PYTHON
#include <pyhandler.h>
using namespace boost::python;
#endif
......@@ -45,324 +46,6 @@ void ShowLogo( char* FonteFileName );
IMPLEMENT_APP( WinEDA_App )
#ifdef KICAD_PYTHON
using namespace boost::python;
/*****************************************************************************/
// Global functions:
/*****************************************************************************/
static WinEDA_MainFrame& GetMainFrame()
{
return *( wxGetApp().m_MainFrame );
}
static void WinEDAPrint( str msg )
{
GetMainFrame().PrintMsg( PyHandler::MakeStr( msg ) + wxT( "\n" ) );
}
static void WinEDAClear()
{
GetMainFrame().ClearMsg();
}
static object GetTypeExt( enum TreeFileType type )
{
return PyHandler::Convert( WinEDA_PrjFrame::GetFileExt( type ) );
}
/*****************************************************************************/
// WinEDA_MainFrame Special binding functions:
// (one line functions are simple wrappers)
/*****************************************************************************/
object WinEDA_MainFrame::GetPrjName() const
{
return PyHandler::Convert( m_PrjFileName );
}
object WinEDA_MainFrame::ToWx()
{
return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) );
}
WinEDA_PrjFrame* WinEDA_MainFrame::GetTree() const
{
return m_LeftWin;
}
/**
* @brief TODO
*/
/*****************************************************************************/
void WinEDA_MainFrame::AddFastLaunchPy( object& button )
/*****************************************************************************/
{
wxBitmapButton* btn;
bool success = wxPyConvertSwigPtr( button.ptr(),
(void**) &btn, _T( "wxBitmapButton" ) );
if( !success )
return;
Py_INCREF( button.ptr() );
btn->Reparent( m_CommandWin );
m_CommandWin->AddFastLaunch( btn );
}
/*****************************************************************************/
// WinEDA_PrjFrame Special binding functions:
// (one line functions are simple wrappers)
/*****************************************************************************/
// TODO To WxWidgets ?
object WinEDA_PrjFrame::ToWx()
{
return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) );
}
// TODO Get ?
object WinEDA_PrjFrame::GetFtExPy( enum TreeFileType type ) const
{
return PyHandler::Convert( GetFileExt( type ) );
}
// Get python menu
object WinEDA_PrjFrame::GetMenuPy( enum TreeFileType type )
{
return object( handle<>( borrowed( wxPyMake_wxObject( GetContextMenu( (int) type ), false ) ) ) );
}
// Get tree control
object WinEDA_PrjFrame::GetTreeCtrl()
{
return object( handle<>( borrowed( wxPyMake_wxObject( m_TreeProject, false ) ) ) );
}
// Get current menu
object WinEDA_PrjFrame::GetCurrentMenu()
{
return object( handle<>( borrowed( wxPyMake_wxObject( m_PopupMenu, false ) ) ) );
}
/**
* @brief TODO
*/
/*****************************************************************************/
void WinEDA_PrjFrame::NewFilePy( const str& name,
enum TreeFileType type,
object& id )
/*****************************************************************************/
{
wxTreeItemId root;
if( !wxPyConvertSwigPtr( id.ptr(), (void**) &root, _T( "wxTreeItemId" ) ) )
return;
NewFile( PyHandler::MakeStr( name ), type, root );
}
/**
* @brief Add a file to the tree under root, or m_root if conversion is wrong
*/
/*****************************************************************************/
void WinEDA_PrjFrame::AddFilePy( const str& file, object& root )
/*****************************************************************************/
{
wxTreeItemId* theroot = &m_root;
if( !wxPyConvertSwigPtr( root.ptr(), (void**) &root, _T( "wxTreeItemId" ) ) )
{
theroot = &m_root;
}
AddFile( PyHandler::MakeStr( file ), *theroot );
}
/**
* @brief convert wxTreeItem into TreePrjItemData
*/
/*****************************************************************************/
TreePrjItemData* WinEDA_PrjFrame::GetItemData( const object& item )
/*****************************************************************************/
{
wxTreeItemId* id = NULL;
if( !wxPyConvertSwigPtr( item.ptr(), (void**) &id, _T( "wxTreeItemId" ) ) )
{
return NULL;
}
return dynamic_cast<TreePrjItemData*>( m_TreeProject->GetItemData( *id ) );
}
/*****************************************************************************/
// TreePrjItemData Special binding functions
// (one line functions are simple wrappers)
/*****************************************************************************/
// Python rename
bool TreePrjItemData::RenamePy( const str& newname, bool check )
{
return Rename( PyHandler::MakeStr( newname ), check );
}
// Get python directory
object TreePrjItemData::GetDirPy() const
{
return PyHandler::Convert( GetDir() );
}
// Get python filename
object TreePrjItemData::GetFileNamePy() const
{
return PyHandler::Convert( GetFileName() );
}
// Get python menu
object TreePrjItemData::GetMenuPy()
{
return object( handle<>( borrowed( wxPyMake_wxObject( &m_fileMenu, false ) ) ) );
}
/**
* @brief KiCad python module init, \n
* This function is called from PyHandler to init the kicad module
*/
/*****************************************************************************/
static void py_kicad_init()
/*****************************************************************************/
{
def( "GetMainFrame", &GetMainFrame,
return_value_policy< reference_existing_object >() );
def( "GetTypeExtension", &GetTypeExt );
class_<TreePrjItemData>( "PrjItem" )
// Internal data:
.def( "GetFileName", &TreePrjItemData::GetFileNamePy )
.def( "GetDir", &TreePrjItemData::GetDirPy )
.def( "GetType", &TreePrjItemData::GetType )
.def( "GetId", &TreePrjItemData::GetIdPy )
.def( "GetMenu", &TreePrjItemData::GetMenuPy )
// Item control
.def( "SetState", &TreePrjItemData::SetState )
.def( "Rename", &TreePrjItemData::RenamePy )
.def( "Move", &TreePrjItemData::Move )
.def( "Delete", &TreePrjItemData::Delete )
.def( "Activate", &TreePrjItemData::Activate )
;
enum_<TreeFileType>( "FileType" )
.value( "PROJECT", TREE_PROJECT )
.value( "SCHEMA", TREE_SCHEMA )
.value( "BOARD", TREE_PCB )
.value( "PYSCRIPT", TREE_PY )
.value( "GERBER", TREE_GERBER )
.value( "PDF", TREE_PDF )
.value( "TXT", TREE_TXT )
.value( "NETLIST", TREE_NET )
.value( "UNKNOWN", TREE_UNKNOWN )
.value( "DIRECTORY", TREE_DIRECTORY )
.value( "MAX", TREE_MAX );
class_<WinEDA_PrjFrame>( "TreeWindow" )
// wx Interface
.def( "ToWx", &WinEDA_PrjFrame::ToWx )
// common features
.def( "GetContextMenu", &WinEDA_PrjFrame::GetMenuPy )
.def( "GetFileExtension", &WinEDA_PrjFrame::GetFtExPy )
// file filters control
.def( "AddFilter", &WinEDA_PrjFrame::AddFilter )
.def( "ClearFilters", &WinEDA_PrjFrame::ClearFilters )
.def( "RemoveFilter", &WinEDA_PrjFrame::RemoveFilterPy )
.def( "GetFilters", &WinEDA_PrjFrame::GetFilters,
return_value_policy < copy_const_reference >() )
.def( "GetCurrentMenu", &WinEDA_PrjFrame::GetCurrentMenu )
/** Project tree control **/
// AddState
.def( "AddState",
&WinEDA_PrjFrame::AddStatePy )
// GetTreeCtrl
.def( "GetTreeCtrl",
&WinEDA_PrjFrame::GetTreeCtrl )
// GetItemData
.def( "GetItemData",
&WinEDA_PrjFrame::GetItemData,
return_value_policy < reference_existing_object >() )
// FindItemData
.def( "FindItemData",
&WinEDA_PrjFrame::FindItemData,
return_value_policy < reference_existing_object >() )
// NewFile
.def( "NewFile",
&WinEDA_PrjFrame::NewFilePy )
// AddFile
.def( "AddFile",
&WinEDA_PrjFrame::AddFilePy )
; /* ENDOF class_<WinEDA_PrjFrame>( "TreeWindow" ) */
class_<WinEDA_MainFrame>( "MainFrame" )
// Wx interface
.def( "ToWx", &WinEDA_MainFrame::ToWx )
// Common controls
.def( "AddFastLaunch", &WinEDA_MainFrame::AddFastLaunchPy )
.def( "Refresh", &WinEDA_MainFrame::OnRefreshPy )
.def( "GetProjectName", &WinEDA_MainFrame::GetPrjName )
.def( "GetProjectWindow", &WinEDA_MainFrame::GetTree,
return_value_policy< reference_existing_object >() );
}
/**
* @brief Common python module init
*/
/*****************************************************************************/
static void py_common_init()
/*****************************************************************************/
{
def( "Print", &WinEDAPrint );
def( "Clear", &WinEDAClear );
}
#endif
/*****************************************************************************/
bool WinEDA_App::OnInit()
/*****************************************************************************/
......
......@@ -19,8 +19,7 @@
#include "wxstruct.h"
#include "appl_wxstruct.h"
class WinEDA_CommandFrame;
class RIGHT_KM_FRAME;
class WinEDA_TreePrj;
class WinEDA_PrjFrame;
......@@ -33,10 +32,8 @@ class WinEDA_PrjFrame;
* new commands to Kicad.
*/
enum id_kicad_frm
{
enum id_kicad_frm {
ID_LEFT_FRAME = ID_END_LIST,
ID_BOTTOM_FRAME,
ID_PROJECT_TREE,
ID_PROJECT_TXTEDIT,
ID_PROJECT_TREE_REFRESH,
......@@ -49,7 +46,6 @@ enum id_kicad_frm
ID_PROJECT_RENAME,
ID_PROJECT_OPEN_FILE_WITH_TEXT_EDITOR,
ID_MAIN_COMMAND,
ID_TO_EDITOR,
ID_TO_EESCHEMA,
ID_TO_GERBVIEW,
......@@ -71,18 +67,15 @@ class WinEDA_MainFrame : public WinEDA_BasicFrame
{
/* This class is the main entry point of the py API */
public:
WinEDA_PrjFrame* m_LeftWin;
RIGHT_KM_FRAME* m_RightWin;
WinEDA_Toolbar* m_VToolBar; // Vertical toolbar (not used)
wxString m_BoardFileName;
wxString m_SchematicRootFileName;
wxFileName m_ProjectFileName;
WinEDA_CommandFrame* m_CommandWin;
WinEDA_PrjFrame* m_LeftWin;
wxSashLayoutWindow* m_BottomWin;
wxTextCtrl* m_DialogWin;
WinEDA_Toolbar* m_VToolBar; // Vertical toolbar (not used)
wxString m_BoardFileName;
wxString m_SchematicRootFileName;
wxFileName m_ProjectFileName;
int m_LeftWin_Width;
int m_CommandWin_Height;
private:
int m_LeftWin_Width;
public:
......@@ -91,59 +84,63 @@ public:
~WinEDA_MainFrame();
void OnCloseWindow( wxCloseEvent& Event );
void OnSize( wxSizeEvent& event );
void OnSashDrag( wxSashEvent& event );
void OnLoadProject( wxCommandEvent& event );
void OnSaveProject( wxCommandEvent& event );
void OnArchiveFiles( wxCommandEvent& event );
void OnUnarchiveFiles( wxCommandEvent& event );
void OnRunPcbNew( wxCommandEvent& event );
void OnRunCvpcb( wxCommandEvent& event );
void OnRunEeschema( wxCommandEvent& event );
void OnRunGerbview( wxCommandEvent& event );
/** Function CreateCommandToolbar
* Create the main buttons (fast launch buttons)
*/
void OnCloseWindow( wxCloseEvent& Event );
void OnSize( wxSizeEvent& event );
void OnSashDrag( wxSashEvent& event );
void OnLoadProject( wxCommandEvent& event );
void OnSaveProject( wxCommandEvent& event );
void OnArchiveFiles( wxCommandEvent& event );
void OnUnarchiveFiles( wxCommandEvent& event );
void OnRunPcbNew( wxCommandEvent& event );
void OnRunCvpcb( wxCommandEvent& event );
void OnRunEeschema( wxCommandEvent& event );
void OnRunGerbview( wxCommandEvent& event );
#ifdef KICAD_PYTHON
void OnRunPythonScript( wxCommandEvent& event );
void OnRunPythonScript( wxCommandEvent& event );
#endif
void OnOpenTextEditor( wxCommandEvent& event );
void OnOpenFileInTextEditor( wxCommandEvent& event );
void OnOpenFileInEditor( wxCommandEvent& event );
void OnOpenTextEditor( wxCommandEvent& event );
void OnOpenFileInTextEditor( wxCommandEvent& event );
void OnOpenFileInEditor( wxCommandEvent& event );
void OnFileHistory( wxCommandEvent& event );
void OnExit( wxCommandEvent& event );
void Process_Preferences( wxCommandEvent& event );
void ReCreateMenuBar();
void RecreateBaseHToolbar();
void PrintMsg( const wxString& text );
void ClearMsg();
void SetLanguage( wxCommandEvent& event );
void OnRefresh( wxCommandEvent& event );
void OnSelectDefaultPdfBrowser( wxCommandEvent& event );
void OnSelectPreferredPdfBrowser( wxCommandEvent& event );
void OnSelectPreferredEditor( wxCommandEvent& event );
void OnFileHistory( wxCommandEvent& event );
void OnExit( wxCommandEvent& event );
void Process_Preferences( wxCommandEvent& event );
void ReCreateMenuBar();
void RecreateBaseHToolbar();
void PrintMsg( const wxString& text );
void ClearMsg();
void SetLanguage( wxCommandEvent& event );
void OnRefresh( wxCommandEvent& event );
void OnSelectDefaultPdfBrowser( wxCommandEvent& event );
void OnSelectPreferredPdfBrowser( wxCommandEvent& event );
void OnSelectPreferredEditor( wxCommandEvent& event );
void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event );
void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event );
void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event );
void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event );
void CreateNewProject( const wxString PrjFullFileName );
void CreateNewProject( const wxString PrjFullFileName );
void LoadSettings();
void SaveSettings();
void LoadSettings();
void SaveSettings();
#ifdef KICAD_PYTHON
void OnRefreshPy();
void OnRefreshPy();
boost::python::object GetPrjName() const;
boost::python::object GetPrjName() const;
WinEDA_MainFrame( const WinEDA_MainFrame& ) { }
WinEDA_MainFrame() { }
boost::python::object ToWx();
void AddFastLaunchPy( boost::python::object& button );
WinEDA_PrjFrame* GetTree() const;
boost::python::object ToWx();
void AddFastLaunchPy( boost::python::object& button );
WinEDA_PrjFrame* GetTree() const;
#endif
......@@ -166,39 +163,29 @@ enum TreeFileType {
TREE_MAX,
};
/**************************************************************/
/* class WinEDA_CommandFrame: window handling command buttons */
/**************************************************************/
/** class WinEDA_CommandFrame
* This is the window handling the main tools to launch eeschema, cvpcb,
* pcbnew and gerbview
/** class RIGHT_KM_FRAME
*/
class WinEDA_CommandFrame : public wxSashLayoutWindow
class RIGHT_KM_FRAME : public wxSashLayoutWindow
{
public:
WinEDA_CommandFrame( wxWindow* parent, int id, wxPoint pos, wxSize size,
long style );
~WinEDA_CommandFrame()
{ }
wxTextCtrl* m_DialogWin;
private:
WinEDA_MainFrame* m_Parent;
int m_ButtonsPanelHeight;
wxPanel* m_ButtPanel;
wxPoint m_ButtonLastPosition; /* position of the last button in the window */
int m_ButtonSeparation; /* button distance in pixels */
/** Function AddFastLaunch
* add a Bitmap Button (fast launch button) to the window
*/
public:
void AddFastLaunch( wxBitmapButton * button );
RIGHT_KM_FRAME( WinEDA_MainFrame* parent );
~RIGHT_KM_FRAME() { };
void OnSize( wxSizeEvent& event );
private:
void CreateCommandToolbar( void );
void AddFastLaunch( wxBitmapButton* button );
/** Function CreateCommandToolbar
* Create the main buttons (fast launch buttons)
*/
void CreateCommandToolbar( void );
private:
wxPoint m_ButtonLastPosition; /** position of the last button in the window */
int m_ButtonSeparation; /** button distance in pixels */
DECLARE_EVENT_TABLE()
};
......@@ -228,9 +215,9 @@ public:
TreePrjItemData() : m_Parent( NULL ) { }
TreePrjItemData( const TreePrjItemData& src ) :
m_Type( src.m_Type )
, m_FileName( src.m_FileName )
, m_Parent( src.m_Parent )
m_Type( src.m_Type ),
m_FileName( src.m_FileName ),
m_Parent( src.m_Parent )
{
SetState( src.m_State );
}
......@@ -254,13 +241,13 @@ public:
}
wxString GetDir() const;
wxString GetDir() const;
void OnRename( wxTreeEvent& event, bool check = true );
bool Rename( const wxString& name, bool check = true );
bool Delete( bool check = true );
void Move( TreePrjItemData* dest );
void Activate(WinEDA_PrjFrame* prjframe);
void OnRename( wxTreeEvent& event, bool check = true );
bool Rename( const wxString& name, bool check = true );
bool Delete( bool check = true );
void Move( TreePrjItemData* dest );
void Activate( WinEDA_PrjFrame* prjframe );
const wxMenu* GetMenu()
{
......@@ -268,18 +255,18 @@ public:
}
void SetState( int state );
void SetState( int state );
#ifdef KICAD_PYTHON
boost::python::object GetFileNamePy() const;
bool RenamePy( const boost::python::str& newname,
bool check = true );
boost::python::object GetFileNamePy() const;
bool RenamePy( const boost::python::str& newname,
bool check = true );
boost::python::object GetDirPy() const;
boost::python::object GetDirPy() const;
boost::python::object GetIdPy() const;
boost::python::object GetIdPy() const;
boost::python::object GetMenuPy();
boost::python::object GetMenuPy();
#endif
};
......@@ -291,19 +278,19 @@ class WinEDA_PrjFrame : public wxSashLayoutWindow
{
private:
std::vector<wxMenu*> m_ContextMenus;
std::vector<wxString> m_Filters;
std::vector<wxMenu*> m_ContextMenus;
std::vector<wxString> m_Filters;
wxMenu* m_PopupMenu;
wxCursor m_DragCursor;
wxCursor m_Default;
protected:
wxMenu* GetContextMenu( int type );
void NewFile( TreeFileType type );
void NewFile( const wxString& name, TreeFileType type,
wxTreeItemId& root );
TreePrjItemData* GetSelectedData();
wxMenu* GetContextMenu( int type );
void NewFile( TreeFileType type );
void NewFile( const wxString& name, TreeFileType type,
wxTreeItemId& root );
TreePrjItemData* GetSelectedData();
public:
WinEDA_MainFrame* m_Parent;
......@@ -312,41 +299,40 @@ public:
wxTreeItemId m_root;
public:
static wxString GetFileExt( TreeFileType type );
static wxString GetFileWildcard( TreeFileType type );
static wxString GetFileExt( TreeFileType type );
static wxString GetFileWildcard( TreeFileType type );
WinEDA_PrjFrame( WinEDA_MainFrame* parent,
const wxPoint& pos, const wxSize& size );
WinEDA_PrjFrame( WinEDA_MainFrame* parent );
~WinEDA_PrjFrame();
void OnSelect( wxTreeEvent& Event );
void OnRenameAsk( wxTreeEvent& Event );
void OnRename( wxTreeEvent& Event );
void OnDragStart( wxTreeEvent& event );
void OnDragEnd( wxTreeEvent& event );
void OnRight( wxTreeEvent& Event );
void ReCreateTreePrj();
void OnSelect( wxTreeEvent& Event );
void OnRenameAsk( wxTreeEvent& Event );
void OnRename( wxTreeEvent& Event );
void OnDragStart( wxTreeEvent& event );
void OnDragEnd( wxTreeEvent& event );
void OnRight( wxTreeEvent& Event );
void ReCreateTreePrj();
void OnTxtEdit( wxCommandEvent& event );
void OnTxtEdit( wxCommandEvent& event );
void OnDeleteFile( wxCommandEvent& event );
void OnRenameFile( wxCommandEvent& event );
void OnDeleteFile( wxCommandEvent& event );
void OnRenameFile( wxCommandEvent& event );
void OnNewFile( wxCommandEvent& event );
void OnNewDirectory( wxCommandEvent& event );
void OnNewSchFile( wxCommandEvent& event );
void OnNewBrdFile( wxCommandEvent& event );
void OnNewPyFile( wxCommandEvent& event );
void OnNewGerberFile( wxCommandEvent& event );
void OnNewTxtFile( wxCommandEvent& event );
void OnNewNetFile( wxCommandEvent& event );
void OnNewFile( wxCommandEvent& event );
void OnNewDirectory( wxCommandEvent& event );
void OnNewSchFile( wxCommandEvent& event );
void OnNewBrdFile( wxCommandEvent& event );
void OnNewPyFile( wxCommandEvent& event );
void OnNewGerberFile( wxCommandEvent& event );
void OnNewTxtFile( wxCommandEvent& event );
void OnNewNetFile( wxCommandEvent& event );
void ClearFilters();
void ClearFilters();
const std::vector<wxString>& GetFilters();
void RemoveFilter( const wxString& filter );
const std::vector<wxString>& GetFilters();
void RemoveFilter( const wxString& filter );
#ifdef KICAD_PYTHON
boost::python::object ToWx();
boost::python::object ToWx();
WinEDA_PrjFrame()
{
......@@ -358,31 +344,31 @@ public:
}
void OnRunPy( wxCommandEvent& event );
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 );
void RemoveFilterPy( const boost::python::str& filter );
void AddFilter( const boost::python::str& filter );
boost::python::object GetTreeCtrl();
TreePrjItemData* 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 );
boost::python::object GetTreeCtrl();
TreePrjItemData* 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 );
TreePrjItemData* FindItemData( const boost::python::str& name );
TreePrjItemData* FindItemData( const boost::python::str& name );
boost::python::object GetCurrentMenu();
int AddStatePy( boost::python::object& bitmap );
boost::python::object GetCurrentMenu();
int AddStatePy( boost::python::object& bitmap );
#endif
bool AddFile( const wxString& name, wxTreeItemId& root );
bool AddFile( const wxString& name, wxTreeItemId& root );
DECLARE_EVENT_TABLE()
};
......
......@@ -17,31 +17,31 @@
#include "confirm.h"
#include "gestfich.h"
#include "bitmaps.h"
#include "macros.h"
#include "kicad.h"
static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) );
static const wxString CommandFrameWidthEntry( wxT( "CommandWinWidth" ) );
WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size ) :
const wxPoint& pos,
const wxSize& size ) :
WinEDA_BasicFrame( parent, KICAD_MAIN_FRAME, title, pos, size )
{
wxString msg;
wxString line;
wxSize clientsize;
m_FrameName = wxT( "KicadFrame" );
m_VToolBar = NULL;
m_LeftWin = NULL;
m_BottomWin = NULL;
m_CommandWin = NULL;
m_LeftWin_Width = 200;
m_CommandWin_Height = 82;
wxString msg;
wxString line;
wxSize clientsize;
m_FrameName = wxT( "KicadFrame" );
m_VToolBar = NULL; // No Vertical tooolbar used here
m_LeftWin = NULL; // A shashwindow that contains the project tree
m_RightWin = NULL; /* A shashwindow that contains the buttons
* and the window display text
*/
m_LeftWin_Width = MAX(60, GetSize().x/3 );
LoadSettings();
......@@ -55,47 +55,28 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
// Give an icon
#ifdef __WINDOWS__
SetIcon( wxICON( a_kicad_icon ) );
SetIcon( wxICON( a_kicad_icon ) );
#else
SetIcon( wxICON( kicad_icon ) );
SetIcon( wxICON( kicad_icon ) );
#endif
clientsize = GetClientSize();
int rightWinWidth = clientsize.x - m_LeftWin_Width;
// Left window: is the box which display tree project
m_LeftWin = new WinEDA_PrjFrame( this, wxDefaultPosition, wxDefaultSize );
m_LeftWin = new WinEDA_PrjFrame( this );
m_LeftWin->SetDefaultSize( wxSize( m_LeftWin_Width, clientsize.y ) );
m_LeftWin->SetOrientation( wxLAYOUT_VERTICAL );
m_LeftWin->SetAlignment( wxLAYOUT_LEFT );
m_LeftWin->SetSashVisible( wxSASH_RIGHT, TRUE );
m_LeftWin->SetExtraBorderSize( 2 );
#if !defined(KICAD_AUIMANAGER)
// Bottom Window: box to display messages
m_BottomWin = new wxSashLayoutWindow( this, ID_BOTTOM_FRAME,
wxDefaultPosition, wxDefaultSize,
wxNO_BORDER | wxSW_3D );
m_BottomWin->SetDefaultSize( wxSize( clientsize.x, 150 ) );
m_BottomWin->SetOrientation( wxLAYOUT_HORIZONTAL );
m_BottomWin->SetAlignment ( wxLAYOUT_BOTTOM );
m_BottomWin->SetSashVisible( wxSASH_TOP, TRUE );
m_BottomWin->SetSashVisible( wxSASH_LEFT, TRUE );
m_BottomWin->SetExtraBorderSize( 2 );
m_DialogWin = new wxTextCtrl( m_BottomWin, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxNO_BORDER | wxTE_READONLY );
#else
m_DialogWin = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxNO_BORDER | wxTE_READONLY );
#endif
// m_CommandWin is the box with buttons which launch eechema, pcbnew ...
m_CommandWin = new WinEDA_CommandFrame( this, ID_MAIN_COMMAND,
wxPoint( m_LeftWin_Width, 0 ),
wxSize( clientsize.x,
m_CommandWin_Height ),
wxNO_BORDER | wxSW_3D );
m_RightWin = new RIGHT_KM_FRAME( this );
m_RightWin->SetDefaultSize( wxSize( rightWinWidth, clientsize.y ) );
m_RightWin->SetOrientation( wxLAYOUT_VERTICAL );
m_RightWin->SetAlignment( wxLAYOUT_RIGHT );
m_RightWin->SetExtraBorderSize( 2 );
msg = wxGetCwd();
line.Printf( _( "Ready\nWorking dir: %s\n" ), msg.GetData() );
......@@ -108,32 +89,30 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
#if defined(KICAD_AUIMANAGER)
RecreateBaseHToolbar();
m_auimgr.SetManagedWindow(this);
m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz;
horiz.Gripper(false);
horiz.DockFixed(true);
horiz.Movable(false);
horiz.Floatable(false);
horiz.CloseButton(false);
horiz.CaptionVisible(false);
wxAuiPaneInfo vert(horiz);
horiz.Gripper( false );
horiz.DockFixed( true );
horiz.Movable( false );
horiz.Floatable( false );
horiz.CloseButton( false );
horiz.CaptionVisible( false );
vert.TopDockable(false).BottomDockable(false);
horiz.LeftDockable(false).RightDockable(false);
wxAuiPaneInfo vert( horiz );
m_auimgr.AddPane(m_HToolBar,
wxAuiPaneInfo(horiz).Name(wxT("m_HToolBar")).Top());
vert.TopDockable( false ).BottomDockable( false );
horiz.LeftDockable( false ).RightDockable( false );
m_auimgr.AddPane(m_CommandWin,
wxAuiPaneInfo().Name(wxT("m_CommandWin")).CentrePane());
m_auimgr.AddPane( m_HToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top() );
m_auimgr.AddPane(m_DialogWin,
wxAuiPaneInfo(horiz).Name(wxT("m_DialogWin")).CentrePane());
m_auimgr.AddPane( m_RightWin,
wxAuiPaneInfo().Name( wxT( "m_RightWin" ) ).CentrePane() );
m_auimgr.AddPane(m_LeftWin,
wxAuiPaneInfo(horiz).Name(wxT("m_LeftWin")).Left().BestSize(clientsize.x/3,clientsize.y));
m_auimgr.AddPane( m_LeftWin,
wxAuiPaneInfo( horiz ).Name( wxT( "m_LeftWin" ) ).
Left().BestSize( m_LeftWin_Width, clientsize.y ) );
m_auimgr.Update();
#endif
}
......@@ -144,7 +123,7 @@ WinEDA_MainFrame::~WinEDA_MainFrame()
/*****************************************************************************/
{
#if defined(KICAD_AUIMANAGER)
m_auimgr.UnInit();
m_auimgr.UnInit();
#endif
}
......@@ -152,14 +131,12 @@ m_auimgr.UnInit();
/*******************************************************/
void WinEDA_MainFrame::PrintMsg( const wxString& text )
/*******************************************************/
/*
* Put text in the dialog frame
*/
{
m_DialogWin->AppendText( text );
#ifdef DEBUG
printf("%s\n", (const char*)text.mb_str() );
#endif
m_RightWin->m_DialogWin->AppendText( text );
}
......@@ -170,43 +147,19 @@ void WinEDA_MainFrame::OnSashDrag( wxSashEvent& event )
/* Resize windows when dragging window borders
*/
{
int w, h;
wxSize newsize;
#if defined(KICAD_AUIMANAGER)
#else
if( event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE )
return;
GetClientSize( &w, &h );
switch( event.GetId() )
{
case ID_LEFT_FRAME:
{
m_LeftWin->SetDefaultSize( wxSize( event.GetDragRect().width, -1 ) );
break;
}
case ID_BOTTOM_FRAME:
{
newsize = event.GetDragRect().GetSize();
m_LeftWin->SetDefaultSize( wxSize( w - newsize.x, -1 ) );
m_BottomWin->SetDefaultSize( wxSize( -1, newsize.y ) );
m_CommandWin->SetDefaultSize( wxSize( -1, h - newsize.y ) );
break;
}
case ID_MAIN_COMMAND:
{
newsize = event.GetDragRect().GetSize();
m_LeftWin->SetDefaultSize( wxSize( w - newsize.x, -1 ) );
m_CommandWin->SetDefaultSize( wxSize( -1, newsize.y ) );
m_BottomWin->SetDefaultSize( wxSize( -1, h - newsize.y ) );
break;
}
}
m_LeftWin_Width = event.GetDragRect().width;
m_LeftWin->SetDefaultSize( wxSize( m_LeftWin_Width, -1 ) );
wxLayoutAlgorithm layout;
layout.LayoutFrame( this );
#endif
event.Skip();
}
......@@ -216,30 +169,13 @@ void WinEDA_MainFrame::OnSize( wxSizeEvent& event )
/************************************************/
{
#if defined(KICAD_AUIMANAGER)
if(m_auimgr.GetManagedWindow())
m_auimgr.Update();
#else
if( m_CommandWin && m_BottomWin )
{
int w, h, dy;
wxSize bsize, hsize;
GetClientSize( &w, &h );
bsize = m_BottomWin->GetSize();
hsize = m_CommandWin->GetSize();
dy = h - hsize.y;
if( dy < 50 )
{
dy = 50;
hsize.y = h - dy;
}
m_CommandWin->SetDefaultSize( wxSize( -1, hsize.y ) );
m_BottomWin->SetDefaultSize( wxSize( -1, dy ) );
}
if( m_auimgr.GetManagedWindow() )
m_auimgr.Update();
#else
wxLayoutAlgorithm layout;
layout.LayoutFrame( this );
if( m_CommandWin )
m_CommandWin->Refresh( TRUE );
#endif
event.Skip();
}
......@@ -276,7 +212,7 @@ void WinEDA_MainFrame::OnCloseWindow( wxCloseEvent& Event )
wxGetApp().m_HtmlCtrl = NULL;
}
m_LeftWin->Show(false);
m_LeftWin->Show( false );
Destroy();
}
......@@ -291,6 +227,7 @@ void WinEDA_MainFrame::OnExit( wxCommandEvent& event )
void WinEDA_MainFrame::OnRunPcbNew( wxCommandEvent& event )
{
wxFileName fn( m_ProjectFileName );
fn.SetExt( BoardFileExtension );
ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( fn ) );
}
......@@ -299,6 +236,7 @@ void WinEDA_MainFrame::OnRunPcbNew( wxCommandEvent& event )
void WinEDA_MainFrame::OnRunCvpcb( wxCommandEvent& event )
{
wxFileName fn( m_ProjectFileName );
fn.SetExt( NetlistFileExtension );
ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) );
}
......@@ -307,6 +245,7 @@ void WinEDA_MainFrame::OnRunCvpcb( wxCommandEvent& event )
void WinEDA_MainFrame::OnRunEeschema( wxCommandEvent& event )
{
wxFileName fn( m_ProjectFileName );
fn.SetExt( SchematicFileExtension );
ExecuteFile( this, EESCHEMA_EXE, QuoteFullPath( fn ) );
}
......@@ -315,8 +254,9 @@ void WinEDA_MainFrame::OnRunEeschema( wxCommandEvent& event )
void WinEDA_MainFrame::OnRunGerbview( wxCommandEvent& event )
{
wxFileName fn( m_ProjectFileName );
ExecuteFile( this, GERBVIEW_EXE,
fn.GetPath( wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME ) );
fn.GetPath( wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME ) );
}
......@@ -341,12 +281,15 @@ void WinEDA_MainFrame::OnRunPythonScript( wxCommandEvent& event )
PyHandler::GetInstance()->RunScript( dlg.GetPath() );
}
#endif
void WinEDA_MainFrame::OnOpenFileInTextEditor( wxCommandEvent& event )
{
wxString mask( wxT( "*" ) );
#ifdef __WINDOWS__
mask += wxT( ".*" );
#endif
......@@ -354,12 +297,12 @@ void WinEDA_MainFrame::OnOpenFileInTextEditor( wxCommandEvent& event )
mask = _( "Text file (" ) + mask + wxT( ")|" ) + mask;
wxFileDialog dlg( this, _( "Load File to Edit" ), wxGetCwd(),
wxEmptyString, mask,wxFD_OPEN );
wxEmptyString, mask, wxFD_OPEN );
if( dlg.ShowModal() == wxID_CANCEL )
return;
if( ! dlg.GetPath().IsEmpty() && ! wxGetApp().GetEditorName().IsEmpty() )
if( !dlg.GetPath().IsEmpty() && !wxGetApp().GetEditorName().IsEmpty() )
ExecuteFile( this, wxGetApp().GetEditorName(), dlg.GetPath() );
}
......@@ -372,12 +315,11 @@ void WinEDA_MainFrame::OnRefresh( wxCommandEvent& event )
}
/*********************************/
void WinEDA_MainFrame::ClearMsg()
/*********************************/
{
m_DialogWin->Clear();
m_RightWin->m_DialogWin->Clear();
}
......@@ -395,7 +337,6 @@ void WinEDA_MainFrame::LoadSettings()
WinEDA_BasicFrame::LoadSettings();
cfg->Read( TreeFrameWidthEntry, &m_LeftWin_Width );
cfg->Read( CommandFrameWidthEntry, &m_CommandWin_Height );
}
......@@ -414,7 +355,6 @@ void WinEDA_MainFrame::SaveSettings()
WinEDA_BasicFrame::SaveSettings();
cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x );
cfg->Write( CommandFrameWidthEntry, m_CommandWin->GetSize().y );
}
......@@ -425,4 +365,6 @@ void WinEDA_MainFrame::OnRefreshPy()
{
m_LeftWin->ReCreateTreePrj();
}
#endif
......@@ -69,13 +69,11 @@ const wxString TextFileWildcard( wxT( "Text files (*.txt)|*.txt" ) );
* @brief TODO
*/
/******************************************************************/
WinEDA_PrjFrame::WinEDA_PrjFrame( WinEDA_MainFrame* parent,
const wxPoint& pos,
const wxSize& size ) :
WinEDA_PrjFrame::WinEDA_PrjFrame( WinEDA_MainFrame* parent ) :
wxSashLayoutWindow( parent,
ID_LEFT_FRAME,
pos,
size,
wxDefaultPosition,
wxDefaultSize,
wxNO_BORDER | wxSW_3D )
/******************************************************************/
{
......
......@@ -33,13 +33,8 @@
#include "PolyLine.h"
// Kbool 1.9 and before had sometimes problemes when calculating thermal shapes as polygons (this is the best solution)
// So as a workaround we can use stubs (small tracks segments) to create thermal shape
// Define USE_STUBS_FOR_THERMAL to work on this workaround
// Currently only for tests: DO NOT USE
// because the code is not really tested, pcbnew can do not work properly when used
// Kbool 2.0 has solved some problems, but not all
// Kbool 2.1 has solved some others problems, but not all
//define USE_STUBS_FOR_THERMAL
// Used to create data files to debug Kbool
#include "debug_kbool_key_file_fct.h"
......@@ -67,14 +62,6 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
// Local Functions:
#ifdef USE_STUBS_FOR_THERMAL
#warning \
USE_STUBS_FOR_THERMAL is defined: for test version only do not use for working pcbnew version
void CreateStubsForThermalShapes( BOARD* aPcb, ZONE_CONTAINER* aZone_container,
int aThermalGap,
int aCopperThickness, int aMinThicknessValue );
#endif
void AddTrackWithClearancePolygon( Bool_Engine* aBooleng,
TRACK& aTrack, int aClearanceValue );
void AddPadWithClearancePolygon( Bool_Engine* aBooleng, D_PAD& aPad, int aClearanceValue );
......@@ -251,15 +238,11 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
}
int gap = zone_clearance;
#ifdef USE_STUBS_FOR_THERMAL
gap = MAX( zone_clearance, m_ThermalReliefGapValue );
#else
if( (m_PadOption == PAD_NOT_IN_ZONE)
|| (GetNet() == 0) || pad->m_PadShape == PAD_TRAPEZOID )
// PAD_TRAPEZOID shapes are not in zones because they are used in microwave apps
// and i think it is good that shapes are not changed by thermal pads or others
#endif
{
item_boundingbox = pad->GetBoundingBox();
if( item_boundingbox.Intersects( zone_boundingbox ) )
......@@ -375,28 +358,6 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
CopyPolygonsFromBoolengineToFilledPolysList( booleng );
}
delete booleng;
#ifdef USE_STUBS_FOR_THERMAL
// remove thermal gaps if required:
if( m_PadOption != THERMAL_PAD || aPcb->m_Modules == NULL )
{
Test_For_Copper_Island_And_Remove_Insulated_Islands( aPcb );
return;
}
#ifdef CREATE_KBOOL_KEY_FILES
CreateKeyFileKeyFile();
OpenKeyFileEntity( "Layer" );
CopyPolygonsFromFilledPolysListToKeyFile( this, 0 );
#endif
CreateStubsForThermalShapes( aPcb, this, m_ThermalReliefGapValue,
m_ThermalReliefCopperBridgeValue, m_ZoneMinThickness );
Test_For_Copper_Island_And_Remove_Insulated_Islands( aPcb );
#ifdef CREATE_KBOOL_KEY_FILES
CloseKeyFileEntity();
CloseKeyFile();
#endif
#else
// Remove insulated islands:
if( GetNet() > 0 )
......@@ -619,7 +580,6 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
delete booleng;
#endif // REMOVE_UNUSED_THERMAL_STUBS
#endif // USE_STUBS_FOR_THERMAL
}
......@@ -654,117 +614,6 @@ void AddPadWithClearancePolygon( Bool_Engine* aBooleng,
}
/** function CreateStubsForThermalShapes()
* Only for testing the thermal shapes by stubs purposes
* Do not use for working pcbnew versions
* This is just for kbool test only
*/
void CreateStubsForThermalShapes( BOARD* aPcb, ZONE_CONTAINER* aZone_container,
int aThermalGap,
int aCopperThickness, int aMinThicknessValue )
{
EDA_Rect zone_boundingbox = aZone_container->GetBoundingBox();
bool have_poly_to_add = false;
Bool_Engine* booleng = new Bool_Engine();
ArmBoolEng( booleng, true );
TRACK dummy_track( aPcb );
if( aCopperThickness <= aMinThicknessValue )
return;
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
{
for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{
// check
if( !pad->IsOnLayer( aZone_container->GetLayer() ) )
continue;
if( pad->GetNet() != aZone_container->GetNet() )
continue;
EDA_Rect item_boundingbox = pad->GetBoundingBox();
item_boundingbox.Inflate( aThermalGap, aThermalGap );
if( !( item_boundingbox.Intersects( zone_boundingbox ) ) )
continue;
// test point
int dx = ( pad->m_Size.x / 2 ) + aThermalGap;
int dy = ( pad->m_Size.y / 2 ) + aThermalGap;
// This is CIRCLE pad tweak (for circle pads the thermal stubs are at 45 deg)
int fAngle = pad->m_Orient;
if( pad->m_PadShape == PAD_CIRCLE )
{
dx = (int) ( dx * s_Correction );
dy = dx;
fAngle = 450;
}
// compute north, south, west and east points for zone connection.
// Add a small value to ensure point is inside (or outside) zone, not on an edge
wxPoint ptTest[4];
ptTest[0] = wxPoint( 0, 3 + dy + aMinThicknessValue / 2 );
ptTest[1] = wxPoint( 0, -(3 + dy + aMinThicknessValue / 2) );
ptTest[2] = wxPoint( 3 + dx + aMinThicknessValue / 2, 0 );
ptTest[3] = wxPoint( -(3 + dx + aMinThicknessValue / 2), 0 );
// Test all sides
for( int i = 0; i<4; i++ )
{
// rotate point
RotatePoint( &ptTest[i], fAngle );
// translate point
ptTest[i] += pad->ReturnShapePos();
bool inside = aZone_container->HitTestFilledArea( ptTest[i] );
if( inside )
{
dummy_track.m_Start = pad->ReturnShapePos();
dummy_track.m_End = ptTest[i];
dummy_track.SetNet( aZone_container->GetNet() );
dummy_track.SetLayer( aZone_container->GetLayer() );
dummy_track.m_Width = aCopperThickness;
dummy_track.SetState( BEGIN_ONPAD, ON );
dummy_track.start = pad;
// add stub
WinEDA_PcbFrame* pcbFrame = (WinEDA_PcbFrame*) aPcb->m_PcbFrame;
if( pcbFrame->GetDrcController()->Drc( &dummy_track, aPcb->m_Track ) == OK_DRC )
{
have_poly_to_add = true;
// because stubs outlines are drawn with a pen size = aMinThicknessValue,
// the width of the stub is aCopperThickness - aMinThicknessValue
int thickness = dummy_track.m_Width - aMinThicknessValue;
AddRoundedEndsSegmentPolygon( booleng,
dummy_track.m_Start,
dummy_track.m_End,
thickness );
}
}
}
}
}
if( have_poly_to_add )
{
/* Add the main corrected polygon (i.e. the filled area using only one outline)
* in GroupA in Bool_Engine
*/
aZone_container->CopyPolygonsFromFilledPolysListToBoolengine( booleng, GROUP_A );
/* remove thermal areas (non copper areas) */
booleng->Do_Operation( BOOL_OR );
/* put these areas in m_FilledPolysList */
aZone_container->m_FilledPolysList.clear();
aZone_container->CopyPolygonsFromBoolengineToFilledPolysList( booleng );
}
delete booleng;
}
/** function AddThermalReliefPadPolygon
* Add holes around a pad to create a thermal relief
......
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