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 ...@@ -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,11 +95,12 @@ void WinEDA_CommandFrame::CreateCommandToolbar( void ) ...@@ -71,11 +95,12 @@ 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
*/ */
{ {
button->Move( m_ButtonLastPosition ); button->Move( m_ButtonLastPosition );
......
...@@ -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_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; private:
WinEDA_PrjFrame* m_LeftWin; int m_LeftWin_Width;
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;
public: public:
...@@ -91,59 +84,63 @@ public: ...@@ -91,59 +84,63 @@ public:
~WinEDA_MainFrame(); ~WinEDA_MainFrame();
void OnCloseWindow( wxCloseEvent& Event ); /** Function CreateCommandToolbar
void OnSize( wxSizeEvent& event ); * Create the main buttons (fast launch buttons)
void OnSashDrag( wxSashEvent& event ); */
void OnLoadProject( wxCommandEvent& event ); void OnCloseWindow( wxCloseEvent& Event );
void OnSaveProject( wxCommandEvent& event ); void OnSize( wxSizeEvent& event );
void OnArchiveFiles( wxCommandEvent& event ); void OnSashDrag( wxSashEvent& event );
void OnUnarchiveFiles( wxCommandEvent& event ); void OnLoadProject( wxCommandEvent& event );
void OnRunPcbNew( wxCommandEvent& event ); void OnSaveProject( wxCommandEvent& event );
void OnRunCvpcb( wxCommandEvent& event ); void OnArchiveFiles( wxCommandEvent& event );
void OnRunEeschema( wxCommandEvent& event ); void OnUnarchiveFiles( wxCommandEvent& event );
void OnRunGerbview( wxCommandEvent& event ); void OnRunPcbNew( wxCommandEvent& event );
void OnRunCvpcb( wxCommandEvent& event );
void OnRunEeschema( wxCommandEvent& event );
void OnRunGerbview( wxCommandEvent& event );
#ifdef KICAD_PYTHON #ifdef KICAD_PYTHON
void OnRunPythonScript( wxCommandEvent& event ); void OnRunPythonScript( wxCommandEvent& event );
#endif #endif
void OnOpenTextEditor( wxCommandEvent& event ); void OnOpenTextEditor( wxCommandEvent& event );
void OnOpenFileInTextEditor( wxCommandEvent& event ); void OnOpenFileInTextEditor( wxCommandEvent& event );
void OnOpenFileInEditor( wxCommandEvent& event ); void OnOpenFileInEditor( wxCommandEvent& event );
void OnFileHistory( wxCommandEvent& event ); void OnFileHistory( wxCommandEvent& event );
void OnExit( wxCommandEvent& event ); void OnExit( wxCommandEvent& event );
void Process_Preferences( wxCommandEvent& event ); void Process_Preferences( wxCommandEvent& event );
void ReCreateMenuBar(); void ReCreateMenuBar();
void RecreateBaseHToolbar(); void RecreateBaseHToolbar();
void PrintMsg( const wxString& text ); void PrintMsg( const wxString& text );
void ClearMsg(); void ClearMsg();
void SetLanguage( wxCommandEvent& event ); void SetLanguage( wxCommandEvent& event );
void OnRefresh( wxCommandEvent& event ); void OnRefresh( wxCommandEvent& event );
void OnSelectDefaultPdfBrowser( wxCommandEvent& event ); void OnSelectDefaultPdfBrowser( wxCommandEvent& event );
void OnSelectPreferredPdfBrowser( wxCommandEvent& event ); void OnSelectPreferredPdfBrowser( wxCommandEvent& event );
void OnSelectPreferredEditor( wxCommandEvent& event ); void OnSelectPreferredEditor( wxCommandEvent& event );
void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event ); void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event );
void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event ); void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event );
void CreateNewProject( const wxString PrjFullFileName ); void CreateNewProject( const wxString PrjFullFileName );
void LoadSettings(); void LoadSettings();
void SaveSettings(); void SaveSettings();
#ifdef KICAD_PYTHON #ifdef KICAD_PYTHON
void OnRefreshPy(); void OnRefreshPy();
boost::python::object GetPrjName() const; boost::python::object GetPrjName() const;
WinEDA_MainFrame( const WinEDA_MainFrame& ) { } WinEDA_MainFrame( const WinEDA_MainFrame& ) { }
WinEDA_MainFrame() { } WinEDA_MainFrame() { }
boost::python::object ToWx(); boost::python::object ToWx();
void AddFastLaunchPy( boost::python::object& button ); void AddFastLaunchPy( boost::python::object& button );
WinEDA_PrjFrame* GetTree() const; WinEDA_PrjFrame* GetTree() const;
#endif #endif
...@@ -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:
void CreateCommandToolbar( void );
void AddFastLaunch( wxBitmapButton* button );
/** Function CreateCommandToolbar DECLARE_EVENT_TABLE()
* 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 */
}; };
...@@ -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 );
} }
...@@ -254,13 +241,13 @@ public: ...@@ -254,13 +241,13 @@ public:
} }
wxString GetDir() const; wxString GetDir() const;
void OnRename( wxTreeEvent& event, bool check = true ); void OnRename( wxTreeEvent& event, bool check = true );
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()
{ {
...@@ -268,18 +255,18 @@ public: ...@@ -268,18 +255,18 @@ public:
} }
void SetState( int state ); void SetState( int state );
#ifdef KICAD_PYTHON #ifdef KICAD_PYTHON
boost::python::object GetFileNamePy() const; boost::python::object GetFileNamePy() const;
bool RenamePy( const boost::python::str& newname, bool RenamePy( const boost::python::str& newname,
bool check = true ); 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 #endif
}; };
...@@ -291,19 +278,19 @@ class WinEDA_PrjFrame : public wxSashLayoutWindow ...@@ -291,19 +278,19 @@ class WinEDA_PrjFrame : public wxSashLayoutWindow
{ {
private: private:
std::vector<wxMenu*> m_ContextMenus; std::vector<wxMenu*> m_ContextMenus;
std::vector<wxString> m_Filters; std::vector<wxString> m_Filters;
wxMenu* m_PopupMenu; wxMenu* m_PopupMenu;
wxCursor m_DragCursor; wxCursor m_DragCursor;
wxCursor m_Default; wxCursor m_Default;
protected: protected:
wxMenu* GetContextMenu( int type ); wxMenu* GetContextMenu( int type );
void NewFile( TreeFileType type ); void NewFile( TreeFileType type );
void NewFile( const wxString& name, TreeFileType type, void NewFile( const wxString& name, TreeFileType type,
wxTreeItemId& root ); wxTreeItemId& root );
TreePrjItemData* GetSelectedData(); TreePrjItemData* GetSelectedData();
public: public:
WinEDA_MainFrame* m_Parent; WinEDA_MainFrame* m_Parent;
...@@ -312,41 +299,40 @@ public: ...@@ -312,41 +299,40 @@ public:
wxTreeItemId m_root; wxTreeItemId m_root;
public: 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 );
void OnRename( wxTreeEvent& Event ); void OnRename( wxTreeEvent& Event );
void OnDragStart( wxTreeEvent& event ); void OnDragStart( wxTreeEvent& event );
void OnDragEnd( wxTreeEvent& event ); void OnDragEnd( wxTreeEvent& event );
void OnRight( wxTreeEvent& Event ); void OnRight( wxTreeEvent& Event );
void ReCreateTreePrj(); void ReCreateTreePrj();
void OnTxtEdit( wxCommandEvent& event ); void OnTxtEdit( wxCommandEvent& event );
void OnDeleteFile( wxCommandEvent& event ); void OnDeleteFile( wxCommandEvent& event );
void OnRenameFile( wxCommandEvent& event ); void OnRenameFile( wxCommandEvent& event );
void OnNewFile( wxCommandEvent& event ); void OnNewFile( wxCommandEvent& event );
void OnNewDirectory( wxCommandEvent& event ); void OnNewDirectory( wxCommandEvent& event );
void OnNewSchFile( wxCommandEvent& event ); void OnNewSchFile( wxCommandEvent& event );
void OnNewBrdFile( wxCommandEvent& event ); void OnNewBrdFile( wxCommandEvent& event );
void OnNewPyFile( wxCommandEvent& event ); void OnNewPyFile( wxCommandEvent& event );
void OnNewGerberFile( wxCommandEvent& event ); void OnNewGerberFile( wxCommandEvent& event );
void OnNewTxtFile( wxCommandEvent& event ); void OnNewTxtFile( wxCommandEvent& event );
void OnNewNetFile( wxCommandEvent& event ); void OnNewNetFile( 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 #ifdef KICAD_PYTHON
boost::python::object ToWx(); boost::python::object ToWx();
WinEDA_PrjFrame() WinEDA_PrjFrame()
{ {
...@@ -358,31 +344,31 @@ public: ...@@ -358,31 +344,31 @@ public:
} }
void OnRunPy( wxCommandEvent& event ); void OnRunPy( wxCommandEvent& event );
boost::python::object GetMenuPy( TreeFileType ); boost::python::object GetMenuPy( TreeFileType );
boost::python::object GetFtExPy( TreeFileType ) const; boost::python::object GetFtExPy( TreeFileType ) const;
void RemoveFilterPy( const boost::python::str& filter ); void RemoveFilterPy( const boost::python::str& filter );
void AddFilter( const boost::python::str& filter ); void AddFilter( const boost::python::str& filter );
boost::python::object GetTreeCtrl(); boost::python::object GetTreeCtrl();
TreePrjItemData* GetItemData( const boost::python::object& item ); TreePrjItemData* GetItemData( const boost::python::object& item );
void AddFilePy( const boost::python::str& name, void AddFilePy( const boost::python::str& name,
boost::python::object& root ); boost::python::object& root );
void NewFilePy( const boost::python::str& name, void NewFilePy( const boost::python::str& name,
TreeFileType type, TreeFileType type,
boost::python::object& root ); boost::python::object& root );
TreePrjItemData* FindItemData( const boost::python::str& name ); TreePrjItemData* FindItemData( const boost::python::str& name );
boost::python::object GetCurrentMenu(); boost::python::object GetCurrentMenu();
int AddStatePy( boost::python::object& bitmap ); int AddStatePy( boost::python::object& bitmap );
#endif #endif
bool AddFile( const wxString& name, wxTreeItemId& root ); bool AddFile( const wxString& name, wxTreeItemId& root );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
......
...@@ -17,31 +17,31 @@ ...@@ -17,31 +17,31 @@
#include "confirm.h" #include "confirm.h"
#include "gestfich.h" #include "gestfich.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "macros.h"
#include "kicad.h" #include "kicad.h"
static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) ); 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 wxString& title,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size ) : const wxSize& size ) :
WinEDA_BasicFrame( parent, KICAD_MAIN_FRAME, title, pos, size ) WinEDA_BasicFrame( parent, KICAD_MAIN_FRAME, title, pos, size )
{ {
wxString msg; wxString msg;
wxString line; wxString line;
wxSize clientsize; wxSize clientsize;
m_FrameName = wxT( "KicadFrame" ); m_FrameName = wxT( "KicadFrame" );
m_VToolBar = NULL; m_VToolBar = NULL; // No Vertical tooolbar used here
m_LeftWin = NULL; m_LeftWin = NULL; // A shashwindow that contains the project tree
m_BottomWin = NULL; m_RightWin = NULL; /* A shashwindow that contains the buttons
m_CommandWin = NULL; * and the window display text
m_LeftWin_Width = 200; */
m_CommandWin_Height = 82; m_LeftWin_Width = MAX(60, GetSize().x/3 );
LoadSettings(); LoadSettings();
...@@ -55,47 +55,28 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, ...@@ -55,47 +55,28 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
// Give an icon // Give an icon
#ifdef __WINDOWS__ #ifdef __WINDOWS__
SetIcon( wxICON( a_kicad_icon ) ); SetIcon( wxICON( a_kicad_icon ) );
#else #else
SetIcon( wxICON( kicad_icon ) ); SetIcon( wxICON( kicad_icon ) );
#endif #endif
clientsize = GetClientSize(); clientsize = GetClientSize();
int rightWinWidth = clientsize.x - m_LeftWin_Width;
// Left window: is the box which display tree project // 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->SetDefaultSize( wxSize( m_LeftWin_Width, clientsize.y ) );
m_LeftWin->SetOrientation( wxLAYOUT_VERTICAL ); m_LeftWin->SetOrientation( wxLAYOUT_VERTICAL );
m_LeftWin->SetAlignment( wxLAYOUT_LEFT ); m_LeftWin->SetAlignment( wxLAYOUT_LEFT );
m_LeftWin->SetSashVisible( wxSASH_RIGHT, TRUE ); m_LeftWin->SetSashVisible( wxSASH_RIGHT, TRUE );
m_LeftWin->SetExtraBorderSize( 2 ); m_LeftWin->SetExtraBorderSize( 2 );
#if !defined(KICAD_AUIMANAGER)
// Bottom Window: box to display messages // Bottom Window: box to display messages
m_BottomWin = new wxSashLayoutWindow( this, ID_BOTTOM_FRAME, m_RightWin = new RIGHT_KM_FRAME( this );
wxDefaultPosition, wxDefaultSize, m_RightWin->SetDefaultSize( wxSize( rightWinWidth, clientsize.y ) );
wxNO_BORDER | wxSW_3D ); m_RightWin->SetOrientation( wxLAYOUT_VERTICAL );
m_BottomWin->SetDefaultSize( wxSize( clientsize.x, 150 ) ); m_RightWin->SetAlignment( wxLAYOUT_RIGHT );
m_BottomWin->SetOrientation( wxLAYOUT_HORIZONTAL ); m_RightWin->SetExtraBorderSize( 2 );
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 );
msg = wxGetCwd(); msg = wxGetCwd();
line.Printf( _( "Ready\nWorking dir: %s\n" ), msg.GetData() ); line.Printf( _( "Ready\nWorking dir: %s\n" ), msg.GetData() );
...@@ -108,32 +89,30 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, ...@@ -108,32 +89,30 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
#if defined(KICAD_AUIMANAGER) #if defined(KICAD_AUIMANAGER)
RecreateBaseHToolbar(); RecreateBaseHToolbar();
m_auimgr.SetManagedWindow(this); m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz; wxAuiPaneInfo horiz;
horiz.Gripper(false); horiz.Gripper( false );
horiz.DockFixed(true); horiz.DockFixed( true );
horiz.Movable(false); horiz.Movable( false );
horiz.Floatable(false); horiz.Floatable( false );
horiz.CloseButton(false); horiz.CloseButton( false );
horiz.CaptionVisible(false); horiz.CaptionVisible( false );
wxAuiPaneInfo vert(horiz);
vert.TopDockable(false).BottomDockable(false); wxAuiPaneInfo vert( horiz );
horiz.LeftDockable(false).RightDockable(false);
m_auimgr.AddPane(m_HToolBar, vert.TopDockable( false ).BottomDockable( false );
wxAuiPaneInfo(horiz).Name(wxT("m_HToolBar")).Top()); horiz.LeftDockable( false ).RightDockable( false );
m_auimgr.AddPane(m_CommandWin, m_auimgr.AddPane( m_HToolBar,
wxAuiPaneInfo().Name(wxT("m_CommandWin")).CentrePane()); wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top() );
m_auimgr.AddPane(m_DialogWin, m_auimgr.AddPane( m_RightWin,
wxAuiPaneInfo(horiz).Name(wxT("m_DialogWin")).CentrePane()); wxAuiPaneInfo().Name( wxT( "m_RightWin" ) ).CentrePane() );
m_auimgr.AddPane(m_LeftWin, m_auimgr.AddPane( m_LeftWin,
wxAuiPaneInfo(horiz).Name(wxT("m_LeftWin")).Left().BestSize(clientsize.x/3,clientsize.y)); wxAuiPaneInfo( horiz ).Name( wxT( "m_LeftWin" ) ).
Left().BestSize( m_LeftWin_Width, clientsize.y ) );
m_auimgr.Update(); m_auimgr.Update();
#endif #endif
} }
...@@ -144,7 +123,7 @@ WinEDA_MainFrame::~WinEDA_MainFrame() ...@@ -144,7 +123,7 @@ WinEDA_MainFrame::~WinEDA_MainFrame()
/*****************************************************************************/ /*****************************************************************************/
{ {
#if defined(KICAD_AUIMANAGER) #if defined(KICAD_AUIMANAGER)
m_auimgr.UnInit(); m_auimgr.UnInit();
#endif #endif
} }
...@@ -152,14 +131,12 @@ m_auimgr.UnInit(); ...@@ -152,14 +131,12 @@ m_auimgr.UnInit();
/*******************************************************/ /*******************************************************/
void WinEDA_MainFrame::PrintMsg( const wxString& text ) void WinEDA_MainFrame::PrintMsg( const wxString& text )
/*******************************************************/ /*******************************************************/
/* /*
* Put text in the dialog frame * Put text in the dialog frame
*/ */
{ {
m_DialogWin->AppendText( text ); m_RightWin->m_DialogWin->AppendText( text );
#ifdef DEBUG
printf("%s\n", (const char*)text.mb_str() );
#endif
} }
...@@ -170,43 +147,19 @@ void WinEDA_MainFrame::OnSashDrag( wxSashEvent& event ) ...@@ -170,43 +147,19 @@ void WinEDA_MainFrame::OnSashDrag( wxSashEvent& event )
/* Resize windows when dragging window borders /* Resize windows when dragging window borders
*/ */
{ {
int w, h; #if defined(KICAD_AUIMANAGER)
wxSize newsize;
#else
if( event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE ) if( event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE )
return; return;
GetClientSize( &w, &h ); m_LeftWin_Width = event.GetDragRect().width;
m_LeftWin->SetDefaultSize( wxSize( m_LeftWin_Width, -1 ) );
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;
}
}
wxLayoutAlgorithm layout; wxLayoutAlgorithm layout;
layout.LayoutFrame( this ); layout.LayoutFrame( this );
#endif
event.Skip(); event.Skip();
} }
...@@ -216,30 +169,13 @@ void WinEDA_MainFrame::OnSize( wxSizeEvent& event ) ...@@ -216,30 +169,13 @@ void WinEDA_MainFrame::OnSize( wxSizeEvent& event )
/************************************************/ /************************************************/
{ {
#if defined(KICAD_AUIMANAGER) #if defined(KICAD_AUIMANAGER)
if(m_auimgr.GetManagedWindow()) if( m_auimgr.GetManagedWindow() )
m_auimgr.Update(); 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 ) );
}
#else
wxLayoutAlgorithm layout; wxLayoutAlgorithm layout;
layout.LayoutFrame( this ); layout.LayoutFrame( this );
if( m_CommandWin )
m_CommandWin->Refresh( TRUE );
#endif #endif
event.Skip(); event.Skip();
} }
...@@ -276,7 +212,7 @@ void WinEDA_MainFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -276,7 +212,7 @@ void WinEDA_MainFrame::OnCloseWindow( wxCloseEvent& Event )
wxGetApp().m_HtmlCtrl = NULL; wxGetApp().m_HtmlCtrl = NULL;
} }
m_LeftWin->Show(false); m_LeftWin->Show( false );
Destroy(); Destroy();
} }
...@@ -291,6 +227,7 @@ void WinEDA_MainFrame::OnExit( wxCommandEvent& event ) ...@@ -291,6 +227,7 @@ void WinEDA_MainFrame::OnExit( wxCommandEvent& event )
void WinEDA_MainFrame::OnRunPcbNew( wxCommandEvent& event ) void WinEDA_MainFrame::OnRunPcbNew( wxCommandEvent& event )
{ {
wxFileName fn( m_ProjectFileName ); wxFileName fn( m_ProjectFileName );
fn.SetExt( BoardFileExtension ); fn.SetExt( BoardFileExtension );
ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( fn ) ); ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( fn ) );
} }
...@@ -299,6 +236,7 @@ void WinEDA_MainFrame::OnRunPcbNew( wxCommandEvent& event ) ...@@ -299,6 +236,7 @@ void WinEDA_MainFrame::OnRunPcbNew( wxCommandEvent& event )
void WinEDA_MainFrame::OnRunCvpcb( wxCommandEvent& event ) void WinEDA_MainFrame::OnRunCvpcb( wxCommandEvent& event )
{ {
wxFileName fn( m_ProjectFileName ); wxFileName fn( m_ProjectFileName );
fn.SetExt( NetlistFileExtension ); fn.SetExt( NetlistFileExtension );
ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) ); ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) );
} }
...@@ -307,6 +245,7 @@ void WinEDA_MainFrame::OnRunCvpcb( wxCommandEvent& event ) ...@@ -307,6 +245,7 @@ void WinEDA_MainFrame::OnRunCvpcb( wxCommandEvent& event )
void WinEDA_MainFrame::OnRunEeschema( wxCommandEvent& event ) void WinEDA_MainFrame::OnRunEeschema( wxCommandEvent& event )
{ {
wxFileName fn( m_ProjectFileName ); wxFileName fn( m_ProjectFileName );
fn.SetExt( SchematicFileExtension ); fn.SetExt( SchematicFileExtension );
ExecuteFile( this, EESCHEMA_EXE, QuoteFullPath( fn ) ); ExecuteFile( this, EESCHEMA_EXE, QuoteFullPath( fn ) );
} }
...@@ -315,8 +254,9 @@ void WinEDA_MainFrame::OnRunEeschema( wxCommandEvent& event ) ...@@ -315,8 +254,9 @@ void WinEDA_MainFrame::OnRunEeschema( wxCommandEvent& event )
void WinEDA_MainFrame::OnRunGerbview( wxCommandEvent& event ) void WinEDA_MainFrame::OnRunGerbview( wxCommandEvent& event )
{ {
wxFileName fn( m_ProjectFileName ); wxFileName fn( m_ProjectFileName );
ExecuteFile( this, GERBVIEW_EXE, 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 ) ...@@ -341,12 +281,15 @@ void WinEDA_MainFrame::OnRunPythonScript( wxCommandEvent& event )
PyHandler::GetInstance()->RunScript( dlg.GetPath() ); PyHandler::GetInstance()->RunScript( dlg.GetPath() );
} }
#endif #endif
void WinEDA_MainFrame::OnOpenFileInTextEditor( wxCommandEvent& event ) void WinEDA_MainFrame::OnOpenFileInTextEditor( wxCommandEvent& event )
{ {
wxString mask( wxT( "*" ) ); wxString mask( wxT( "*" ) );
#ifdef __WINDOWS__ #ifdef __WINDOWS__
mask += wxT( ".*" ); mask += wxT( ".*" );
#endif #endif
...@@ -354,12 +297,12 @@ void WinEDA_MainFrame::OnOpenFileInTextEditor( wxCommandEvent& event ) ...@@ -354,12 +297,12 @@ void WinEDA_MainFrame::OnOpenFileInTextEditor( wxCommandEvent& event )
mask = _( "Text file (" ) + mask + wxT( ")|" ) + mask; mask = _( "Text file (" ) + mask + wxT( ")|" ) + mask;
wxFileDialog dlg( this, _( "Load File to Edit" ), wxGetCwd(), wxFileDialog dlg( this, _( "Load File to Edit" ), wxGetCwd(),
wxEmptyString, mask,wxFD_OPEN ); wxEmptyString, mask, wxFD_OPEN );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; return;
if( ! dlg.GetPath().IsEmpty() && ! wxGetApp().GetEditorName().IsEmpty() ) if( !dlg.GetPath().IsEmpty() && !wxGetApp().GetEditorName().IsEmpty() )
ExecuteFile( this, wxGetApp().GetEditorName(), dlg.GetPath() ); ExecuteFile( this, wxGetApp().GetEditorName(), dlg.GetPath() );
} }
...@@ -372,12 +315,11 @@ void WinEDA_MainFrame::OnRefresh( wxCommandEvent& event ) ...@@ -372,12 +315,11 @@ void WinEDA_MainFrame::OnRefresh( wxCommandEvent& event )
} }
/*********************************/ /*********************************/
void WinEDA_MainFrame::ClearMsg() void WinEDA_MainFrame::ClearMsg()
/*********************************/ /*********************************/
{ {
m_DialogWin->Clear(); m_RightWin->m_DialogWin->Clear();
} }
...@@ -395,7 +337,6 @@ void WinEDA_MainFrame::LoadSettings() ...@@ -395,7 +337,6 @@ void WinEDA_MainFrame::LoadSettings()
WinEDA_BasicFrame::LoadSettings(); WinEDA_BasicFrame::LoadSettings();
cfg->Read( TreeFrameWidthEntry, &m_LeftWin_Width ); cfg->Read( TreeFrameWidthEntry, &m_LeftWin_Width );
cfg->Read( CommandFrameWidthEntry, &m_CommandWin_Height );
} }
...@@ -414,7 +355,6 @@ void WinEDA_MainFrame::SaveSettings() ...@@ -414,7 +355,6 @@ void WinEDA_MainFrame::SaveSettings()
WinEDA_BasicFrame::SaveSettings(); WinEDA_BasicFrame::SaveSettings();
cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x ); cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x );
cfg->Write( CommandFrameWidthEntry, m_CommandWin->GetSize().y );
} }
...@@ -425,4 +365,6 @@ void WinEDA_MainFrame::OnRefreshPy() ...@@ -425,4 +365,6 @@ void WinEDA_MainFrame::OnRefreshPy()
{ {
m_LeftWin->ReCreateTreePrj(); m_LeftWin->ReCreateTreePrj();
} }
#endif #endif
...@@ -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