Pcbnew: footprint wizard dialogs: minor fixes, and fixes a not working parmeters dialog under Windows, due to an incorrect Printf format.

This commit is contained in:
jean-pierre charras 2013-08-05 15:43:15 +02:00
parent c99243ffc5
commit e89db97dd4
12 changed files with 98 additions and 144 deletions

View File

@ -68,5 +68,10 @@ FOOTPRINT_WIZARD* DIALOG_FOOTPRINT_WIZARD_LIST::GetWizard()
void DIALOG_FOOTPRINT_WIZARD_LIST::OnOpenButtonClick( wxCommandEvent& event )
{
Close(true);
EndModal( wxID_OK );
}
void DIALOG_FOOTPRINT_WIZARD_LIST::OnCancelClick( wxCommandEvent& event )
{
EndModal( wxID_CANCEL );
}

View File

@ -236,90 +236,28 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER|wxALL</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Open</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_btOpen</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnOpenButtonClick</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick">OnCancelClick</event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick">OnOpenButtonClick</event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>
</object>
</object>

View File

@ -20,9 +20,9 @@ public:
FOOTPRINT_WIZARD* GetWizard();
private:
void OnCellWizardClick( wxGridEvent& event );
void OnOpenButtonClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
};
#endif // _DIALOG_FOOTPRINT_WIZARD_LIST_H_

View File

@ -51,9 +51,14 @@ DIALOG_FOOTPRINT_WIZARD_LIST_BASE::DIALOG_FOOTPRINT_WIZARD_LIST_BASE( wxWindow*
bSizerMain->Add( m_footprintWizardsGrid, 1, wxALL|wxEXPAND, 5 );
m_btOpen = new wxButton( this, wxID_ANY, _("Open"), wxDefaultPosition, wxDefaultSize, 0 );
m_btOpen->SetDefault();
bSizerMain->Add( m_btOpen, 0, wxALIGN_CENTER|wxALL, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bSizerMain->Add( m_sdbSizer, 0, wxEXPAND, 5 );
this->SetSizer( bSizerMain );
@ -63,13 +68,15 @@ DIALOG_FOOTPRINT_WIZARD_LIST_BASE::DIALOG_FOOTPRINT_WIZARD_LIST_BASE( wxWindow*
// Connect Events
m_footprintWizardsGrid->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnCellWizardClick ), NULL, this );
m_btOpen->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnOpenButtonClick ), NULL, this );
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnOpenButtonClick ), NULL, this );
}
DIALOG_FOOTPRINT_WIZARD_LIST_BASE::~DIALOG_FOOTPRINT_WIZARD_LIST_BASE()
{
// Disconnect Events
m_footprintWizardsGrid->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnCellWizardClick ), NULL, this );
m_btOpen->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnOpenButtonClick ), NULL, this );
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnOpenButtonClick ), NULL, this );
}

View File

@ -20,8 +20,8 @@ class DIALOG_SHIM;
#include <wx/font.h>
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -36,10 +36,13 @@ class DIALOG_FOOTPRINT_WIZARD_LIST_BASE : public DIALOG_SHIM
protected:
wxGrid* m_footprintWizardsGrid;
wxButton* m_btOpen;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCellWizardClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOpenButtonClick( wxCommandEvent& event ) { event.Skip(); }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -114,14 +114,14 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con
m_staticTextGrid1->Wrap( -1 );
fgSizer3->Add( m_staticTextGrid1, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxLEFT|wxTOP, 5 );
m_comboBoxGrid1 = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_comboBoxGrid1 = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
fgSizer3->Add( m_comboBoxGrid1, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
m_staticTextGrid2 = new wxStaticText( this, wxID_ANY, _("Grid 2:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextGrid2->Wrap( -1 );
fgSizer3->Add( m_staticTextGrid2, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_comboBoxGrid2 = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_comboBoxGrid2 = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
fgSizer3->Add( m_comboBoxGrid2, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );

View File

@ -1375,7 +1375,7 @@
<property name="selection">-1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="style">wxCB_READONLY</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
@ -1549,7 +1549,7 @@
<property name="selection">-1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="style">wxCB_READONLY</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!

View File

@ -34,6 +34,7 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
case ID_FOOTPRINT_WIZARD_NEXT:
m_PageList->SetSelection( m_PageList->GetSelection() + 1, true );
ClickOnPageList( event );
break;
case ID_FOOTPRINT_WIZARD_PREVIOUS:
@ -43,6 +44,7 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event )
page = 0;
m_PageList->SetSelection( page, true );
ClickOnPageList( event );
break;
default:
@ -102,19 +104,20 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
SetCurItem( NULL );
// Delete the current footprint
GetBoard()->m_Modules.DeleteAll();
MODULE* m = footprintWizard->GetModule();
if( m )
// Creates the module
MODULE* module = footprintWizard->GetModule();
if( module )
{
/* Here we should make a copy of the object before adding to board*/
m->SetParent( (EDA_ITEM*) GetBoard() );
GetBoard()->m_Modules.Append( m );
wxPoint p( 0, 0 );
m->SetPosition( p );
// Add the object to board
module->SetParent( (EDA_ITEM*) GetBoard() );
GetBoard()->m_Modules.Append( module );
module->SetPosition( wxPoint( 0, 0 ) );
}
else
{
printf( "footprintWizard->GetModule() returns NULL\n" );
D(printf( "footprintWizard->GetModule() returns NULL\n" );)
}
m_canvas->Refresh();
@ -142,14 +145,12 @@ MODULE* FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint()
{
FOOTPRINT_WIZARD* footprintWizard = FOOTPRINT_WIZARDS::GetWizard( m_wizardName );
if( footprintWizard )
if( footprintWizard && m_exportRequest )
{
return footprintWizard->GetModule();
}
else
{
return NULL;
}
}
@ -158,7 +159,8 @@ void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard()
DIALOG_FOOTPRINT_WIZARD_LIST* selectWizard =
new DIALOG_FOOTPRINT_WIZARD_LIST( this );
selectWizard->ShowModal();
if( selectWizard->ShowModal() != wxID_OK )
return;
FOOTPRINT_WIZARD* footprintWizard = selectWizard->GetWizard();
@ -225,14 +227,11 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
dValue = dValue / 1000.0;
dValue = From_User_Unit( g_UserUnit, dValue );
value.Printf( wxT( "%lf" ), dValue );
value.Printf( wxT( "%f" ), dValue );
}
// If our locale is set to use , for decimal point, just change it
// to be scripting compatible
arr.Add( value );
}

View File

@ -127,11 +127,12 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( FOOTPRINT_EDIT_FRAME* parent,
m_showAxis = true; // true to draw axis.
// Give an icon
#if 1
// Disabled for now, it raises an assert error in wxwidgets
// wxIcon icon;
// icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) );
// SetIcon( icon );
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) );
SetIcon( icon );
#endif
m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr;
m_PageList = NULL;
@ -140,6 +141,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( FOOTPRINT_EDIT_FRAME* parent,
m_ParameterGridWindow = NULL;
m_Semaphore = semaphore;
m_wizardName.Empty();
m_exportRequest = false;
if( m_Semaphore )
SetModalMode( true );
@ -199,11 +201,11 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( FOOTPRINT_EDIT_FRAME* parent,
// Columns
m_ParameterGrid->AutoSizeColumns();
m_ParameterGrid->SetColLabelSize( 20 );
m_ParameterGrid->SetColLabelValue( 0, _( "Parameter" ) );
m_ParameterGrid->SetColLabelValue( 1, _( "Value" ) );
m_ParameterGrid->SetColLabelValue( 2, _( "Units" ) );
m_ParameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
m_ParameterGrid->AutoSizeColumns();
ReCreatePageList();
@ -293,14 +295,6 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
*
*/
void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
wxCommandEvent fakeEvent;
ExportSelectedFootprint( fakeEvent );
}
void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent )
{
SaveSettings();
@ -318,6 +312,13 @@ void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent )
}
void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent )
{
m_exportRequest = true;
Close();
}
/* Function OnSashDrag
* handles the horizontal separator (sash) drag, updating the pagelist or parameter list
*/
@ -450,10 +451,9 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
m_ParameterGrid->DeleteRows( 0, m_ParameterGrid->GetNumberRows() );
m_ParameterGrid->AppendRows( fpList.size() );
wxString name, value, units;
for( unsigned int i = 0; i<fpList.size(); i++ )
{
wxString name, value, units;
name = fpList[i];
value = fvList[i];
@ -482,7 +482,8 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
units = wxT( "mm" );
}
value.Printf( wxT( "%lf" ), dValue );
std::string s = Double2Str( dValue );
value = FROM_UTF8( s.c_str() );
}
else if( ptList[i]==wxT( "UNITS" ) ) // 1,2,3,4,5 ... N
{
@ -733,11 +734,11 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_PREVIOUS, wxEmptyString,
KiBitmap( lib_previous_xpm ),
_( "Display previous page" ) );
_( "Select previous editable item" ) );
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_NEXT, wxEmptyString,
KiBitmap( lib_next_xpm ),
_( "Display next page" ) );
_( "Select next editable item" ) );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, wxEmptyString,

View File

@ -47,7 +47,6 @@ class FOOTPRINT_EDIT_FRAME;
class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_FRAME
{
private:
wxSashLayoutWindow* m_PageListWindow; // < List of libraries (for selection )
wxListBox* m_PageList; // < The list of pages
wxSize m_PageListSize; // < size of the window
@ -60,10 +59,13 @@ private:
// Flags
wxSemaphore* m_Semaphore; // < != NULL if the frame must emulate a modal dialog
wxString m_configPath; // < subpath for configuration
bool m_exportRequest; // < true if the current footprint should be exported
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( FOOTPRINT_EDIT_FRAME* parent,
wxSemaphore* semaphore = NULL,

View File

@ -311,11 +311,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_NEW_MODULE_FROM_WIZARD:
{
Clear_Pcb( true );
GetScreen()->ClearUndoRedoList();
SetCurItem( NULL );
SetCrossHairPosition( wxPoint( 0, 0 ) );
wxSemaphore semaphore( 0, 1 );
FOOTPRINT_WIZARD_FRAME *wizard = new FOOTPRINT_WIZARD_FRAME( this, &semaphore,
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
@ -328,11 +323,17 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
wxMilliSleep( 50 );
}
// Creates the new footprint from python script wizard
MODULE* module = wizard->GetBuiltFootprint();
if( module ) // i.e. if create module command not aborted
{
// Here we should make a copy of the object before adding to board
Clear_Pcb( true );
GetScreen()->ClearUndoRedoList();
SetCurItem( NULL );
SetCrossHairPosition( wxPoint( 0, 0 ) );
// Add the new object to board
module->SetParent( (EDA_ITEM*)GetBoard() );
GetBoard()->m_Modules.Append( module );
@ -342,9 +343,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
GetBoard()->BuildListOfNets();
redraw = true;
module->SetPosition( wxPoint( 0, 0 ) );
if( GetBoard()->m_Modules )
GetBoard()->m_Modules->ClearFlags();
module->ClearFlags();
}
wizard->Destroy();