Footprint wizard converts from user units to internal units back and forth, so user can type in mm or mils now
This commit is contained in:
parent
894e6eb5ea
commit
9259b21ffa
|
@ -245,6 +245,15 @@ int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ReturnValueFromString( const wxString& aTextValue )
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
|
||||||
|
value = ReturnValueFromString( g_UserUnit, aTextValue);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr )
|
int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr )
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
|
|
|
@ -108,7 +108,7 @@ void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue );
|
||||||
double From_User_Unit( EDA_UNITS_T aUnit, double aValue );
|
double From_User_Unit( EDA_UNITS_T aUnit, double aValue );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ReturnValueFromeString
|
* Function ReturnValueFromString
|
||||||
* converts \a aTextValue in \a aUnits to internal units used by the application.
|
* converts \a aTextValue in \a aUnits to internal units used by the application.
|
||||||
*
|
*
|
||||||
* @param aUnits The units of \a aTextValue.
|
* @param aUnits The units of \a aTextValue.
|
||||||
|
@ -117,6 +117,18 @@ double From_User_Unit( EDA_UNITS_T aUnit, double aValue );
|
||||||
*/
|
*/
|
||||||
int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue );
|
int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function ReturnValueFromString
|
||||||
|
|
||||||
|
* converts \a aTextValue in \a aUnits to internal units used by the application,
|
||||||
|
* unit type will be obtained from g_UserUnit.
|
||||||
|
*
|
||||||
|
* @param aTextValue A reference to a wxString object containing the string to convert.
|
||||||
|
* @return The string from Value, according to units (inch, mm ...) for display,
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ReturnValueFromString( const wxString& aTextValue );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the number Value in a string according to the internal units
|
* Convert the number Value in a string according to the internal units
|
||||||
* and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl
|
* and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl
|
||||||
|
|
|
@ -57,6 +57,15 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual wxArrayString GetParameterNames(int aPage)=0;
|
virtual wxArrayString GetParameterNames(int aPage)=0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetParameterTypes
|
||||||
|
* @param aPage is the page we want the parameter types of
|
||||||
|
* @return an array string with the parameter types on a certain page
|
||||||
|
* "IU" for internal units, "UNITS" for units (0,1,2,3...,N)
|
||||||
|
*/
|
||||||
|
virtual wxArrayString GetParameterTypes(int aPage)=0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetParameterValues
|
* Function GetParameterValues
|
||||||
* @param aPage is the page we want the parameter values of
|
* @param aPage is the page we want the parameter values of
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "footprint_wizard_frame.h"
|
#include "footprint_wizard_frame.h"
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
#include <dialogs/dialog_footprint_wizard_list.h>
|
#include <dialogs/dialog_footprint_wizard_list.h>
|
||||||
|
#include <base_units.h>
|
||||||
|
|
||||||
#define NEXT_PART 1
|
#define NEXT_PART 1
|
||||||
#define NEW_PART 0
|
#define NEW_PART 0
|
||||||
|
@ -153,11 +154,28 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
|
||||||
|
|
||||||
int n=m_ParameterGrid->GetNumberRows();
|
int n=m_ParameterGrid->GetNumberRows();
|
||||||
wxArrayString arr;
|
wxArrayString arr;
|
||||||
|
wxArrayString ptList = m_FootprintWizard->GetParameterTypes(page);
|
||||||
|
|
||||||
for (int i=0;i<n;i++)
|
for (int i=0;i<n;i++)
|
||||||
{
|
{
|
||||||
wxString val = m_ParameterGrid->GetCellValue(i,1);
|
wxString value = m_ParameterGrid->GetCellValue(i,1);
|
||||||
arr.Add(val);
|
|
||||||
|
// if this parameter is expected to be an internal
|
||||||
|
// unit convert it back from the user format
|
||||||
|
if (ptList[i]==wxT("IU"))
|
||||||
|
{
|
||||||
|
double dValue;
|
||||||
|
value.ToDouble(&dValue);
|
||||||
|
|
||||||
|
// convert from mils to inches where it's needed
|
||||||
|
if (g_UserUnit==INCHES) dValue = dValue / 1000.0;
|
||||||
|
dValue = From_User_Unit(g_UserUnit,dValue);
|
||||||
|
|
||||||
|
value.Printf(wxT("%lf"),dValue);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
arr.Add(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString res = m_FootprintWizard->SetParameterValues(page,arr);
|
wxString res = m_FootprintWizard->SetParameterValues(page,arr);
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
|
|
||||||
#include <hotkeys.h>
|
#include <hotkeys.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
|
#include <base_units.h>
|
||||||
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
|
BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
|
||||||
|
@ -177,9 +178,11 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s
|
||||||
|
|
||||||
m_ParameterGridWindow->SetSashVisible( wxSASH_RIGHT, true );
|
m_ParameterGridWindow->SetSashVisible( wxSASH_RIGHT, true );
|
||||||
m_ParameterGridWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
|
m_ParameterGridWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
|
||||||
m_ParameterGrid = new wxGrid(m_ParameterGridWindow,ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
|
m_ParameterGrid = new wxGrid(m_ParameterGridWindow,
|
||||||
|
ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
|
||||||
wxPoint(0,0),wxDefaultSize);
|
wxPoint(0,0),wxDefaultSize);
|
||||||
|
|
||||||
|
printf("pws.x=%d pws.y=%d\n",m_ParameterGridSize.x, m_ParameterGridSize.y);
|
||||||
ReCreatePageList();
|
ReCreatePageList();
|
||||||
|
|
||||||
DisplayWizardInfos();
|
DisplayWizardInfos();
|
||||||
|
@ -239,7 +242,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s
|
||||||
pane.MinSize(wxSize(m_ParameterGridSize.x, -1));
|
pane.MinSize(wxSize(m_ParameterGridSize.x, -1));
|
||||||
|
|
||||||
m_auimgr.Update();
|
m_auimgr.Update();
|
||||||
|
|
||||||
// Now Drawpanel is sized, we can use BestZoom to show the component (if any)
|
// Now Drawpanel is sized, we can use BestZoom to show the component (if any)
|
||||||
#ifdef USE_WX_GRAPHICS_CONTEXT
|
#ifdef USE_WX_GRAPHICS_CONTEXT
|
||||||
GetScreen()->SetZoom( BestZoom() );
|
GetScreen()->SetZoom( BestZoom() );
|
||||||
|
@ -390,34 +393,74 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
|
||||||
|
|
||||||
m_ParameterGrid->ClearGrid();
|
m_ParameterGrid->ClearGrid();
|
||||||
|
|
||||||
|
|
||||||
// Columns
|
// Columns
|
||||||
m_ParameterGrid->AutoSizeColumns();
|
m_ParameterGrid->AutoSizeColumns();
|
||||||
m_ParameterGrid->SetColLabelSize( 20 );
|
m_ParameterGrid->SetColLabelSize( 20 );
|
||||||
m_ParameterGrid->SetColLabelValue( 0, _("Parameter") );
|
m_ParameterGrid->SetColLabelValue( 0, _("Parameter") );
|
||||||
m_ParameterGrid->SetColLabelValue( 1, _("Value") );
|
m_ParameterGrid->SetColLabelValue( 1, _("Value") );
|
||||||
|
m_ParameterGrid->SetColLabelValue( 2, _("Units") );
|
||||||
m_ParameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
|
m_ParameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
|
||||||
|
|
||||||
|
|
||||||
// Rows
|
// Rows
|
||||||
m_ParameterGrid->AutoSizeRows();
|
m_ParameterGrid->AutoSizeRows();
|
||||||
m_ParameterGrid->EnableDragRowSize( true );
|
m_ParameterGrid->EnableDragRowSize( true );
|
||||||
m_ParameterGrid->SetRowLabelSize( 1 );
|
m_ParameterGrid->SetRowLabelSize( 1 );
|
||||||
m_ParameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
|
m_ParameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||||
|
|
||||||
|
// Get the list of names, values, and types
|
||||||
|
|
||||||
wxArrayString fpList = m_FootprintWizard->GetParameterNames(page);
|
wxArrayString fpList = m_FootprintWizard->GetParameterNames(page);
|
||||||
wxArrayString fvList = m_FootprintWizard->GetParameterValues(page);
|
wxArrayString fvList = m_FootprintWizard->GetParameterValues(page);
|
||||||
|
wxArrayString ptList = m_FootprintWizard->GetParameterTypes(page);
|
||||||
|
|
||||||
m_ParameterGrid->CreateGrid(fpList.size(),2);
|
|
||||||
|
|
||||||
|
|
||||||
|
// Dimension the wxGrid
|
||||||
|
m_ParameterGrid->CreateGrid(fpList.size(),3);
|
||||||
|
|
||||||
for (unsigned int i=0;i<fpList.size();i++)
|
for (unsigned int i=0;i<fpList.size();i++)
|
||||||
{
|
{
|
||||||
m_ParameterGrid->SetCellValue( i, 0, fpList[i] );
|
wxString name,value,units;
|
||||||
|
|
||||||
|
name = fpList[i];
|
||||||
|
value = fvList[i];
|
||||||
|
|
||||||
|
|
||||||
|
m_ParameterGrid->SetCellValue( i, 0, name);
|
||||||
m_ParameterGrid->SetReadOnly( i, 0 );
|
m_ParameterGrid->SetReadOnly( i, 0 );
|
||||||
m_ParameterGrid->SetCellValue( i, 1 , fvList[i] );
|
|
||||||
|
if (ptList[i]==wxT("IU"))
|
||||||
|
{
|
||||||
|
// We are handling internal units, so convert them to the current
|
||||||
|
// system selected units and store into value.
|
||||||
|
double dValue;
|
||||||
|
value.ToDouble(&dValue);
|
||||||
|
|
||||||
|
dValue = To_User_Unit(g_UserUnit,dValue);
|
||||||
|
|
||||||
|
if (g_UserUnit==INCHES) // we convert inches into mils for more detail
|
||||||
|
{
|
||||||
|
dValue = dValue*1000.0;
|
||||||
|
units = wxT("mils");
|
||||||
|
}
|
||||||
|
else if (g_UserUnit==MILLIMETRES)
|
||||||
|
{
|
||||||
|
units = wxT("mm");
|
||||||
|
}
|
||||||
|
|
||||||
|
value.Printf(wxT("%lf"),dValue);
|
||||||
|
}
|
||||||
|
else if (ptList[i]==wxT("UNITS")) // 1,2,3,4,5 ... N
|
||||||
|
{
|
||||||
|
units = wxT("");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ParameterGrid->SetCellValue( i, 1 , value );
|
||||||
|
|
||||||
|
m_ParameterGrid->SetCellValue( i, 2 , units );
|
||||||
|
m_ParameterGrid->SetReadOnly( i, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ParameterGrid->AutoSizeColumns();
|
m_ParameterGrid->AutoSizeColumns();
|
||||||
|
|
||||||
|
|
||||||
|
@ -452,7 +495,7 @@ void FOOTPRINT_WIZARD_FRAME::LoadSettings( )
|
||||||
cfg = wxGetApp().GetSettings();
|
cfg = wxGetApp().GetSettings();
|
||||||
|
|
||||||
m_PageListSize.x = 150; // default width of libs list
|
m_PageListSize.x = 150; // default width of libs list
|
||||||
m_ParameterGridSize.x = 250; // default width of component list
|
m_ParameterGridSize.x = 350; // default width of component list
|
||||||
|
|
||||||
cfg->Read( PARTLIST_WIDTH_KEY , &m_PageListSize.x );
|
cfg->Read( PARTLIST_WIDTH_KEY , &m_PageListSize.x );
|
||||||
cfg->Read( PARAMLIST_WIDTH_KEY, &m_ParameterGridSize.x );
|
cfg->Read( PARAMLIST_WIDTH_KEY, &m_ParameterGridSize.x );
|
||||||
|
@ -463,6 +506,7 @@ void FOOTPRINT_WIZARD_FRAME::LoadSettings( )
|
||||||
|
|
||||||
if ( m_ParameterGridSize.x > m_FrameSize.x/2 )
|
if ( m_ParameterGridSize.x > m_FrameSize.x/2 )
|
||||||
m_ParameterGridSize.x = m_FrameSize.x/2;
|
m_ParameterGridSize.x = m_FrameSize.x/2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -170,10 +170,51 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames(int aPage)
|
||||||
arglist = Py_BuildValue("(i)", aPage);
|
arglist = Py_BuildValue("(i)", aPage);
|
||||||
ret = CallRetArrayStrMethod("GetParameterNames",arglist);
|
ret = CallRetArrayStrMethod("GetParameterNames",arglist);
|
||||||
Py_DECREF(arglist);
|
Py_DECREF(arglist);
|
||||||
|
|
||||||
|
for (unsigned i=0;i<ret.GetCount();i++)
|
||||||
|
{
|
||||||
|
wxString rest;
|
||||||
|
wxString item = ret[i];
|
||||||
|
if (item.StartsWith(wxT("*"),&rest))
|
||||||
|
{
|
||||||
|
ret[i]=rest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterTypes(int aPage)
|
||||||
|
{
|
||||||
|
|
||||||
|
PyObject *arglist;
|
||||||
|
wxArrayString ret;
|
||||||
|
|
||||||
|
arglist = Py_BuildValue("(i)", aPage);
|
||||||
|
ret = CallRetArrayStrMethod("GetParameterNames",arglist);
|
||||||
|
Py_DECREF(arglist);
|
||||||
|
|
||||||
|
for (unsigned i=0;i<ret.GetCount();i++)
|
||||||
|
{
|
||||||
|
wxString rest;
|
||||||
|
wxString item = ret[i];
|
||||||
|
if (item.StartsWith(wxT("*"),&rest))
|
||||||
|
{
|
||||||
|
ret[i]=wxT("UNITS"); /* units */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret[i]=wxT("IU"); /* internal units */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterValues(int aPage)
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterValues(int aPage)
|
||||||
{
|
{
|
||||||
PyObject *arglist;
|
PyObject *arglist;
|
||||||
|
|
|
@ -29,6 +29,7 @@ public:
|
||||||
int GetNumParameterPages();
|
int GetNumParameterPages();
|
||||||
wxString GetParameterPageName(int aPage);
|
wxString GetParameterPageName(int aPage);
|
||||||
wxArrayString GetParameterNames(int aPage);
|
wxArrayString GetParameterNames(int aPage);
|
||||||
|
wxArrayString GetParameterTypes(int aPage);
|
||||||
wxArrayString GetParameterValues(int aPage);
|
wxArrayString GetParameterValues(int aPage);
|
||||||
wxArrayString GetParameterErrors(int aPage);
|
wxArrayString GetParameterErrors(int aPage);
|
||||||
wxString SetParameterValues(int aPage,wxArrayString& aValues); //< must return "OK" or error description
|
wxString SetParameterValues(int aPage,wxArrayString& aValues); //< must return "OK" or error description
|
||||||
|
|
|
@ -9,26 +9,22 @@ class FPCFootprintWizard(FootprintWizardPlugin):
|
||||||
self.description = "FPC Footprint Wizard"
|
self.description = "FPC Footprint Wizard"
|
||||||
self.parameters = {
|
self.parameters = {
|
||||||
"Pads":
|
"Pads":
|
||||||
{"n":40,"pitch":FromMM(0.5),
|
{"*n":40, # not internal units preceded by "*"
|
||||||
"width":FromMM(0.25),"height":FromMM(1.6)},
|
"pitch": FromMM(0.5),
|
||||||
|
"width": FromMM(0.25),
|
||||||
|
"height": FromMM(1.6)},
|
||||||
"Shield":
|
"Shield":
|
||||||
{"shield_to_pad":FromMM(1.6),"from_top":FromMM(1.3),
|
{"shield_to_pad": FromMM(1.6),
|
||||||
"width":FromMM(1.5),"height":FromMM(2)},
|
"from_top": FromMM(1.3),
|
||||||
|
"width": FromMM(1.5),
|
||||||
|
"height": FromMM(2)},
|
||||||
|
|
||||||
}
|
}
|
||||||
self.ClearErrors()
|
self.ClearErrors()
|
||||||
|
|
||||||
def GetParameterValues(self,page_n):
|
# build a rectangular pad
|
||||||
name = self.GetParameterPageName(page_n)
|
|
||||||
values = self.parameters[name].values()
|
|
||||||
str_values = map( lambda x: str(x) , values)
|
|
||||||
|
|
||||||
print values,str_values
|
|
||||||
return str_values
|
|
||||||
|
|
||||||
def smdRectPad(self,module,size,pos,name):
|
def smdRectPad(self,module,size,pos,name):
|
||||||
pad = D_PAD(module)
|
pad = D_PAD(module)
|
||||||
# print "smdRectPad( size=",size,"pos=",pos,"name=",name,")"
|
|
||||||
pad.SetSize(size)
|
pad.SetSize(size)
|
||||||
pad.SetShape(PAD_RECT)
|
pad.SetShape(PAD_RECT)
|
||||||
pad.SetAttribute(PAD_SMD)
|
pad.SetAttribute(PAD_SMD)
|
||||||
|
@ -37,10 +33,11 @@ class FPCFootprintWizard(FootprintWizardPlugin):
|
||||||
pad.SetPosition(pos)
|
pad.SetPosition(pos)
|
||||||
pad.SetPadName(name)
|
pad.SetPadName(name)
|
||||||
return pad
|
return pad
|
||||||
|
|
||||||
|
# This method checks the parameters provided to wizard and set errors
|
||||||
def CheckParameters(self):
|
def CheckParameters(self):
|
||||||
p = self.parameters
|
p = self.parameters
|
||||||
pads = p["Pads"]["n"]
|
pads = p["Pads"]["*n"]
|
||||||
errors = ""
|
errors = ""
|
||||||
if (pads<1):
|
if (pads<1):
|
||||||
self.parameter_errors["Pads"]["n"]="Must be positive"
|
self.parameter_errors["Pads"]["n"]="Must be positive"
|
||||||
|
@ -57,12 +54,10 @@ class FPCFootprintWizard(FootprintWizardPlugin):
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
def SetParameterValues(self,page,values):
|
|
||||||
print "SetParameterValues("+str(page)+","+str(values)+")"
|
|
||||||
FootprintWizardPlugin.SetParameterValues(self,page,values)
|
|
||||||
|
|
||||||
|
# build the footprint from parameters
|
||||||
def BuildFootprint(self):
|
def BuildFootprint(self):
|
||||||
|
|
||||||
print "parameters:",self.parameters
|
print "parameters:",self.parameters
|
||||||
#self.ClearErrors()
|
#self.ClearErrors()
|
||||||
#print "errors:",self.parameter_errors
|
#print "errors:",self.parameter_errors
|
||||||
|
@ -71,7 +66,7 @@ class FPCFootprintWizard(FootprintWizardPlugin):
|
||||||
self.module = module
|
self.module = module
|
||||||
|
|
||||||
p = self.parameters
|
p = self.parameters
|
||||||
pads = int(p["Pads"]["n"])
|
pads = int(p["Pads"]["*n"])
|
||||||
pad_width = p["Pads"]["width"]
|
pad_width = p["Pads"]["width"]
|
||||||
pad_height = p["Pads"]["height"]
|
pad_height = p["Pads"]["height"]
|
||||||
pad_pitch = p["Pads"]["pitch"]
|
pad_pitch = p["Pads"]["pitch"]
|
||||||
|
|
Loading…
Reference in New Issue