diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index 6f58b942d4..60f92128a4 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -327,6 +327,7 @@ set( BMAPS_MID modratsnest module_check module_edit + module_wizard module_filtered_list module_full_list module_options diff --git a/bitmaps_png/cpp_26/module_wizard.cpp b/bitmaps_png/cpp_26/module_wizard.cpp new file mode 100644 index 0000000000..316c6931fb --- /dev/null +++ b/bitmaps_png/cpp_26/module_wizard.cpp @@ -0,0 +1,97 @@ + +/* Do not modify this file, it was automatically generated by the + * PNG2cpp CMake script, using a *.png file as input. + */ + +#include + +static const unsigned char png[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x06, 0x00, 0x00, 0x00, 0xa9, 0x4a, 0x4c, + 0xce, 0x00, 0x00, 0x05, 0x07, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0xad, 0x96, 0x0d, 0x50, 0x14, + 0x65, 0x18, 0xc7, 0x6f, 0x77, 0x39, 0xe4, 0x38, 0x20, 0x2f, 0x73, 0xc0, 0x92, 0x13, 0x2c, 0xd4, + 0x81, 0xf1, 0x03, 0xc5, 0xa0, 0x3b, 0x0e, 0x41, 0x4f, 0x85, 0x88, 0x81, 0x40, 0x0e, 0x90, 0x4f, + 0x0f, 0x30, 0x08, 0xc3, 0x03, 0x3d, 0xc4, 0x14, 0xc2, 0x86, 0x98, 0x38, 0x04, 0x86, 0x14, 0x44, + 0xc1, 0x0f, 0x3a, 0x3f, 0xf8, 0x70, 0x40, 0x4b, 0x1a, 0x14, 0x6c, 0x4c, 0x4c, 0xb4, 0xc2, 0xf2, + 0x2b, 0x6d, 0x9c, 0xd1, 0x12, 0x6a, 0xc8, 0xd0, 0x50, 0x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 0x7c, 0xea, 0x78, 0xfe, 0x4f, 0x35, 0x61, 0xd6, 0x28, 0xda, 0xa0, 0x86, 0xaf, 0x7c, 0x02, 0x3c, + 0x67, 0xd1, 0x60, 0xeb, 0x0e, 0x90, 0x35, 0xe5, 0x4c, 0xfa, 0x56, 0x56, 0xe8, 0x1c, 0x9c, 0x6b, + 0x6d, 0xc2, 0xfa, 0xe0, 0x19, 0xe4, 0xc7, 0x75, 0x72, 0xfd, 0x08, 0x66, 0x66, 0x66, 0x0b, 0x88, + 0x28, 0xc9, 0xd6, 0xd6, 0x76, 0x28, 0x21, 0x21, 0x01, 0x84, 0x74, 0xaf, 0xb1, 0x88, 0x90, 0x4d, + 0x44, 0x6d, 0x8d, 0x00, 0xb9, 0x59, 0x02, 0x78, 0x7b, 0x08, 0x11, 0x1c, 0x1c, 0x08, 0x3f, 0xe9, + 0x0c, 0x24, 0x78, 0x33, 0xc8, 0x5a, 0x67, 0x8d, 0xc1, 0x41, 0x2b, 0xc4, 0xf8, 0x32, 0x6c, 0x1e, + 0x6c, 0xa8, 0x59, 0x21, 0x1b, 0x87, 0x82, 0x50, 0x27, 0x14, 0xaf, 0x5d, 0x8e, 0xe2, 0xd0, 0xc9, + 0x88, 0x96, 0xda, 0x83, 0xeb, 0x27, 0x95, 0x4a, 0x21, 0x14, 0x0a, 0x8f, 0x18, 0x44, 0xae, 0xae, + 0xae, 0xbd, 0xa7, 0x4e, 0x9d, 0x02, 0x21, 0x27, 0x60, 0x12, 0x6e, 0xaa, 0x78, 0xc8, 0x59, 0xc5, + 0x67, 0xcf, 0xd8, 0x0a, 0x03, 0x03, 0x56, 0x28, 0x2b, 0x1b, 0x8f, 0x65, 0xb1, 0x22, 0x74, 0x76, + 0x0a, 0x0d, 0x19, 0x21, 0xda, 0x87, 0x0f, 0xad, 0x56, 0x6b, 0xa8, 0xc9, 0x0e, 0x74, 0x32, 0x5c, + 0x9b, 0x9e, 0x87, 0xd7, 0x70, 0x6d, 0x98, 0x04, 0x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0xd2, 0xa6, 0xff, 0xc6, + 0xf6, 0x00, 0xf4, 0x56, 0xb1, 0x93, 0x78, 0x58, 0x81, 0x9a, 0xb2, 0x2c, 0x5d, 0x45, 0x41, 0xe6, + 0x15, 0xa3, 0xa2, 0xff, 0x0a, 0x7b, 0x66, 0x41, 0x3f, 0xa7, 0x8b, 0xbb, 0xbb, 0xd9, 0xe1, 0xe8, + 0xfe, 0x7c, 0x1e, 0xf6, 0x56, 0x6d, 0xc2, 0x91, 0xc6, 0x03, 0xfa, 0x7a, 0xf5, 0x7b, 0xdf, 0xbc, + 0x50, 0x11, 0xe1, 0xab, 0x15, 0xd3, 0xf7, 0x55, 0x69, 0xd2, 0x74, 0x25, 0x9a, 0xf5, 0x38, 0x7e, + 0xfc, 0x18, 0x3a, 0x3a, 0xae, 0xe3, 0x8b, 0xf4, 0x54, 0x74, 0x4a, 0x26, 0xfa, 0xbe, 0x50, 0xd1, + 0xce, 0x75, 0x11, 0x4c, 0x79, 0x5e, 0xfa, 0x9d, 0x2d, 0x5b, 0x4a, 0x51, 0x58, 0x58, 0x88, 0xbd, + 0x5b, 0x37, 0xe3, 0xb8, 0x7a, 0x35, 0xba, 0x3c, 0x66, 0xde, 0xfd, 0x07, 0x3e, 0x0a, 0x38, 0xab, + 0xbb, 0xc7, 0x1e, 0xdb, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, +}; + +const BITMAP_OPAQUE module_wizard_xpm[1] = {{ png, sizeof( png ), "module_wizard_xpm" }}; + +//EOF diff --git a/bitmaps_png/sources/module_wizard.svg b/bitmaps_png/sources/module_wizard.svg new file mode 100644 index 0000000000..a8fd1839e5 --- /dev/null +++ b/bitmaps_png/sources/module_wizard.svg @@ -0,0 +1,401 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/bitmaps.h b/include/bitmaps.h index 8a5d4242cb..97e3474827 100644 --- a/include/bitmaps.h +++ b/include/bitmaps.h @@ -278,6 +278,7 @@ EXTERN_BITMAP( mode_track_xpm ) EXTERN_BITMAP( mod_ratsnest_xpm ) EXTERN_BITMAP( module_check_xpm ) EXTERN_BITMAP( module_edit_xpm ) +EXTERN_BITMAP( module_wizard_xpm ) EXTERN_BITMAP( module_filtered_list_xpm ) EXTERN_BITMAP( module_pin_filtered_list_xpm ) EXTERN_BITMAP( module_full_list_xpm ) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index d20fa8afb0..bcf99737a6 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -97,8 +97,11 @@ set(PCBNEW_DIALOGS dialogs/dialog_set_grid_base.cpp dialogs/dialog_scripting_base.cpp dialogs/dialog_scripting.cpp + footprint_wizard.cpp + footprint_wizard_frame.cpp ) +# some of the files here may be going to the dialog srcs in fact.... set(PCBNEW_CLASS_SRCS tool_modview.cpp modview.cpp @@ -114,7 +117,6 @@ set(PCBNEW_CLASS_SRCS block.cpp block_module_editor.cpp build_BOM_from_board.cpp -# class_footprint_library.cpp class_pcb_layer_widget.cpp clean.cpp connect.cpp @@ -215,6 +217,7 @@ set(PCBNEW_CLASS_SRCS zones_polygons_insulated_copper_islands.cpp zones_polygons_test_connections.cpp zones_test_and_combine_areas.cpp + class_footprint_wizard.cpp ) set(PCBNEW_SRCS ${PCBNEW_CLASS_SRCS} ${PCBNEW_DIALOGS}) diff --git a/pcbnew/class_footprint_wizard.cpp b/pcbnew/class_footprint_wizard.cpp new file mode 100644 index 0000000000..6e85ac4b55 --- /dev/null +++ b/pcbnew/class_footprint_wizard.cpp @@ -0,0 +1,41 @@ +/** + * @file class_footprint_wizard.cpp + * @brief Class FOOTPRINT_WIZARD and FOOTPRINT_WIZARDS + */ + +#include "class_footprint_wizard.h" +#include + +void FOOTPRINT_WIZARD::register_wizard() +{ + FOOTPRINT_WIZARDS::register_wizard(this); +} + +std::vector FOOTPRINT_WIZARDS::m_FootprintWizards; + +void FOOTPRINT_WIZARDS::register_wizard(FOOTPRINT_WIZARD *aWizard) +{ + + wxString name = aWizard->GetName(); + m_FootprintWizards.push_back(aWizard); + + printf("Registered footprint wizard '%s'\n",(const char*)name.mb_str() ); + +#if 0 + /* just to test if it works correctly */ + int pages = fw->GetNumParameterPages(); + printf(" %d pages\n",pages); + + for (int n=0; n'%s'\n",n, + (const char*)fw->GetParameterPageName(n).mb_str()); + } +#endif + + +} + + + + diff --git a/pcbnew/class_footprint_wizard.h b/pcbnew/class_footprint_wizard.h new file mode 100644 index 0000000000..36442a6218 --- /dev/null +++ b/pcbnew/class_footprint_wizard.h @@ -0,0 +1,44 @@ +/** + * @file pcbnew_footprint_wizards.h + * @brief Class PCBNEW_FOOTPRINT_WIZARDS + */ + +#ifndef CLASS_FOOTPRINT_WIZARD_H +#define CLASS_FOOTPRINT_WIZARD_H +#include +#include + +/* This is the parent class from where any footprint wiizard class must + * derive */ +class FOOTPRINT_WIZARD +{ + +public: + FOOTPRINT_WIZARD() {} + ~FOOTPRINT_WIZARD() {} + virtual wxString GetName()=0; + virtual wxString GetImage()=0; + virtual wxString GetDescription()=0; + virtual int GetNumParameterPages()=0; + virtual wxString GetParameterPageName(int aPage)=0; + virtual wxArrayString GetParameterNames(int aPage)=0; + virtual wxArrayString GetParameterValues(int aPage)=0; + virtual wxString SetParameterValues(int aPage,wxArrayString& aValues)=0; + virtual MODULE *GetModule()=0; + void register_wizard(); + +}; + + +class FOOTPRINT_WIZARDS +{ +private: + static std::vector m_FootprintWizards; + +public: + static void register_wizard(FOOTPRINT_WIZARD *wizard); + +}; + +#endif /* PCBNEW_FOOTPRINT_WIZARDS_H */ + diff --git a/pcbnew/footprint_wizard.cpp b/pcbnew/footprint_wizard.cpp new file mode 100644 index 0000000000..a3abdac2fc --- /dev/null +++ b/pcbnew/footprint_wizard.cpp @@ -0,0 +1,160 @@ +/** + * @file footprint wizard.cpp + */ + +#include +#include +#include +#include +#include +#include <3d_viewer.h> +#include + +#include +#include + +#include +#include +#include "footprint_wizard_frame.h" +#include + + +#define NEXT_PART 1 +#define NEW_PART 0 +#define PREVIOUS_PART -1 + + +void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event ) +{ + wxString msg; + + switch( event.GetId() ) + { + case ID_FOOTPRINT_WIZARD_NEXT: + //SelectAndViewFootprint( NEXT_PART ); + break; + + case ID_FOOTPRINT_WIZARD_PREVIOUS: + //SelectAndViewFootprint( PREVIOUS_PART ); + break; + + default: + msg << wxT( "FOOTPRINT_WIZARD_FRAME::Process_Special_Functions error: id = " ) + << event.GetId(); + wxMessageBox( msg ); + break; + } +} + + +void FOOTPRINT_WIZARD_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) +{ +} + + +bool FOOTPRINT_WIZARD_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) +{ + return true; +} + + +/* Displays the name of the current opened library in the caption */ +void FOOTPRINT_WIZARD_FRAME::DisplayWizardInfos() +{ + wxString msg; + + msg = _( "Footprint Wizard" ); + msg << wxT( " [" ); + + if( ! m_wizardName.IsEmpty() ) + msg << m_wizardName; + else + msg += _( "no wizard selected" ); + + msg << wxT( "]" ); + + SetTitle( msg ); +} + + +void FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard( wxCommandEvent& event ) +{ + wxString msg; + + if( g_LibraryNames.GetCount() == 0 ) + return; + + EDA_LIST_DIALOG dlg( this, _( "Select Current Wizard:" ), + g_LibraryNames, m_wizardName ); + + if( dlg.ShowModal() != wxID_OK ) + return; + + if( m_wizardName == dlg.GetTextSelection() ) + return; + + m_wizardName = dlg.GetTextSelection(); + + DisplayWizardInfos(); + ReCreatePageList(); + ReCreateParameterList(); + + +} + +/** + * Function SelectCurrentFootprint + * Selects the current footprint name and display it + */ +void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxCommandEvent& event ) +{ + /* + // will pick it from the wizard + MODULE * module = new MODULE(NULL); + if( module ) + { + module->SetPosition( wxPoint( 0, 0 ) ); + + // Only one fotprint allowed: remove the previous footprint (if exists) + if( oldmodule ) + { + GetBoard()->Remove( oldmodule ); + delete oldmodule; + } + m_footprintName = module->GetLibRef(); + module->ClearFlags(); + SetCurItem( NULL ); + + Zoom_Automatique( false ); + m_canvas->Refresh( ); + Update3D_Frame(); + m_FootprintList->SetStringSelection( m_footprintName ); + } + * */ +} + + +/** + * Function RedrawActiveWindow + * Display the current selected component. + * If the component is an alias, the ROOT component is displayed +*/ +void FOOTPRINT_WIZARD_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) +{ + if( !GetBoard() ) + return; + + m_canvas->DrawBackGround( DC ); + GetBoard()->Draw( m_canvas, DC, GR_COPY ); + + MODULE* module = GetBoard()->m_Modules; + + if ( module ) + module->DisplayInfo( this ); + + m_canvas->DrawCrossHair( DC ); + + ClearMsgPanel(); + if( module ) + module->DisplayInfo( this ); +} diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp new file mode 100644 index 0000000000..ae534d96f9 --- /dev/null +++ b/pcbnew/footprint_wizard_frame.cpp @@ -0,0 +1,685 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras + * Copyright (C) 2008-2011 Wayne Stambaugh + * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * @file modview_frame.cpp + */ + +#include +#include +#include +#include +#include +#include <3d_viewer.h> +#include + +#include +#include + +#include +#include +#include "footprint_wizard_frame.h" +#include + +#include +#include + + +BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME ) + /* Window events */ + EVT_CLOSE( FOOTPRINT_WIZARD_FRAME::OnCloseWindow ) + EVT_SIZE( FOOTPRINT_WIZARD_FRAME::OnSize ) + EVT_ACTIVATE( FOOTPRINT_WIZARD_FRAME::OnActivate ) + + /* Sash drag events */ + EVT_SASH_DRAGGED( ID_FOOTPRINT_WIZARD_PAGES, FOOTPRINT_WIZARD_FRAME::OnSashDrag ) + EVT_SASH_DRAGGED( ID_FOOTPRINT_WIZARD_PARAMETERS, FOOTPRINT_WIZARD_FRAME::OnSashDrag ) + + /* Toolbar events */ + EVT_TOOL( ID_FOOTPRINT_WIZARD_NEXT, + FOOTPRINT_WIZARD_FRAME::Process_Special_Functions ) + EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS, + FOOTPRINT_WIZARD_FRAME::Process_Special_Functions ) +/* EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE, + FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )*/ + EVT_TOOL( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, + FOOTPRINT_WIZARD_FRAME::Show3D_Frame ) + + /* listbox events */ + EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList ) + EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnParameterList ) + + EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset ) +END_EVENT_TABLE() + + +/* + * This emulates the zoom menu entries found in the other KiCad applications. + * The library viewer does not have any menus so add an accelerator table to + * the main frame. + */ +static wxAcceleratorEntry accels[] = +{ + wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F1, ID_ZOOM_IN ), + wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F2, ID_ZOOM_OUT ), + wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F3, ID_ZOOM_REDRAW ), + wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F4, ID_POPUP_ZOOM_CENTER ), + wxAcceleratorEntry( wxACCEL_NORMAL, WXK_HOME, ID_ZOOM_PAGE ), + wxAcceleratorEntry( wxACCEL_NORMAL, WXK_SPACE, ID_SET_RELATIVE_OFFSET ) +}; + +#define ACCEL_TABLE_CNT ( sizeof( accels ) / sizeof( wxAcceleratorEntry ) ) + +#define EXTRA_BORDER_SIZE 2 + + +FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* semaphore ) : + PCB_BASE_FRAME( parent, MODULE_VIEWER_FRAME, _( "Footprint Wizard" ), + wxDefaultPosition, wxDefaultSize ) +{ + wxAcceleratorTable table( ACCEL_TABLE_CNT, accels ); + + m_FrameName = wxT( "FootprintWizard" ); + m_configPath = wxT( "FootprintWizard" ); + m_showAxis = true; // true to draw axis. + + // Give an icon + wxIcon icon; + icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) ); + SetIcon( icon ); + + m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr; + m_PageList= NULL; + m_ParameterList = NULL; + m_PageListWindow = NULL; + m_ParameterListWindow = NULL; + m_Semaphore = semaphore; + m_wizardName.Empty(); + + if( m_Semaphore ) + MakeModal(true); + + SetBoard( new BOARD() ); + // Ensure all layers and items are visible: + GetBoard()->SetVisibleAlls(); + SetScreen( new PCB_SCREEN(GetPageSizeIU()) ); + GetScreen()->m_Center = true; // Center coordinate origins on screen. + LoadSettings(); + + SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); + GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); + + ReCreateHToolbar(); + ReCreateVToolbar(); + + wxSize size = GetClientSize(); + size.y -= m_MsgFrameHeight + 2; + + m_PageListSize.y = -1; + + wxPoint win_pos( 0, 0 ); + + // Creates the libraries window display + m_PageListWindow = + new wxSashLayoutWindow( this, ID_FOOTPRINT_WIZARD_PAGES_WINDOW, win_pos, + wxDefaultSize, wxCLIP_CHILDREN | wxSW_3D, + wxT( "PagesWindow" ) ); + m_PageListWindow->SetOrientation( wxLAYOUT_VERTICAL ); + m_PageListWindow->SetAlignment( wxLAYOUT_LEFT ); + m_PageListWindow->SetSashVisible( wxSASH_RIGHT, true ); + m_PageListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE ); + m_PageList = new wxListBox( m_PageListWindow, ID_FOOTPRINT_WIZARD_PAGE_LIST, + wxPoint( 0, 0 ), wxDefaultSize, + 0, NULL, wxLB_HSCROLL ); + + // Creates the component window display + m_ParameterListSize.y = size.y; + win_pos.x = m_PageListSize.x; + m_ParameterListWindow = new wxSashLayoutWindow( this, + ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW, + win_pos, wxDefaultSize, + wxCLIP_CHILDREN | wxSW_3D, + wxT( "ParameterList" ) ); + + m_ParameterListWindow->SetOrientation( wxLAYOUT_VERTICAL ); + + m_ParameterListWindow->SetSashVisible( wxSASH_RIGHT, true ); + m_ParameterListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE ); + m_ParameterList = new wxListBox( m_ParameterListWindow, ID_FOOTPRINT_WIZARD_PARAMETER_LIST, + wxPoint( 0, 0 ), wxDefaultSize, + 0, NULL, wxLB_HSCROLL ); + + ReCreatePageList(); + + DisplayWizardInfos(); + + if( m_canvas ) + m_canvas->SetAcceleratorTable( table ); + + m_auimgr.SetManagedWindow( this ); + + + EDA_PANEINFO horiz; + horiz.HorizontalToolbarPane(); + + EDA_PANEINFO vert; + vert.VerticalToolbarPane(); + + EDA_PANEINFO info; + info.InfoToolbarPane(); + + EDA_PANEINFO mesg; + mesg.MessageToolbarPane(); + + + // Manage main toolbal + m_auimgr.AddPane( m_mainToolBar, + wxAuiPaneInfo( horiz ).Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) ); + + wxSize minsize( 60, -1 ); + + // Manage the left window (list of pages) + if( m_PageListWindow ) + m_auimgr.AddPane( m_PageListWindow, wxAuiPaneInfo( info ).Name( wxT( "m_PageList" ) ). + Left().Row( 0 )); + + // Manage the list of parameters) + m_auimgr.AddPane( m_ParameterListWindow, + wxAuiPaneInfo( info ).Name( wxT( "m_ParameterList" ) ). + Left().Row( 1 ) ); + + // Manage the draw panel + m_auimgr.AddPane( m_canvas, + wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).Centre() ); + + // Manage the message panel + m_auimgr.AddPane( m_messagePanel, + wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) ); + + /* Now the minimum windows are fixed, set library list + * and component list of the previous values from last viewlib use + */ + if( m_PageListWindow ) + { + wxAuiPaneInfo& pane = m_auimgr.GetPane(m_PageListWindow); + pane.MinSize( wxSize(m_PageListSize.x, -1)); + } + wxAuiPaneInfo& pane = m_auimgr.GetPane(m_ParameterListWindow); + pane.MinSize(wxSize(m_ParameterListSize.x, -1)); + + m_auimgr.Update(); + + // Now Drawpanel is sized, we can use BestZoom to show the component (if any) +#ifdef USE_WX_GRAPHICS_CONTEXT + GetScreen()->SetZoom( BestZoom() ); +#else + Zoom_Automatique( false ); +#endif + + Show( true ); +} + + +FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME() +{ + if( m_Draw3DFrame ) + m_Draw3DFrame->Destroy(); + PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent(); + frame->m_ModuleViewerFrame = NULL; +} + + +void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event ) +{ + SaveSettings(); + + if( m_Semaphore ) + { + m_Semaphore->Post(); + MakeModal(false); + // This window will be destroyed by the calling function, + // to avoid side effects + } + else + { + Destroy(); + } +} + + +void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event ) +{ + if( event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE ) + return; + + m_PageListSize.y = GetClientSize().y - m_MsgFrameHeight; + m_ParameterListSize.y = m_PageListSize.y; + + switch( event.GetId() ) + { + case ID_FOOTPRINT_WIZARD_WINDOW: + if( m_PageListWindow ) + { + wxAuiPaneInfo& pane = m_auimgr.GetPane( m_PageListWindow ); + m_PageListSize.x = event.GetDragRect().width; + pane.MinSize( m_PageListSize ); + m_auimgr.Update(); + } + break; + + case ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW: + { + wxAuiPaneInfo& pane = m_auimgr.GetPane( m_ParameterListWindow ); + m_ParameterListSize.x = event.GetDragRect().width; + pane.MinSize( m_ParameterListSize ); + m_auimgr.Update(); + } + break; + } +} + + +void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv ) +{ + if( m_auimgr.GetManagedWindow() ) + m_auimgr.Update(); + + SizeEv.Skip(); +} + + +void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event ) +{ + GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); + UpdateStatusBar(); +} + + +void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() +{ + if( m_PageList == NULL ) + return; + + m_PageList->Clear(); + + m_PageList->Append(wxT("Pads")); + m_PageList->Append(wxT("Shield")); + + m_PageList->SetSelection( 0, true ); + + /*for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ ) + { + m_PageList->Append( g_LibraryNames[ii] ); + }*/ + +#if 0 + // Search for a previous selection: + + int index = m_PageList->FindString( m_libraryName ); + + if( index != wxNOT_FOUND ) + { + m_PageList->SetSelection( index, true ); + } + else + { + /* If not found, clear current library selection because it can be + * deleted after a config change. */ + m_libraryName = wxEmptyString; + m_footprintName = wxEmptyString; + } +#endif + + ReCreateHToolbar(); + DisplayWizardInfos(); + m_canvas->Refresh(); +} + + +void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() +{ + if( m_ParameterList == NULL ) + return; + + m_ParameterList->Clear(); + + wxArrayString fpList; + + m_ParameterList->Append( fpList ); + m_ParameterList->Append(wxT("N")); + m_ParameterList->Append(wxT("pitch")); + m_ParameterList->Append(wxT("width")); + m_ParameterList->Append(wxT("height")); + m_ParameterList->SetSelection( 0, true ); + + //m_ParameterList->SetSelection( index, true ); +} + + +void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event ) +{ + int ii = m_PageList->GetSelection(); + + if( ii < 0 ) + return; + + wxString name = m_PageList->GetString( ii ); + + printf("page=%d\n",ii); + + ReCreateParameterList(); + m_canvas->Refresh(); + DisplayWizardInfos(); +} + + +void FOOTPRINT_WIZARD_FRAME::ClickOnParameterList( wxCommandEvent& event ) +{ + int ii = m_ParameterList->GetSelection(); + + if( ii < 0 ) + return; + + wxString name = m_ParameterList->GetString( ii ); + + SetCurItem( NULL ); + // Delete the current footprint + GetBoard()->m_Modules.DeleteAll(); + DisplayWizardInfos(); + Zoom_Automatique( false ); + m_canvas->Refresh(); +} + + +#define PARTLIST_WIDTH_KEY wxT( "Partlist_width" ) +#define PARAMLIST_WIDTH_KEY wxT( "Paramlist_width" ) + + +void FOOTPRINT_WIZARD_FRAME::LoadSettings( ) +{ + wxConfig* cfg ; + + EDA_DRAW_FRAME::LoadSettings(); + + wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath ); + cfg = wxGetApp().GetSettings(); + + m_PageListSize.x = 150; // default width of libs list + m_ParameterListSize.x = 150; // default width of component list + + cfg->Read( PARTLIST_WIDTH_KEY , &m_PageListSize.x ); + cfg->Read( PARAMLIST_WIDTH_KEY, &m_ParameterListSize.x ); + + // Set parameters to a reasonable value. + if ( m_PageListSize.x > m_FrameSize.x/2 ) + m_PageListSize.x = m_FrameSize.x/2; + + if ( m_ParameterListSize.x > m_FrameSize.x/2 ) + m_ParameterListSize.x = m_FrameSize.x/2; +} + + +void FOOTPRINT_WIZARD_FRAME::SaveSettings() +{ + wxConfig* cfg; + + EDA_DRAW_FRAME::SaveSettings(); + + wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath ); + cfg = wxGetApp().GetSettings(); + + if ( m_PageListSize.x ) + cfg->Write( PARTLIST_WIDTH_KEY, m_PageListSize.x ); + + cfg->Write( PARAMLIST_WIDTH_KEY, m_ParameterListSize.x ); +} + + +void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event ) +{ + EDA_DRAW_FRAME::OnActivate( event ); + + // Ensure we do not have old selection: + if( ! m_FrameIsActive ) + return; + + bool footprintWizardsChanged=false; + if (footprintWizardsChanged) + { + // If we are here, the library list has changed, rebuild it + ReCreatePageList(); + DisplayWizardInfos(); + + } +} + + +void FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) +{ + wxRealPoint gridSize; + wxPoint oldpos; + PCB_SCREEN* screen = GetScreen(); + wxPoint pos = aPosition; + + wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); + cmd.SetEventObject( this ); + + pos = screen->GetNearestGridPosition( pos ); + oldpos = screen->GetCrossHairPosition(); + gridSize = screen->GetGridSize(); + + switch( aHotKey ) + { + case WXK_F1: + cmd.SetId( ID_POPUP_ZOOM_IN ); + GetEventHandler()->ProcessEvent( cmd ); + break; + + case WXK_F2: + cmd.SetId( ID_POPUP_ZOOM_OUT ); + GetEventHandler()->ProcessEvent( cmd ); + break; + + case WXK_F3: + cmd.SetId( ID_ZOOM_REDRAW ); + GetEventHandler()->ProcessEvent( cmd ); + break; + + case WXK_F4: + cmd.SetId( ID_POPUP_ZOOM_CENTER ); + GetEventHandler()->ProcessEvent( cmd ); + break; + + case WXK_HOME: + cmd.SetId( ID_ZOOM_PAGE ); + GetEventHandler()->ProcessEvent( cmd ); + break; + + case ' ': + screen->m_O_Curseur = screen->GetCrossHairPosition(); + break; + + case WXK_NUMPAD8: /* cursor moved up */ + case WXK_UP: + pos.y -= KiROUND( gridSize.y ); + m_canvas->MoveCursor( pos ); + break; + + case WXK_NUMPAD2: /* cursor moved down */ + case WXK_DOWN: + pos.y += KiROUND( gridSize.y ); + m_canvas->MoveCursor( pos ); + break; + + case WXK_NUMPAD4: /* cursor moved left */ + case WXK_LEFT: + pos.x -= KiROUND( gridSize.x ); + m_canvas->MoveCursor( pos ); + break; + + case WXK_NUMPAD6: /* cursor moved right */ + case WXK_RIGHT: + pos.x += KiROUND( gridSize.x ); + m_canvas->MoveCursor( pos ); + break; + } + + screen->SetCrossHairPosition( pos ); + + if( oldpos != screen->GetCrossHairPosition() ) + { + pos = screen->GetCrossHairPosition(); + screen->SetCrossHairPosition( oldpos ); + m_canvas->CrossHairOff( aDC ); + screen->SetCrossHairPosition( pos ); + m_canvas->CrossHairOn( aDC ); + + if( m_canvas->IsMouseCaptured() ) + { + m_canvas->CallMouseCapture( aDC, aPosition, 0 ); + } + } + + UpdateStatusBar(); /* Display new cursor coordinates */ +} + + +void FOOTPRINT_WIZARD_FRAME::Show3D_Frame( wxCommandEvent& event ) +{ + if( m_Draw3DFrame ) + { + // Raising the window does not show the window on Windows if iconized. + // This should work on any platform. + if( m_Draw3DFrame->IsIconized() ) + m_Draw3DFrame->Iconize( false ); + + m_Draw3DFrame->Raise(); + + // Raising the window does not set the focus on Linux. This should work on any platform. + if( wxWindow::FindFocus() != m_Draw3DFrame ) + m_Draw3DFrame->SetFocus(); + + return; + } + + m_Draw3DFrame = new EDA_3D_FRAME( this, wxEmptyString ); + Update3D_Frame( false ); + m_Draw3DFrame->Show( true ); +} + +/** + * Function Update3D_Frame + * must be called after a footprint selection + * Updates the 3D view and 3D frame title. + */ +void FOOTPRINT_WIZARD_FRAME::Update3D_Frame( bool aForceReloadFootprint ) +{ + if( m_Draw3DFrame == NULL ) + return; + + wxString frm3Dtitle; + frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), GetChars( m_wizardName ) ); + m_Draw3DFrame->SetTitle( frm3Dtitle ); + + if( aForceReloadFootprint ) + { + m_Draw3DFrame->ReloadRequest(); + // Force 3D screen refresh immediately + if( GetBoard()->m_Modules ) + m_Draw3DFrame->NewDisplay(); + } +} + + +void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar() +{ + wxString msg; + + if( m_mainToolBar == NULL ) + { + m_mainToolBar = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, + wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT ); + + // Set up toolbar + m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, wxEmptyString, + KiBitmap( library_xpm ), + _( "Select wizard to use" ) ); + + m_mainToolBar->AddSeparator(); + m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_PREVIOUS, wxEmptyString, + KiBitmap( lib_previous_xpm ), + _( "Display previous page" ) ); + + m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_NEXT, wxEmptyString, + KiBitmap( lib_next_xpm ), + _( "Display next page" ) ); + + m_mainToolBar->AddSeparator(); + m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, wxEmptyString, + KiBitmap( three_d_xpm ), + _( "Show footprint in 3D viewer" ) ); + + m_mainToolBar->AddSeparator(); + msg = AddHotkeyName( _( "Zoom in" ), g_Module_Editor_Hokeys_Descr, + HK_ZOOM_IN, IS_COMMENT ); + m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, + KiBitmap( zoom_in_xpm ), msg ); + + msg = AddHotkeyName( _( "Zoom out" ), g_Module_Editor_Hokeys_Descr, + HK_ZOOM_OUT, IS_COMMENT ); + m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, + KiBitmap( zoom_out_xpm ), msg ); + + msg = AddHotkeyName( _( "Redraw view" ), g_Module_Editor_Hokeys_Descr, + HK_ZOOM_REDRAW, IS_COMMENT ); + m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, + KiBitmap( zoom_redraw_xpm ), msg ); + + msg = AddHotkeyName( _( "Zoom auto" ), g_Module_Editor_Hokeys_Descr, + HK_ZOOM_AUTO, IS_COMMENT ); + m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, + KiBitmap( zoom_fit_in_page_xpm ), msg ); +#if 0 + if( m_Semaphore ) + { + // The library browser is called from a "load component" command + m_mainToolBar->AddSeparator(); + m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_FOOTPRINT_EXPORT_TO_BOARD, + wxEmptyString, KiBitmap( export_footprint_names_xpm ), + _( "Insert footprint in board" ) ); + } +#endif + // after adding the buttons to the toolbar, must call Realize() to + // reflect the changes + m_mainToolBar->Realize(); + } + + m_mainToolBar->Refresh(); +} + + +void FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar() +{ +} diff --git a/pcbnew/footprint_wizard_frame.h b/pcbnew/footprint_wizard_frame.h new file mode 100644 index 0000000000..82777f246a --- /dev/null +++ b/pcbnew/footprint_wizard_frame.h @@ -0,0 +1,167 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 Miguel Angel Ajo Pelayo, miguelangel@nbee.es + * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * @file footprint_wizard_frame.h + */ + +#ifndef FOOTPRINT_WIZARD_FRAME_H_ +#define FOOTPRINT_WIZARD_FRAME_H_ + + +#include + +class wxSashLayoutWindow; +class wxListBox; +class wxSemaphore; + + +/** + * Component library viewer main window. + */ +class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_FRAME +{ +private: + // List of libraries (for selection ) + wxSashLayoutWindow* m_PageListWindow; + wxListBox* m_PageList; // The list of pages + wxSize m_PageListSize; // size of the window + + // List of components in the selected library + wxSashLayoutWindow* m_ParameterListWindow; + wxListBox* m_ParameterList; // The list of parameters + wxSize m_ParameterListSize; // size of the window + + // Flags + wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog + wxString m_configPath; // subpath for configuration + +protected: + wxString m_wizardName; //< name of the current wizard + wxString m_wizardDescription; //< description of the wizard + wxString m_wizardStatus; //< current wizard status + +public: + FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* semaphore = NULL ); + + ~FOOTPRINT_WIZARD_FRAME(); + + MODULE* GetBuiltFootrint( void ); + +private: + + void OnSize( wxSizeEvent& event ); + + /** + * Function OnSashDrag + * resizes the child windows when dragging a sash window border. + */ + + void OnSashDrag( wxSashEvent& event ); + + /** + * Function ReCreateLibraryList + * + * Creates or recreates the list of current loaded libraries. + * This list is sorted, with the library cache always at end of the list + */ + void ReCreatePageList(); + void ReCreateParameterList(); + + void Process_Special_Functions( wxCommandEvent& event ); + void DisplayWizardInfos(); + void RedrawActiveWindow( wxDC* DC, bool EraseBg ); + void OnCloseWindow( wxCloseEvent& Event ); + void ReCreateHToolbar(); + void ReCreateVToolbar(); + void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); + void ClickOnPageList( wxCommandEvent& event ); + void ClickOnParameterList( wxCommandEvent& event ); + void OnSetRelativeOffset( wxCommandEvent& event ); + + void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); + + /** + * Function LoadSettings + * loads the library viewer frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get loaded. + */ + void LoadSettings(); + + /** + * Function SaveSettings + * save library viewer frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get saved. + */ + void SaveSettings(); + + + /** + * Function OnActivate + * is called when the frame frame is activate to reload the libraries and component lists + * that can be changed by the schematic editor or the library editor. + */ + virtual void OnActivate( wxActivateEvent& event ); + + void SelectCurrentWizard( wxCommandEvent& event ); + + void ParametersUpdated( wxCommandEvent& event ); + + + + bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); + + /** + * Function Show3D_Frame (virtual) + * displays 3D view of the footprint (module) being edited. + */ + void Show3D_Frame( wxCommandEvent& event ); + + /** + * Function Update3D_Frame + * must be called after a footprint selection + * Updates the 3D view and 3D frame title. + * @param aForceReloadFootprint = true to reload data (default) + * = false to update title only -(aftre creating the 3D viewer) + */ + void Update3D_Frame( bool aForceReloadFootprint = true ); + + /* + * Virtual functions, not used here, but needed by PCB_BASE_FRAME + * (virtual pure functions ) + */ + void OnLeftDClick(wxDC*, const wxPoint&) {} + void SaveCopyInUndoList(BOARD_ITEM*, UNDO_REDO_T, const wxPoint&) {} + void SaveCopyInUndoList(PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint&) {} + + + DECLARE_EVENT_TABLE() +}; + +#endif // FOOTPRINT_WIZARD_FRM_H_ diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 0c1ccc4363..f55c561d48 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -29,6 +29,8 @@ #include #include #include +#include + // Functions defined in block_module_editor, but used here // These 2 functions are used in modedit to rotate or mirror the whole footprint @@ -283,6 +285,36 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) } break; } + + case ID_MODEDIT_NEW_MODULE_FROM_WIZARD: + { + Clear_Pcb( true ); + GetScreen()->ClearUndoRedoList(); + SetCurItem( NULL ); + GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); + + MODULE* module = NULL; + + FOOTPRINT_WIZARD_FRAME *wizard = new FOOTPRINT_WIZARD_FRAME(this,NULL); + wizard->Show( true ); + wizard->Zoom_Automatique( false ); + + if( module ) // i.e. if create module command not aborted + { + // Initialize data relative to nets and netclasses (for a new + // module the defaults are used) + // This is mandatory to handle and draw pads + GetBoard()->BuildListOfNets(); + redraw = true; + module->SetPosition( wxPoint( 0, 0 ) ); + + if( GetBoard()->m_Modules ) + GetBoard()->m_Modules->ClearFlags(); + + Zoom_Automatique( false ); + } + break; + } case ID_MODEDIT_SAVE_LIBMODULE: if( GetBoard()->m_Modules == NULL ) diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 3c6261dede..7103043235 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -71,6 +71,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_NEW_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) + EVT_TOOL( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_LOAD_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_IMPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 88bf2da19c..71d7769e5b 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -299,6 +299,7 @@ enum pcbnew_ids ID_MODEDIT_SAVE_LIBMODULE, ID_MODEDIT_DELETE_PART, ID_MODEDIT_NEW_MODULE, + ID_MODEDIT_NEW_MODULE_FROM_WIZARD, ID_MODEDIT_SHEET_SET, ID_MODEDIT_LOAD_MODULE, ID_MODEDIT_PAD_SETTINGS, @@ -323,8 +324,21 @@ enum pcbnew_ids ID_MODVIEW_PREVIOUS, ID_MODVIEW_NEXT, ID_MODVIEW_SHOW_3D_VIEW, - ID_MODVIEW_FOOTPRINT_EXPORT_TO_BOARD - + ID_MODVIEW_FOOTPRINT_EXPORT_TO_BOARD, + ID_FOOTPRINT_WIZARD_WINDOW, + ID_FOOTPRINT_WIZARD_PAGES, + ID_FOOTPRINT_WIZARD_PARAMETERS, + ID_FOOTPRINT_WIZARD_NEXT, + ID_FOOTPRINT_WIZARD_PREVIOUS, + ID_FOOTPRINT_WIZARD_DONE, + ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, + ID_FOOTPRINT_WIZARD_PAGE_LIST, + ID_FOOTPRINT_WIZARD_PARAMETER_LIST, + ID_FOOTPRINT_WIZARD_PAGES_WINDOW, + ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW, + ID_FOOTPRINT_WIZARD_SELECT_WIZARD, + ID_FOOTPRINT_WIZARD_EXPORT_TO_BOARD, + }; #endif /* __PCBNEW_IDS_H__ */ diff --git a/pcbnew/scripting/pcbnew_footprint_wizards.cpp b/pcbnew/scripting/pcbnew_footprint_wizards.cpp index 8bd60af79e..83bcb90b1a 100644 --- a/pcbnew/scripting/pcbnew_footprint_wizards.cpp +++ b/pcbnew/scripting/pcbnew_footprint_wizards.cpp @@ -1,28 +1,28 @@ /** * @file pcbnew_footprint_wizards.cpp - * @brief Class PCBNEW_FOOTPRINT_WIZARDS + * @brief Class PCBNEW_PYTHON_FOOTPRINT_WIZARDS */ #include "pcbnew_footprint_wizards.h" #include -FOOTPRINT_WIZARD::FOOTPRINT_WIZARD(PyObject *aWizard) +PYTHON_FOOTPRINT_WIZARD::PYTHON_FOOTPRINT_WIZARD(PyObject *aWizard) { - this->py_wizard = aWizard; + this->m_PyWizard= aWizard; Py_XINCREF(aWizard); } -FOOTPRINT_WIZARD::~FOOTPRINT_WIZARD() +PYTHON_FOOTPRINT_WIZARD::~PYTHON_FOOTPRINT_WIZARD() { - Py_XDECREF(this->py_wizard); + Py_XDECREF(this->m_PyWizard); } -PyObject* FOOTPRINT_WIZARD::CallMethod(const char* aMethod, PyObject *aArglist) +PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod(const char* aMethod, PyObject *aArglist) { PyObject *pFunc; /* pFunc is a new reference to the desired method */ - pFunc = PyObject_GetAttrString(this->py_wizard, aMethod); + pFunc = PyObject_GetAttrString(this->m_PyWizard, aMethod); if (pFunc && PyCallable_Check(pFunc)) { @@ -39,7 +39,6 @@ PyObject* FOOTPRINT_WIZARD::CallMethod(const char* aMethod, PyObject *aArglist) printf (" : %s\n",PyString_AsString(PyObject_Str(b))); } - if (result) { Py_XDECREF(pFunc); @@ -57,7 +56,7 @@ PyObject* FOOTPRINT_WIZARD::CallMethod(const char* aMethod, PyObject *aArglist) return NULL; } -wxString FOOTPRINT_WIZARD::CallRetStrMethod(const char* aMethod, PyObject *aArglist) +wxString PYTHON_FOOTPRINT_WIZARD::CallRetStrMethod(const char* aMethod, PyObject *aArglist) { wxString ret; PyObject *result = CallMethod(aMethod,aArglist); @@ -74,22 +73,22 @@ wxString FOOTPRINT_WIZARD::CallRetStrMethod(const char* aMethod, PyObject *aArgl return ret; } -wxString FOOTPRINT_WIZARD::GetName() +wxString PYTHON_FOOTPRINT_WIZARD::GetName() { return CallRetStrMethod("GetName"); } -wxString FOOTPRINT_WIZARD::GetImage() +wxString PYTHON_FOOTPRINT_WIZARD::GetImage() { return CallRetStrMethod("GetImage"); } -wxString FOOTPRINT_WIZARD::GetDescription() +wxString PYTHON_FOOTPRINT_WIZARD::GetDescription() { return CallRetStrMethod("GetDescription"); } -int FOOTPRINT_WIZARD::GetNumParameterPages() +int PYTHON_FOOTPRINT_WIZARD::GetNumParameterPages() { int ret; PyObject *result; @@ -106,7 +105,7 @@ int FOOTPRINT_WIZARD::GetNumParameterPages() return ret; } -wxString FOOTPRINT_WIZARD::GetParameterPageName(int aPage) +wxString PYTHON_FOOTPRINT_WIZARD::GetParameterPageName(int aPage) { wxString ret; PyObject *arglist; @@ -126,41 +125,48 @@ wxString FOOTPRINT_WIZARD::GetParameterPageName(int aPage) return ret; } -wxArrayString FOOTPRINT_WIZARD::GetParameterNames(int aPage) +wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames(int aPage) { wxArrayString a; return a; } -wxArrayString FOOTPRINT_WIZARD::GetParameterValues(int aPage) +wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterValues(int aPage) { wxArrayString a; return a; } -wxString FOOTPRINT_WIZARD::SetParameterValues(int aPage,wxArrayString& aValues) +wxString PYTHON_FOOTPRINT_WIZARD::SetParameterValues(int aPage,wxArrayString& aValues) { wxString ret; return ret; } -MODULE FOOTPRINT_WIZARD::*GetModule() +MODULE *PYTHON_FOOTPRINT_WIZARD::GetModule() { return NULL; } -std::vector FOOTPRINT_WIZARDS::m_FootprintWizards; -void FOOTPRINT_WIZARDS::register_wizard(PyObject* wizard) +void PYTHON_FOOTPRINT_WIZARDS::register_wizard(PyObject* aPyWizard) { - FOOTPRINT_WIZARD *fw; + PYTHON_FOOTPRINT_WIZARD *fw; - fw = new FOOTPRINT_WIZARD(wizard); - m_FootprintWizards.push_back(fw); + fw = new PYTHON_FOOTPRINT_WIZARD(aPyWizard); printf("Registered python footprint wizard '%s'\n", - (const char*)fw->GetName().mb_str()); + (const char*)fw->GetName().mb_str() + ); + // this get the wizard registered in the common + // FOOTPRINT_WIZARDS class + + fw->register_wizard(); + + +#if 0 + /* just to test if it works correctly */ int pages = fw->GetNumParameterPages(); printf(" %d pages\n",pages); @@ -169,7 +175,7 @@ void FOOTPRINT_WIZARDS::register_wizard(PyObject* wizard) printf(" page %d->'%s'\n",n, (const char*)fw->GetParameterPageName(n).mb_str()); } - +#endif } diff --git a/pcbnew/scripting/pcbnew_footprint_wizards.h b/pcbnew/scripting/pcbnew_footprint_wizards.h index 37349cd2d3..0e03b44a41 100644 --- a/pcbnew/scripting/pcbnew_footprint_wizards.h +++ b/pcbnew/scripting/pcbnew_footprint_wizards.h @@ -7,17 +7,17 @@ #define PCBNEW_FOOTPRINT_WIZARDS_H #include #include -#include +#include -class FOOTPRINT_WIZARD +class PYTHON_FOOTPRINT_WIZARD: public FOOTPRINT_WIZARD { - PyObject *py_wizard; + PyObject *m_PyWizard; PyObject *CallMethod(const char *aMethod, PyObject *aArglist=NULL); wxString CallRetStrMethod(const char *aMethod, PyObject *aArglist=NULL); public: - FOOTPRINT_WIZARD(PyObject *wizard); - ~FOOTPRINT_WIZARD(); + PYTHON_FOOTPRINT_WIZARD(PyObject *wizard); + ~PYTHON_FOOTPRINT_WIZARD(); wxString GetName(); wxString GetImage(); wxString GetDescription(); @@ -31,13 +31,10 @@ public: }; -class FOOTPRINT_WIZARDS +class PYTHON_FOOTPRINT_WIZARDS { -private: - static std::vector m_FootprintWizards; - public: - static void register_wizard(PyObject *wizard); + static void register_wizard(PyObject *aPyWizard); }; diff --git a/pcbnew/scripting/plugins.i b/pcbnew/scripting/plugins.i index 591ba79884..1957b7d2b4 100644 --- a/pcbnew/scripting/plugins.i +++ b/pcbnew/scripting/plugins.i @@ -3,7 +3,7 @@ #include %} -class FOOTPRINT_WIZARDS +class PYTHON_FOOTPRINT_WIZARDS { public: static void register_wizard(PyObject *wizard); diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index 85bfc7580c..3c20eb7afd 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -76,6 +76,12 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() m_mainToolBar->AddSeparator(); m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE, wxEmptyString, KiBitmap( new_footprint_xpm ), _( "New module" ) ); + + m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, wxEmptyString, + KiBitmap( module_wizard_xpm ), + _( "New module from footprint wizard" ) ); + + m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE, wxEmptyString, KiBitmap( load_module_lib_xpm ), diff --git a/scripting/kicadplugins.i b/scripting/kicadplugins.i index 084561c711..5f1147604b 100644 --- a/scripting/kicadplugins.i +++ b/scripting/kicadplugins.i @@ -35,7 +35,7 @@ class KiCadPlugin: if isinstance(self,FilePlugin): pass # register to file plugins in C++ if isinstance(self,FootprintWizardPlugin): - FOOTPRINT_WIZARDS.register_wizard(self) + PYTHON_FOOTPRINT_WIZARDS.register_wizard(self) return if isinstance(self,ActionPlugin):