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
474128a4
Commit
474128a4
authored
Jul 31, 2012
by
Miguel Angel Ajo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcbnew scripting: fixed for coding style policy
parent
f96d557e
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
176 additions
and
179 deletions
+176
-179
class_footprint_wizard.cpp
pcbnew/class_footprint_wizard.cpp
+4
-7
footprint_wizard.cpp
pcbnew/footprint_wizard.cpp
+17
-17
footprint_wizard_frame.cpp
pcbnew/footprint_wizard_frame.cpp
+22
-21
pcbnew_footprint_wizards.cpp
pcbnew/scripting/pcbnew_footprint_wizards.cpp
+101
-104
pcbnew_footprint_wizards.h
pcbnew/scripting/pcbnew_footprint_wizards.h
+12
-12
pcbnew_scripting_helpers.cpp
pcbnew/scripting/pcbnew_scripting_helpers.cpp
+13
-12
pcbnew_scripting_helpers.h
pcbnew/scripting/pcbnew_scripting_helpers.h
+7
-6
No files found.
pcbnew/class_footprint_wizard.cpp
View file @
474128a4
...
...
@@ -26,13 +26,13 @@ FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName )
{
int
max
=
GetSize
();
for
(
int
i
=
0
;
i
<
max
;
i
++
)
for
(
int
i
=
0
;
i
<
max
;
i
++
)
{
FOOTPRINT_WIZARD
*
wizard
=
GetWizard
(
i
);
wxString
name
=
wizard
->
GetName
();
if
(
name
.
Cmp
(
aName
)
)
if
(
name
.
Cmp
(
aName
)
)
return
wizard
;
}
...
...
@@ -48,11 +48,8 @@ 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() );
m_FootprintWizards
.
push_back
(
aWizard
);
}
...
...
pcbnew/footprint_wizard.cpp
View file @
474128a4
...
...
@@ -33,13 +33,13 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event )
switch
(
event
.
GetId
()
)
{
case
ID_FOOTPRINT_WIZARD_NEXT
:
m_PageList
->
SetSelection
(
m_PageList
->
GetSelection
()
+
1
,
true
);
m_PageList
->
SetSelection
(
m_PageList
->
GetSelection
()
+
1
,
true
);
break
;
case
ID_FOOTPRINT_WIZARD_PREVIOUS
:
page
=
m_PageList
->
GetSelection
()
-
1
;
if
(
page
<
0
)
page
=
0
;
m_PageList
->
SetSelection
(
page
,
true
);
m_PageList
->
SetSelection
(
page
,
true
);
break
;
default
:
...
...
@@ -95,13 +95,13 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
// Delete the current footprint
GetBoard
()
->
m_Modules
.
DeleteAll
();
MODULE
*
m
=
m_FootprintWizard
->
GetModule
();
if
(
m
)
if
(
m
)
{
/* 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
);
wxPoint
p
(
0
,
0
);
m
->
SetPosition
(
p
);
}
else
{
...
...
@@ -112,21 +112,21 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
void
FOOTPRINT_WIZARD_FRAME
::
SelectFootprintWizard
()
{
DIALOG_FOOTPRINT_WIZARD_LIST
*
selectWizard
=
new
DIALOG_FOOTPRINT_WIZARD_LIST
(
this
);
DIALOG_FOOTPRINT_WIZARD_LIST
*
selectWizard
=
new
DIALOG_FOOTPRINT_WIZARD_LIST
(
this
);
selectWizard
->
ShowModal
();
m_FootprintWizard
=
selectWizard
->
GetWizard
();
if
(
m_FootprintWizard
)
if
(
m_FootprintWizard
)
{
m_wizardName
=
m_FootprintWizard
->
GetName
();
m_wizardDescription
=
m_FootprintWizard
->
GetDescription
();
}
ReloadFootprint
();
Zoom_Automatique
(
false
);
Zoom_Automatique
(
false
);
DisplayWizardInfos
();
ReCreatePageList
();
ReCreateParameterList
();
...
...
@@ -149,36 +149,36 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
int
page
=
m_PageList
->
GetSelection
();
if
(
page
<
0
)
if
(
page
<
0
)
return
;
int
n
=
m_ParameterGrid
->
GetNumberRows
();
wxArrayString
arr
;
wxArrayString
ptList
=
m_FootprintWizard
->
GetParameterTypes
(
page
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
wxString
value
=
m_ParameterGrid
->
GetCellValue
(
i
,
1
);
wxString
value
=
m_ParameterGrid
->
GetCellValue
(
i
,
1
);
// 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
);
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
);
dValue
=
From_User_Unit
(
g_UserUnit
,
dValue
);
value
.
Printf
(
wxT
(
"%lf"
),
dValue
);
value
.
Printf
(
wxT
(
"%lf"
),
dValue
);
}
arr
.
Add
(
value
);
arr
.
Add
(
value
);
}
wxString
res
=
m_FootprintWizard
->
SetParameterValues
(
page
,
arr
);
wxString
res
=
m_FootprintWizard
->
SetParameterValues
(
page
,
arr
);
ReloadFootprint
();
DisplayWizardInfos
();
...
...
pcbnew/footprint_wizard_frame.cpp
View file @
474128a4
...
...
@@ -234,11 +234,11 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s
*/
if
(
m_PageListWindow
)
{
wxAuiPaneInfo
&
pane
=
m_auimgr
.
GetPane
(
m_PageListWindow
);
pane
.
MinSize
(
wxSize
(
m_PageListSize
.
x
,
-
1
)
);
wxAuiPaneInfo
&
pane
=
m_auimgr
.
GetPane
(
m_PageListWindow
);
pane
.
MinSize
(
wxSize
(
m_PageListSize
.
x
,
-
1
)
);
}
wxAuiPaneInfo
&
pane
=
m_auimgr
.
GetPane
(
m_ParameterGridWindow
);
pane
.
MinSize
(
wxSize
(
m_ParameterGridSize
.
x
,
-
1
)
);
wxAuiPaneInfo
&
pane
=
m_auimgr
.
GetPane
(
m_ParameterGridWindow
);
pane
.
MinSize
(
wxSize
(
m_ParameterGridSize
.
x
,
-
1
)
);
m_auimgr
.
Update
();
...
...
@@ -358,10 +358,10 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
m_PageList
->
Clear
();
int
max_page
=
m_FootprintWizard
->
GetNumParameterPages
();
for
(
int
i
=
0
;
i
<
max_page
;
i
++
)
for
(
int
i
=
0
;
i
<
max_page
;
i
++
)
{
wxString
name
=
m_FootprintWizard
->
GetParameterPageName
(
i
);
m_PageList
->
Append
(
name
);
wxString
name
=
m_FootprintWizard
->
GetParameterPageName
(
i
);
m_PageList
->
Append
(
name
);
}
m_PageList
->
SetSelection
(
0
,
true
);
...
...
@@ -414,44 +414,43 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
// 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
++
)
{
wxString
name
,
value
,
units
;
name
=
fpList
[
i
];
value
=
fvList
[
i
];
m_ParameterGrid
->
SetCellValue
(
i
,
0
,
name
);
m_ParameterGrid
->
SetCellValue
(
i
,
0
,
name
);
m_ParameterGrid
->
SetReadOnly
(
i
,
0
);
if
(
ptList
[
i
]
==
wxT
(
"IU"
)
)
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
);
value
.
ToDouble
(
&
dValue
);
dValue
=
To_User_Unit
(
g_UserUnit
,
dValue
);
dValue
=
To_User_Unit
(
g_UserUnit
,
dValue
);
if
(
g_UserUnit
==
INCHES
)
// we convert inches into mils for more detail
if
(
g_UserUnit
==
INCHES
)
// we convert inches into mils for more detail
{
dValue
=
dValue
*
1000.0
;
units
=
wxT
(
"mils"
);
units
=
wxT
(
"mils"
);
}
else
if
(
g_UserUnit
==
MILLIMETRES
)
else
if
(
g_UserUnit
==
MILLIMETRES
)
{
units
=
wxT
(
"mm"
);
units
=
wxT
(
"mm"
);
}
value
.
Printf
(
wxT
(
"%lf"
),
dValue
);
value
.
Printf
(
wxT
(
"%lf"
),
dValue
);
}
else
if
(
ptList
[
i
]
==
wxT
(
"UNITS"
)
)
// 1,2,3,4,5 ... N
else
if
(
ptList
[
i
]
==
wxT
(
"UNITS"
)
)
// 1,2,3,4,5 ... N
{
units
=
wxT
(
""
);
units
=
wxT
(
""
);
}
m_ParameterGrid
->
SetCellValue
(
i
,
1
,
value
);
m_ParameterGrid
->
SetCellValue
(
i
,
2
,
units
);
m_ParameterGrid
->
SetReadOnly
(
i
,
2
);
}
...
...
@@ -529,7 +528,7 @@ void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event )
return
;
bool
footprintWizardsChanged
=
false
;
if
(
footprintWizardsChanged
)
if
(
footprintWizardsChanged
)
{
// If we are here, the library list has changed, rebuild it
ReCreatePageList
();
...
...
@@ -734,6 +733,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
_( "Insert footprint in board" ) );
}
#endif
// after adding the buttons to the toolbar, must call Realize() to
// reflect the changes
m_mainToolBar
->
Realize
();
...
...
@@ -745,4 +745,5 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
void
FOOTPRINT_WIZARD_FRAME
::
ReCreateVToolbar
()
{
}
pcbnew/scripting/pcbnew_footprint_wizards.cpp
View file @
474128a4
This diff is collapsed.
Click to expand it.
pcbnew/scripting/pcbnew_footprint_wizards.h
View file @
474128a4
...
...
@@ -15,24 +15,24 @@ class PYTHON_FOOTPRINT_WIZARD: public FOOTPRINT_WIZARD
{
PyObject
*
m_PyWizard
;
PyObject
*
CallMethod
(
const
char
*
aMethod
,
PyObject
*
aArglist
=
NULL
);
wxString
CallRetStrMethod
(
const
char
*
aMethod
,
PyObject
*
aArglist
=
NULL
);
wxArrayString
CallRetArrayStrMethod
(
const
char
*
aMethod
,
PyObject
*
aArglist
=
NULL
);
PyObject
*
CallMethod
(
const
char
*
aMethod
,
PyObject
*
aArglist
=
NULL
);
wxString
CallRetStrMethod
(
const
char
*
aMethod
,
PyObject
*
aArglist
=
NULL
);
wxArrayString
CallRetArrayStrMethod
(
const
char
*
aMethod
,
PyObject
*
aArglist
=
NULL
);
public
:
PYTHON_FOOTPRINT_WIZARD
(
PyObject
*
wizard
);
PYTHON_FOOTPRINT_WIZARD
(
PyObject
*
wizard
);
~
PYTHON_FOOTPRINT_WIZARD
();
wxString
GetName
();
wxString
GetImage
();
wxString
GetDescription
();
int
GetNumParameterPages
();
wxString
GetParameterPageName
(
int
aPage
);
wxArrayString
GetParameterNames
(
int
aPage
);
wxArrayString
GetParameterTypes
(
int
aPage
);
wxArrayString
GetParameterValues
(
int
aPage
);
wxArrayString
GetParameterErrors
(
int
aPage
);
wxString
SetParameterValues
(
int
aPage
,
wxArrayString
&
aValues
);
//< must return "OK" or error description
wxString
GetParameterPageName
(
int
aPage
);
wxArrayString
GetParameterNames
(
int
aPage
);
wxArrayString
GetParameterTypes
(
int
aPage
);
wxArrayString
GetParameterValues
(
int
aPage
);
wxArrayString
GetParameterErrors
(
int
aPage
);
wxString
SetParameterValues
(
int
aPage
,
wxArrayString
&
aValues
);
//< must return "OK" or error description
MODULE
*
GetModule
();
};
...
...
@@ -40,7 +40,7 @@ public:
class
PYTHON_FOOTPRINT_WIZARDS
{
public
:
static
void
register_wizard
(
PyObject
*
aPyWizard
);
static
void
register_wizard
(
PyObject
*
aPyWizard
);
};
...
...
pcbnew/scripting/pcbnew_scripting_helpers.cpp
View file @
474128a4
...
...
@@ -43,20 +43,22 @@ static PCB_EDIT_FRAME *PcbEditFrame=NULL;
BOARD
*
GetBoard
()
{
if
(
PcbEditFrame
)
return
PcbEditFrame
->
GetBoard
();
if
(
PcbEditFrame
)
return
PcbEditFrame
->
GetBoard
();
else
return
NULL
;
}
void
ScriptingSetPcbEditFrame
(
PCB_EDIT_FRAME
*
aPCBEdaFrame
)
void
ScriptingSetPcbEditFrame
(
PCB_EDIT_FRAME
*
aPCBEdaFrame
)
{
PcbEditFrame
=
aPCBEdaFrame
;
}
BOARD
*
LoadBoard
(
wxString
&
aFileName
)
BOARD
*
LoadBoard
(
wxString
&
aFileName
)
{
if
(
aFileName
.
EndsWith
(
wxT
(
".kicad_brd"
))
)
if
(
aFileName
.
EndsWith
(
wxT
(
".kicad_brd"
)
)
)
return
LoadBoard
(
aFileName
,
IO_MGR
::
KICAD
);
else
if
(
aFileName
.
EndsWith
(
wxT
(
".brd"
)))
return
LoadBoard
(
aFileName
,
IO_MGR
::
LEGACY
);
...
...
@@ -65,19 +67,18 @@ BOARD* LoadBoard(wxString& aFileName)
}
BOARD
*
LoadBoard
(
wxString
&
aFileName
,
IO_MGR
::
PCB_FILE_T
aFormat
)
BOARD
*
LoadBoard
(
wxString
&
aFileName
,
IO_MGR
::
PCB_FILE_T
aFormat
)
{
return
IO_MGR
::
Load
(
aFormat
,
aFileName
);
return
IO_MGR
::
Load
(
aFormat
,
aFileName
);
}
bool
SaveBoard
(
wxString
&
aFilename
,
BOARD
*
aBoard
)
bool
SaveBoard
(
wxString
&
aFilename
,
BOARD
*
aBoard
)
{
return
SaveBoard
(
aFilename
,
aBoard
,
IO_MGR
::
KICAD
);
return
SaveBoard
(
aFilename
,
aBoard
,
IO_MGR
::
KICAD
);
}
bool
SaveBoard
(
wxString
&
aFileName
,
BOARD
*
aBoard
,
IO_MGR
::
PCB_FILE_T
aFormat
)
bool
SaveBoard
(
wxString
&
aFileName
,
BOARD
*
aBoard
,
IO_MGR
::
PCB_FILE_T
aFormat
)
{
aBoard
->
m_Status_Pcb
&=
~
CONNEXION_OK
;
aBoard
->
SynchronizeNetsAndNetClasses
();
...
...
@@ -86,7 +87,7 @@ bool SaveBoard(wxString& aFileName, BOARD* aBoard,
wxString
header
;
PROPERTIES
props
;
if
(
aFormat
==
IO_MGR
::
LEGACY
)
if
(
aFormat
==
IO_MGR
::
LEGACY
)
{
header
=
wxString
::
Format
(
wxT
(
"PCBNEW-BOARD Version %d date %s
\n\n
# Created by Pcbnew%s scripting
\n\n
"
),
...
...
pcbnew/scripting/pcbnew_scripting_helpers.h
View file @
474128a4
...
...
@@ -7,15 +7,16 @@
* we want plain pcbnew.<method_name> access from python */
#ifndef SWIG
void
ScriptingSetPcbEditFrame
(
PCB_EDIT_FRAME
*
aPCBEdaFrame
);
void
ScriptingSetPcbEditFrame
(
PCB_EDIT_FRAME
*
aPCBEdaFrame
);
#endif
BOARD
*
GetBoard
();
BOARD
*
LoadBoard
(
wxString
&
aFileName
,
IO_MGR
::
PCB_FILE_T
aFormat
);
BOARD
*
LoadBoard
(
wxString
&
aFileName
);
bool
SaveBoard
(
wxString
&
aFileName
,
BOARD
*
aBoard
,
IO_MGR
::
PCB_FILE_T
aFormat
);
bool
SaveBoard
(
wxString
&
aFileName
,
BOARD
*
aBoard
);
BOARD
*
LoadBoard
(
wxString
&
aFileName
,
IO_MGR
::
PCB_FILE_T
aFormat
);
BOARD
*
LoadBoard
(
wxString
&
aFileName
);
bool
SaveBoard
(
wxString
&
aFileName
,
BOARD
*
aBoard
,
IO_MGR
::
PCB_FILE_T
aFormat
);
bool
SaveBoard
(
wxString
&
aFileName
,
BOARD
*
aBoard
);
#endif
\ No newline at end of file
#endif
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