Commit 0a055c04 authored by charras's avatar charras

kicad: cleaned code

parent 1a139a7f
No preview for this file type
This diff is collapsed.
...@@ -9,6 +9,7 @@ set(KICAD_SRCS ...@@ -9,6 +9,7 @@ set(KICAD_SRCS
commandframe.cpp commandframe.cpp
files-io.cpp files-io.cpp
kicad.cpp kicad.cpp
kicad-python.cpp
mainframe.cpp mainframe.cpp
preferences.cpp preferences.cpp
prjconfig.cpp prjconfig.cpp
......
...@@ -19,12 +19,8 @@ BEGIN_EVENT_TABLE( WinEDA_MainFrame, WinEDA_BasicFrame ) ...@@ -19,12 +19,8 @@ BEGIN_EVENT_TABLE( WinEDA_MainFrame, WinEDA_BasicFrame )
/* Window events */ /* Window events */
EVT_SIZE( WinEDA_MainFrame::OnSize ) EVT_SIZE( WinEDA_MainFrame::OnSize )
EVT_CLOSE( WinEDA_MainFrame::OnCloseWindow ) EVT_CLOSE( WinEDA_MainFrame::OnCloseWindow )
#if !defined(KICAD_AUIMANAGER)
/* Sash drag events */ /* Sash drag events */
EVT_SASH_DRAGGED( ID_LEFT_FRAME, WinEDA_MainFrame::OnSashDrag ) 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 */ /* Toolbar events */
EVT_TOOL( ID_NEW_PROJECT, WinEDA_MainFrame::OnLoadProject ) EVT_TOOL( ID_NEW_PROJECT, WinEDA_MainFrame::OnLoadProject )
EVT_TOOL( ID_LOAD_PROJECT, WinEDA_MainFrame::OnLoadProject ) EVT_TOOL( ID_LOAD_PROJECT, WinEDA_MainFrame::OnLoadProject )
......
...@@ -9,29 +9,55 @@ ...@@ -9,29 +9,55 @@
#include "kicad.h" #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 void RIGHT_KM_FRAME::OnSize( wxSizeEvent& event )
* create the window which the buttons to call eeschema and others...
*/
{ {
SetDefaultSize( wxSize( size.x, 100 ) ); #define EXTRA_MARGE 4
SetOrientation( wxLAYOUT_HORIZONTAL ); wxSize wsize = GetClientSize();
SetAlignment( wxLAYOUT_TOP ); wsize.x -= EXTRA_MARGE;
SetSashVisible( wxSASH_BOTTOM, TRUE ); wsize.y -= m_ButtonsPanelHeight + EXTRA_MARGE;
SetSashVisible( wxSASH_LEFT, TRUE ); wxPoint wpos;
SetExtraBorderSize( 2 ); wpos.x = EXTRA_MARGE/2;
CreateCommandToolbar(); 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 /** Function CreateCommandToolbar
...@@ -40,30 +66,28 @@ void WinEDA_CommandFrame::CreateCommandToolbar( void ) ...@@ -40,30 +66,28 @@ void WinEDA_CommandFrame::CreateCommandToolbar( void )
{ {
wxBitmapButton* btn; wxBitmapButton* btn;
m_ButtonSeparation = 10; wxWindow* parent = m_ButtPanel;
m_ButtonLastPosition.x = 20;
m_ButtonLastPosition.y = 20;
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)" ) ); btn->SetToolTip( _( "EESchema (Schematic editor)" ) );
AddFastLaunch( btn ); 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)" ) ); btn->SetToolTip( _( "CVpcb (Components to modules)" ) );
AddFastLaunch( btn ); 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)" ) ); btn->SetToolTip( _( "PCBnew (PCB editor)" ) );
AddFastLaunch( btn ); 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)" ) ); btn->SetToolTip( _( "GerbView (Gerber viewer)" ) );
AddFastLaunch( btn ); AddFastLaunch( btn );
// Set up toolbar // Set up toolbar
#ifdef KICAD_PYTHON #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" ) ); btn->SetToolTip( _( "Run Python Script" ) );
AddFastLaunch( btn ); AddFastLaunch( btn );
#endif #endif
...@@ -71,8 +95,9 @@ void WinEDA_CommandFrame::CreateCommandToolbar( void ) ...@@ -71,8 +95,9 @@ void WinEDA_CommandFrame::CreateCommandToolbar( void )
/****************************************************************/ /****************************************************************/
void WinEDA_CommandFrame::AddFastLaunch( wxBitmapButton * button ) void RIGHT_KM_FRAME::AddFastLaunch( wxBitmapButton* button )
/****************************************************************/ /****************************************************************/
/** Function AddFastLaunch /** Function AddFastLaunch
* add a Bitmap Button (fast launch button) to the window * add a Bitmap Button (fast launch button) to the window
* @param button = wxBitmapButton to add to the window * @param button = wxBitmapButton to add to the window
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#ifdef KICAD_PYTHON #ifdef KICAD_PYTHON
#include <pyhandler.h> #include <pyhandler.h>
using namespace boost::python;
#endif #endif
...@@ -45,324 +46,6 @@ void ShowLogo( char* FonteFileName ); ...@@ -45,324 +46,6 @@ void ShowLogo( char* FonteFileName );
IMPLEMENT_APP( WinEDA_App ) 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() bool WinEDA_App::OnInit()
/*****************************************************************************/ /*****************************************************************************/
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include "wxstruct.h" #include "wxstruct.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
class RIGHT_KM_FRAME;
class WinEDA_CommandFrame;
class WinEDA_TreePrj; class WinEDA_TreePrj;
class WinEDA_PrjFrame; class WinEDA_PrjFrame;
...@@ -33,10 +32,8 @@ class WinEDA_PrjFrame; ...@@ -33,10 +32,8 @@ class WinEDA_PrjFrame;
* new commands to Kicad. * new commands to Kicad.
*/ */
enum id_kicad_frm enum id_kicad_frm {
{
ID_LEFT_FRAME = ID_END_LIST, ID_LEFT_FRAME = ID_END_LIST,
ID_BOTTOM_FRAME,
ID_PROJECT_TREE, ID_PROJECT_TREE,
ID_PROJECT_TXTEDIT, ID_PROJECT_TXTEDIT,
ID_PROJECT_TREE_REFRESH, ID_PROJECT_TREE_REFRESH,
...@@ -49,7 +46,6 @@ enum id_kicad_frm ...@@ -49,7 +46,6 @@ enum id_kicad_frm
ID_PROJECT_RENAME, ID_PROJECT_RENAME,
ID_PROJECT_OPEN_FILE_WITH_TEXT_EDITOR, ID_PROJECT_OPEN_FILE_WITH_TEXT_EDITOR,
ID_MAIN_COMMAND,
ID_TO_EDITOR, ID_TO_EDITOR,
ID_TO_EESCHEMA, ID_TO_EESCHEMA,
ID_TO_GERBVIEW, ID_TO_GERBVIEW,
...@@ -71,18 +67,15 @@ class WinEDA_MainFrame : public WinEDA_BasicFrame ...@@ -71,18 +67,15 @@ class WinEDA_MainFrame : public WinEDA_BasicFrame
{ {
/* This class is the main entry point of the py API */ /* This class is the main entry point of the py API */
public: public:
WinEDA_CommandFrame* m_CommandWin;
WinEDA_PrjFrame* m_LeftWin; WinEDA_PrjFrame* m_LeftWin;
wxSashLayoutWindow* m_BottomWin; RIGHT_KM_FRAME* m_RightWin;
wxTextCtrl* m_DialogWin;
WinEDA_Toolbar* m_VToolBar; // Vertical toolbar (not used) WinEDA_Toolbar* m_VToolBar; // Vertical toolbar (not used)
wxString m_BoardFileName; wxString m_BoardFileName;
wxString m_SchematicRootFileName; wxString m_SchematicRootFileName;
wxFileName m_ProjectFileName; wxFileName m_ProjectFileName;
private:
int m_LeftWin_Width; int m_LeftWin_Width;
int m_CommandWin_Height;
public: public:
...@@ -91,6 +84,9 @@ public: ...@@ -91,6 +84,9 @@ public:
~WinEDA_MainFrame(); ~WinEDA_MainFrame();
/** Function CreateCommandToolbar
* Create the main buttons (fast launch buttons)
*/
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
void OnSize( wxSizeEvent& event ); void OnSize( wxSizeEvent& event );
void OnSashDrag( wxSashEvent& event ); void OnSashDrag( wxSashEvent& event );
...@@ -105,6 +101,7 @@ public: ...@@ -105,6 +101,7 @@ public:
#ifdef KICAD_PYTHON #ifdef KICAD_PYTHON
void OnRunPythonScript( wxCommandEvent& event ); void OnRunPythonScript( wxCommandEvent& event );
#endif #endif
void OnOpenTextEditor( wxCommandEvent& event ); void OnOpenTextEditor( wxCommandEvent& event );
...@@ -166,39 +163,29 @@ enum TreeFileType { ...@@ -166,39 +163,29 @@ enum TreeFileType {
TREE_MAX, TREE_MAX,
}; };
/** class RIGHT_KM_FRAME
/**************************************************************/
/* 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 WinEDA_CommandFrame : public wxSashLayoutWindow class RIGHT_KM_FRAME : public wxSashLayoutWindow
{ {
public: public:
WinEDA_CommandFrame( wxWindow* parent, int id, wxPoint pos, wxSize size, wxTextCtrl* m_DialogWin;
long style ); private:
~WinEDA_CommandFrame() 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: public:
void AddFastLaunch( wxBitmapButton * button ); RIGHT_KM_FRAME( WinEDA_MainFrame* parent );
~RIGHT_KM_FRAME() { };
void OnSize( wxSizeEvent& event );
private: private:
/** Function CreateCommandToolbar
* Create the main buttons (fast launch buttons)
*/
void CreateCommandToolbar( void ); void CreateCommandToolbar( void );
void AddFastLaunch( wxBitmapButton* button );
private: DECLARE_EVENT_TABLE()
wxPoint m_ButtonLastPosition; /** position of the last button in the window */
int m_ButtonSeparation; /** button distance in pixels */
}; };
...@@ -228,9 +215,9 @@ public: ...@@ -228,9 +215,9 @@ public:
TreePrjItemData() : m_Parent( NULL ) { } TreePrjItemData() : m_Parent( NULL ) { }
TreePrjItemData( const TreePrjItemData& src ) : TreePrjItemData( const TreePrjItemData& src ) :
m_Type( src.m_Type ) m_Type( src.m_Type ),
, m_FileName( src.m_FileName ) m_FileName( src.m_FileName ),
, m_Parent( src.m_Parent ) m_Parent( src.m_Parent )
{ {
SetState( src.m_State ); SetState( src.m_State );
} }
...@@ -260,7 +247,7 @@ public: ...@@ -260,7 +247,7 @@ public:
bool Rename( const wxString& name, bool check = true ); bool Rename( const wxString& name, bool check = true );
bool Delete( bool check = true ); bool Delete( bool check = true );
void Move( TreePrjItemData* dest ); void Move( TreePrjItemData* dest );
void Activate(WinEDA_PrjFrame* prjframe); void Activate( WinEDA_PrjFrame* prjframe );
const wxMenu* GetMenu() const wxMenu* GetMenu()
{ {
...@@ -315,8 +302,7 @@ public: ...@@ -315,8 +302,7 @@ public:
static wxString GetFileExt( TreeFileType type ); static wxString GetFileExt( TreeFileType type );
static wxString GetFileWildcard( TreeFileType type ); static wxString GetFileWildcard( TreeFileType type );
WinEDA_PrjFrame( WinEDA_MainFrame* parent, WinEDA_PrjFrame( WinEDA_MainFrame* parent );
const wxPoint& pos, const wxSize& size );
~WinEDA_PrjFrame(); ~WinEDA_PrjFrame();
void OnSelect( wxTreeEvent& Event ); void OnSelect( wxTreeEvent& Event );
void OnRenameAsk( wxTreeEvent& Event ); void OnRenameAsk( wxTreeEvent& Event );
......
This diff is collapsed.
...@@ -69,13 +69,11 @@ const wxString TextFileWildcard( wxT( "Text files (*.txt)|*.txt" ) ); ...@@ -69,13 +69,11 @@ const wxString TextFileWildcard( wxT( "Text files (*.txt)|*.txt" ) );
* @brief TODO * @brief TODO
*/ */
/******************************************************************/ /******************************************************************/
WinEDA_PrjFrame::WinEDA_PrjFrame( WinEDA_MainFrame* parent, WinEDA_PrjFrame::WinEDA_PrjFrame( WinEDA_MainFrame* parent ) :
const wxPoint& pos,
const wxSize& size ) :
wxSashLayoutWindow( parent, wxSashLayoutWindow( parent,
ID_LEFT_FRAME, ID_LEFT_FRAME,
pos, wxDefaultPosition,
size, wxDefaultSize,
wxNO_BORDER | wxSW_3D ) wxNO_BORDER | wxSW_3D )
/******************************************************************/ /******************************************************************/
{ {
......
...@@ -33,13 +33,8 @@ ...@@ -33,13 +33,8 @@
#include "PolyLine.h" #include "PolyLine.h"
// Kbool 1.9 and before had sometimes problemes when calculating thermal shapes as polygons (this is the best solution) // 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.0 has solved some problems, but not all
// Kbool 2.1 has solved some others 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 // Used to create data files to debug Kbool
#include "debug_kbool_key_file_fct.h" #include "debug_kbool_key_file_fct.h"
...@@ -67,14 +62,6 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer, ...@@ -67,14 +62,6 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
// Local Functions: // 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, void AddTrackWithClearancePolygon( Bool_Engine* aBooleng,
TRACK& aTrack, int aClearanceValue ); TRACK& aTrack, int aClearanceValue );
void AddPadWithClearancePolygon( Bool_Engine* aBooleng, D_PAD& aPad, int aClearanceValue ); void AddPadWithClearancePolygon( Bool_Engine* aBooleng, D_PAD& aPad, int aClearanceValue );
...@@ -251,15 +238,11 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -251,15 +238,11 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
} }
int gap = zone_clearance; int gap = zone_clearance;
#ifdef USE_STUBS_FOR_THERMAL
gap = MAX( zone_clearance, m_ThermalReliefGapValue );
#else
if( (m_PadOption == PAD_NOT_IN_ZONE) if( (m_PadOption == PAD_NOT_IN_ZONE)
|| (GetNet() == 0) || pad->m_PadShape == PAD_TRAPEZOID ) || (GetNet() == 0) || pad->m_PadShape == PAD_TRAPEZOID )
// PAD_TRAPEZOID shapes are not in zones because they are used in microwave apps // 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 // and i think it is good that shapes are not changed by thermal pads or others
#endif
{ {
item_boundingbox = pad->GetBoundingBox(); item_boundingbox = pad->GetBoundingBox();
if( item_boundingbox.Intersects( zone_boundingbox ) ) if( item_boundingbox.Intersects( zone_boundingbox ) )
...@@ -375,28 +358,6 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -375,28 +358,6 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
CopyPolygonsFromBoolengineToFilledPolysList( booleng ); CopyPolygonsFromBoolengineToFilledPolysList( booleng );
} }
delete 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: // Remove insulated islands:
if( GetNet() > 0 ) if( GetNet() > 0 )
...@@ -619,7 +580,6 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -619,7 +580,6 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
delete booleng; delete booleng;
#endif // REMOVE_UNUSED_THERMAL_STUBS #endif // REMOVE_UNUSED_THERMAL_STUBS
#endif // USE_STUBS_FOR_THERMAL
} }
...@@ -654,117 +614,6 @@ void AddPadWithClearancePolygon( Bool_Engine* aBooleng, ...@@ -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 /** function AddThermalReliefPadPolygon
* Add holes around a pad to create a thermal relief * 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