Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
70df1517
Commit
70df1517
authored
May 16, 2012
by
Miguel Angel Ajo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Footprint wizard, plus fixes
parent
4dc70b2f
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
145 additions
and
60 deletions
+145
-60
CMakeLists.txt
pcbnew/CMakeLists.txt
+1
-0
class_footprint_wizard.h
pcbnew/class_footprint_wizard.h
+1
-0
dialog_footprint_wizard_list.cpp
pcbnew/dialogs/dialog_footprint_wizard_list.cpp
+3
-0
footprint_wizard.cpp
pcbnew/footprint_wizard.cpp
+21
-24
footprint_wizard_frame.cpp
pcbnew/footprint_wizard_frame.cpp
+1
-16
footprint_wizard_frame.h
pcbnew/footprint_wizard_frame.h
+2
-2
module.i
pcbnew/scripting/module.i
+3
-2
pcbnew_footprint_wizards.cpp
pcbnew/scripting/pcbnew_footprint_wizards.cpp
+38
-2
pcbnew_footprint_wizards.h
pcbnew/scripting/pcbnew_footprint_wizards.h
+2
-2
fpc_footprint_wizard.py
pcbnew/scripting/plugins/fpc_footprint_wizard.py
+33
-7
kicadplugins.i
scripting/kicadplugins.i
+40
-5
No files found.
pcbnew/CMakeLists.txt
View file @
70df1517
...
...
@@ -290,6 +290,7 @@ if (KICAD_SCRIPTING)
DEPENDS ../scripting/dlist.i
DEPENDS ../scripting/kicad.i
DEPENDS ../scripting/wx.i
DEPENDS ../scripting/kicadplugins.i
# DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pcbnew
COMMAND
${
SWIG_EXECUTABLE
}
${
SWIG_OPTS
}
-o
${
CMAKE_CURRENT_BINARY_DIR
}
/pcbnew_wrap.cxx scripting/pcbnew.i
...
...
pcbnew/class_footprint_wizard.h
View file @
70df1517
...
...
@@ -23,6 +23,7 @@ public:
virtual
wxString
GetParameterPageName
(
int
aPage
)
=
0
;
virtual
wxArrayString
GetParameterNames
(
int
aPage
)
=
0
;
virtual
wxArrayString
GetParameterValues
(
int
aPage
)
=
0
;
virtual
wxArrayString
GetParameterErrors
(
int
aPage
)
=
0
;
virtual
wxString
SetParameterValues
(
int
aPage
,
wxArrayString
&
aValues
)
=
0
;
virtual
MODULE
*
GetModule
()
=
0
;
void
register_wizard
();
...
...
pcbnew/dialogs/dialog_footprint_wizard_list.cpp
View file @
70df1517
...
...
@@ -28,6 +28,9 @@ DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST( wxWindow* aParent )
m_FootprintWizard
=
FOOTPRINT_WIZARDS
::
GetWizard
(
0
);
// Choose selection mode and insert the needed rows
m_footprintWizardsGrid
->
SetColSize
(
0
,
0
);
// hide the preview for now
m_footprintWizardsGrid
->
SetSelectionMode
(
wxGrid
::
wxGridSelectRows
);
m_footprintWizardsGrid
->
InsertRows
(
0
,
n_wizards
,
true
);
...
...
pcbnew/footprint_wizard.cpp
View file @
70df1517
...
...
@@ -134,31 +134,28 @@ void FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard( wxCommandEvent& event )
* Function SelectCurrentFootprint
* Selects the current footprint name and display it
*/
void
FOOTPRINT_WIZARD_FRAME
::
ParametersUpdated
(
wx
Comman
dEvent
&
event
)
void
FOOTPRINT_WIZARD_FRAME
::
ParametersUpdated
(
wx
Gri
dEvent
&
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 )
int
page
=
m_PageList
->
GetSelection
();
if
(
page
<
0
)
return
;
int
n
=
m_ParameterGrid
->
GetNumberRows
();
wxArrayString
arr
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
GetBoard()->Remove( oldmodule
);
delete oldmodule
;
wxString
val
=
m_ParameterGrid
->
GetCellValue
(
i
,
1
);
arr
.
Add
(
val
)
;
}
m_footprintName = module->GetLibRef();
module->ClearFlags();
SetCurItem( NULL );
Zoom_Automatique( false );
m_canvas->Refresh( );
Update3D_Frame();
m_FootprintList->SetStringSelection( m_footprintName );
}
* */
wxString
res
=
m_FootprintWizard
->
SetParameterValues
(
page
,
arr
);
ReloadFootprint
();
DisplayWizardInfos
();
}
...
...
pcbnew/footprint_wizard_frame.cpp
View file @
70df1517
...
...
@@ -74,7 +74,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
/* listbox events */
EVT_LISTBOX
(
ID_FOOTPRINT_WIZARD_PAGE_LIST
,
FOOTPRINT_WIZARD_FRAME
::
ClickOnPageList
)
EVT_
LISTBOX
(
ID_FOOTPRINT_WIZARD_PARAMETER_LIST
,
FOOTPRINT_WIZARD_FRAME
::
ClickOnParameterGri
d
)
EVT_
GRID_CMD_CELL_CHANGE
(
ID_FOOTPRINT_WIZARD_PARAMETER_LIST
,
FOOTPRINT_WIZARD_FRAME
::
ParametersUpdate
d
)
EVT_MENU
(
ID_SET_RELATIVE_OFFSET
,
FOOTPRINT_WIZARD_FRAME
::
OnSetRelativeOffset
)
END_EVENT_TABLE
()
...
...
@@ -412,21 +412,6 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
}
void
FOOTPRINT_WIZARD_FRAME
::
ClickOnParameterGrid
(
wxCommandEvent
&
event
)
{
int
n
=
m_ParameterGrid
->
GetNumberRows
();
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
// Get values, send them to the object..
}
ReloadFootprint
();
DisplayWizardInfos
();
}
#define PARTLIST_WIDTH_KEY wxT( "Partlist_width" )
#define PARAMLIST_WIDTH_KEY wxT( "Paramlist_width" )
...
...
pcbnew/footprint_wizard_frame.h
View file @
70df1517
...
...
@@ -37,6 +37,7 @@ class wxSashLayoutWindow;
class
wxListBox
;
class
wxSemaphore
;
class
wxGrid
;
class
wxGridEvent
;
/**
...
...
@@ -104,7 +105,6 @@ private:
void
ReCreateVToolbar
();
void
OnLeftClick
(
wxDC
*
DC
,
const
wxPoint
&
MousePos
);
void
ClickOnPageList
(
wxCommandEvent
&
event
);
void
ClickOnParameterGrid
(
wxCommandEvent
&
event
);
void
OnSetRelativeOffset
(
wxCommandEvent
&
event
);
void
GeneralControl
(
wxDC
*
aDC
,
const
wxPoint
&
aPosition
,
int
aHotKey
=
0
);
...
...
@@ -137,7 +137,7 @@ private:
void
SelectCurrentWizard
(
wxCommandEvent
&
event
);
void
ParametersUpdated
(
wx
Comman
dEvent
&
event
);
void
ParametersUpdated
(
wx
Gri
dEvent
&
event
);
...
...
pcbnew/scripting/module.i
View file @
70df1517
...
...
@@ -36,6 +36,7 @@
def GetPads(self): return self.m_Pads
def GetDrawings(self): return self.m_Drawings
def GetReferenceObj(self): return self.m_Reference
def GetValueObj(self): return self.m_Value
#def SaveToLibrary(self,filename):
# return SaveModuleToLibrary(filename,self)
...
...
pcbnew/scripting/pcbnew_footprint_wizards.cpp
View file @
70df1517
...
...
@@ -186,12 +186,44 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterValues(int aPage)
return
ret
;
}
wx
String
PYTHON_FOOTPRINT_WIZARD
::
SetParameterValues
(
int
aPage
,
wxArrayString
&
aValues
)
wx
ArrayString
PYTHON_FOOTPRINT_WIZARD
::
GetParameterErrors
(
int
aPage
)
{
wxString
ret
;
PyObject
*
arglist
;
wxArrayString
ret
;
arglist
=
Py_BuildValue
(
"(i)"
,
aPage
);
ret
=
CallRetArrayStrMethod
(
"GetParameterErrors"
,
arglist
);
Py_DECREF
(
arglist
);
return
ret
;
}
wxString
PYTHON_FOOTPRINT_WIZARD
::
SetParameterValues
(
int
aPage
,
wxArrayString
&
aValues
)
{
int
len
=
aValues
.
size
();
PyObject
*
py_list
;
py_list
=
PyList_New
(
len
);
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
wxString
str
=
aValues
[
i
];
PyObject
*
py_str
=
PyString_FromString
((
const
char
*
)
str
.
mb_str
());
PyList_SetItem
(
py_list
,
i
,
py_str
);
}
PyObject
*
arglist
;
arglist
=
Py_BuildValue
(
"(i,O)"
,
aPage
,
py_list
);
wxString
res
=
CallRetStrMethod
(
"SetParameterValues"
,
arglist
);
Py_DECREF
(
arglist
);
return
res
;
}
/* this is a SWIG function declaration -from module.i*/
MODULE
*
PyModule_to_MODULE
(
PyObject
*
obj0
);
...
...
@@ -201,14 +233,18 @@ MODULE *PYTHON_FOOTPRINT_WIZARD::GetModule()
result
=
CallMethod
(
"GetModule"
,
NULL
);
if
(
!
result
)
return
NULL
;
obj
=
PyObject_GetAttrString
(
result
,
"this"
);
if
(
PyErr_Occurred
())
{
/*
PyObject *t, *v, *b;
PyErr_Fetch(&t, &v, &b);
printf ("calling GetModule()\n");
printf ("Exception: %s\n",PyString_AsString(PyObject_Str(v)));
printf (" : %s\n",PyString_AsString(PyObject_Str(b)));
*/
PyErr_Print
();
}
...
...
pcbnew/scripting/pcbnew_footprint_wizards.h
View file @
70df1517
...
...
@@ -30,9 +30,9 @@ public:
wxString
GetParameterPageName
(
int
aPage
);
wxArrayString
GetParameterNames
(
int
aPage
);
wxArrayString
GetParameterValues
(
int
aPage
);
wxString
SetParameterValues
(
int
aPage
,
wxArrayString
&
aValues
);
wxArrayString
GetParameterErrors
(
int
aPage
);
wxString
SetParameterValues
(
int
aPage
,
wxArrayString
&
aValues
);
//< must return "OK" or error description
MODULE
*
GetModule
();
};
...
...
pcbnew/scripting/plugins/fpc_footprint_wizard.py
View file @
70df1517
...
...
@@ -16,6 +16,7 @@ class FPCFootprintWizard(FootprintWizardPlugin):
"width"
:
FromMM
(
1.5
),
"height"
:
FromMM
(
2
)},
}
self
.
ClearErrors
()
def
GetParameterValues
(
self
,
page_n
):
name
=
self
.
GetParameterPageName
(
page_n
)
...
...
@@ -37,10 +38,40 @@ class FPCFootprintWizard(FootprintWizardPlugin):
pad
.
SetPadName
(
name
)
return
pad
def
CheckParameters
(
self
):
p
=
self
.
parameters
pads
=
p
[
"Pads"
][
"n"
]
errors
=
""
if
(
pads
<
1
):
self
.
parameter_errors
[
"Pads"
][
"n"
]
=
"Must be positive"
errors
+=
"Pads/n has wrong value, "
p
[
"Pads"
][
"n"
]
=
int
(
pads
)
# make sure it stays as int (default is float)
pad_width
=
p
[
"Pads"
][
"width"
]
pad_height
=
p
[
"Pads"
][
"height"
]
pad_pitch
=
p
[
"Pads"
][
"pitch"
]
shl_width
=
p
[
"Shield"
][
"width"
]
shl_height
=
p
[
"Shield"
][
"height"
]
shl_to_pad
=
p
[
"Shield"
][
"shield_to_pad"
]
shl_from_top
=
p
[
"Shield"
][
"from_top"
]
return
errors
def
SetParameterValues
(
self
,
page
,
values
):
print
"SetParameterValues("
+
str
(
page
)
+
","
+
str
(
values
)
+
")"
FootprintWizardPlugin
.
SetParameterValues
(
self
,
page
,
values
)
def
BuildFootprint
(
self
):
print
"parameters:"
,
self
.
parameters
#self.ClearErrors()
#print "errors:",self.parameter_errors
module
=
MODULE
(
None
)
# create a new module
self
.
module
=
module
p
=
self
.
parameters
pads
=
p
[
"Pads"
][
"n"
]
pads
=
int
(
p
[
"Pads"
][
"n"
])
pad_width
=
p
[
"Pads"
][
"width"
]
pad_height
=
p
[
"Pads"
][
"height"
]
pad_pitch
=
p
[
"Pads"
][
"pitch"
]
...
...
@@ -52,9 +83,6 @@ class FPCFootprintWizard(FootprintWizardPlugin):
size_pad
=
wxSize
(
pad_width
,
pad_height
)
size_shld
=
wxSize
(
shl_width
,
shl_height
)
# create a new module
module
=
MODULE
(
None
)
module
.
SetReference
(
"FPC"
+
str
(
pads
))
# give it a reference name
module
.
m_Reference
.
SetPos0
(
wxPointMM
(
-
1
,
-
2
))
module
.
m_Reference
.
SetPosition
(
wxPointMM
(
-
1
,
-
2
))
...
...
@@ -84,11 +112,9 @@ class FPCFootprintWizard(FootprintWizardPlugin):
e
.
SetShape
(
S_SEGMENT
)
module
.
Add
(
e
)
# save the PCB to disk
module
.
SetLibRef
(
"FPC"
+
str
(
pads
))
self
.
module
=
module
# print "Module built and set:", module
# create our footprint wizard
fpc_wizard
=
FPCFootprintWizard
()
...
...
scripting/kicadplugins.i
View file @
70df1517
...
...
@@ -61,6 +61,7 @@ class FootprintWizardPlugin(KiCadPlugin):
def defaults(self):
self.module = None
self.parameters = {}
self.parameter_errors={}
self.name = "Undefined Footprint Wizard plugin"
self.description = ""
self.image = ""
...
...
@@ -88,17 +89,51 @@ class FootprintWizardPlugin(KiCadPlugin):
def GetParameterValues(self,page_n):
name = self.GetParameterPageName(page_n)
values = self.parameters[name].values()
return map( lambda x: str(x) , values)
return map( lambda x: str(x) , values)
# list elements as strings
def GetParameterErrors(self,page_n):
self.CheckParameters()
name = self.GetParameterPageName(page_n)
values = self.parameter_errors[name].values()
return map( lambda x: str(x) , values) # list elements as strings
def CheckParameters(self):
return ""
def TryConvertToFloat(self,value):
v = value
try:
v = float(value)
except:
pass
return v
def SetParameterValues(self,page_n,values):
name = self.GetParameterPageName(page
n
_n)
keys = self.parameters[name].
value
s()
name = self.GetParameterPageName(page_n)
keys = self.parameters[name].
key
s()
n=0
for key in keys:
self.parameters[name][key] = values[n]
val = self.TryConvertToFloat(values[n])
self.parameters[name][key] = val
print "[%s][%s]<="%(name,key),val
n+=1
# copies the parameter list on parameter_errors but empty
def ClearErrors(self):
errs={}
for page in self.parameters.keys():
page_dict = self.parameters[page]
page_params = {}
for param in page_dict.keys():
page_params[param]=""
errs[page]=page_params
self.parameter_errors = errs
def GetModule(self):
self.BuildFootprint()
return self.module
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment