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
70fde0fd
Commit
70fde0fd
authored
Feb 07, 2008
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
specctra import work
parent
c8584436
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
124 additions
and
12 deletions
+124
-12
class_board.cpp
pcbnew/class_board.cpp
+30
-0
class_board.h
pcbnew/class_board.h
+11
-0
specctra.cpp
pcbnew/specctra.cpp
+4
-0
specctra_export.cpp
pcbnew/specctra_export.cpp
+4
-0
specctra_import.cpp
pcbnew/specctra_import.cpp
+75
-12
No files found.
pcbnew/class_board.cpp
View file @
70fde0fd
...
...
@@ -726,7 +726,37 @@ EQUIPOT* BOARD::FindNet( const wxString & aNetname ) const
}
MODULE
*
BOARD
::
FindModuleByReference
(
const
wxString
&
aReference
)
const
{
struct
FindModule
:
public
INSPECTOR
{
MODULE
*
found
;
FindModule
()
:
found
(
0
)
{}
// implement interface INSPECTOR
SEARCH_RESULT
Inspect
(
EDA_BaseStruct
*
item
,
const
void
*
data
)
{
MODULE
*
module
=
(
MODULE
*
)
item
;
const
wxString
&
ref
=
*
(
const
wxString
*
)
data
;
if
(
ref
==
module
->
GetReference
()
)
{
found
=
module
;
return
SEARCH_QUIT
;
}
return
SEARCH_CONTINUE
;
}
}
inspector
;
// search only for MODULES
static
const
KICAD_T
scanTypes
[]
=
{
TYPEMODULE
,
EOT
};
// visit this BOARD with the above inspector
BOARD
*
nonconstMe
=
(
BOARD
*
)
this
;
nonconstMe
->
Visit
(
&
inspector
,
&
aReference
,
scanTypes
);
return
inspector
.
found
;
}
/* Two sort functions used in BOARD::ReturnSortedNetnamesList */
...
...
pcbnew/class_board.h
View file @
70fde0fd
...
...
@@ -203,6 +203,17 @@ public:
*/
EQUIPOT
*
FindNet
(
const
wxString
&
aNetname
)
const
;
/**
* Function FindModuleByReference
* searches for a MODULE within this board with the given
* reference designator. Finds only the first one, if there
* is more than one such MODULE.
* @param aReference The reference designator of the MODULE to find.
* @return MODULE* - If found, the MODULE having the given reference
* designator, else NULL.
*/
MODULE
*
FindModuleByReference
(
const
wxString
&
aReference
)
const
;
/**
* Function ReturnSortedNetnamesList
* searches for a net with the given netcode.
...
...
pcbnew/specctra.cpp
View file @
70fde0fd
...
...
@@ -3854,6 +3854,8 @@ int main( int argc, char** argv )
SPECCTRA_DB
db
;
bool
failed
=
false
;
setlocale
(
LC_NUMERIC
,
"C"
);
// Switch the locale to standard C
if
(
argc
==
2
)
{
filename
=
CONV_FROM_UTF8
(
argv
[
1
]
);
...
...
@@ -3882,6 +3884,8 @@ int main( int argc, char** argv )
// hose the beautified DSN file to stdout.
db
.
SetFILE
(
stdout
);
pcb
->
Format
(
&
db
,
0
);
setlocale
(
LC_NUMERIC
,
""
);
// revert to the current locale
}
#endif
...
...
pcbnew/specctra_export.cpp
View file @
70fde0fd
...
...
@@ -72,6 +72,8 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event )
db
.
SetPCB
(
SPECCTRA_DB
::
MakePCB
()
);
setlocale
(
LC_NUMERIC
,
"C"
);
// Switch the locale to standard C
try
{
db
.
FromBOARD
(
m_Pcb
);
...
...
@@ -88,6 +90,8 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event )
errorText
=
ioe
.
errorText
;
}
setlocale
(
LC_NUMERIC
,
""
);
// revert to the current locale
// The two calls below to BOARD::Change_Side_Module(), both set the
// modified flag, yet their actions cancel each other out, so it should
// be ok to clear the modify flag.
...
...
pcbnew/specctra_import.cpp
View file @
70fde0fd
...
...
@@ -75,6 +75,8 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
SPECCTRA_DB
db
;
setlocale
(
LC_NUMERIC
,
"C"
);
// Switch the locale to standard C
try
{
db
.
LoadSESSION
(
fileName
);
...
...
@@ -82,10 +84,13 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
}
catch
(
IOError
ioe
)
{
setlocale
(
LC_NUMERIC
,
""
);
// Switch the locale to standard C
DisplayError
(
this
,
ioe
.
errorText
);
return
;
}
setlocale
(
LC_NUMERIC
,
""
);
// Switch the locale to standard C
m_SelTrackWidthBox_Changed
=
TRUE
;
m_SelViaSizeBox_Changed
=
TRUE
;
...
...
@@ -101,20 +106,29 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
namespace
DSN
{
static
wxPoint
mapPt
(
const
POINT
&
aPoint
,
double
aResolution
)
{
wxPoint
ret
;
// the factor of 10.0 is used to convert mils to deci-mils, the units
// used within Kicad.
ret
.
x
=
(
int
)
(
10.0
*
aPoint
.
x
/
aResolution
);
ret
.
y
=
(
int
)
-
(
10.0
*
aPoint
.
y
/
aResolution
);
return
ret
;
}
// no UI code in this function, throw exception to report problems to the
// UI handler: void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
void
SPECCTRA_DB
::
FromSESSION
(
BOARD
*
aBoard
)
throw
(
IOError
)
{
wxASSERT
(
session
);
// delete all the old tracks and vias
aBoard
->
m_Track
->
DeleteStructList
();
aBoard
->
m_Track
=
NULL
;
aBoard
->
m_NbSegmTrack
=
0
;
aBoard
->
DeleteMARKERs
();
//wxASSERT( session );
if
(
!
session
)
ThrowIOError
(
_
(
"Session file is missing the
\"
session
\"
section"
)
);
if
(
!
session
->
placement
)
ThrowIOError
(
_
(
"Session file is missing the
\"
placement
\"
section"
)
);
...
...
@@ -125,12 +139,61 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
if
(
!
session
->
route
->
library
)
ThrowIOError
(
_
(
"Session file is missing the
\"
library_out
\"
section"
)
);
// delete all the old tracks and vias
aBoard
->
m_Track
->
DeleteStructList
();
aBoard
->
m_Track
=
NULL
;
aBoard
->
m_NbSegmTrack
=
0
;
aBoard
->
DeleteMARKERs
();
// Walk the PLACEMENT object's components list.
// Walk the PLACEMENT object's COMPONENTs list, and for each PLACE within
// each COMPONENT, reposition and re-orient each component and put on
// correct side of the board.
COMPONENTS
&
components
=
session
->
placement
->
components
;
for
(
COMPONENTS
::
iterator
i
=
components
.
begin
();
i
!=
components
.
end
();
++
i
)
for
(
COMPONENTS
::
iterator
comp
=
components
.
begin
();
comp
!=
components
.
end
();
++
comp
)
{
PLACES
&
places
=
comp
->
places
;
for
(
unsigned
i
=
0
;
i
<
places
.
size
();
++
i
)
{
PLACE
*
place
=
&
places
[
i
];
// '&' even though places[] holds a pointer!
wxString
reference
=
CONV_FROM_UTF8
(
place
->
component_id
.
c_str
()
);
MODULE
*
module
=
aBoard
->
FindModuleByReference
(
reference
);
if
(
!
module
)
{
wxString
errorMsg
;
errorMsg
.
Printf
(
_
(
"Session file has reference to non-existing component
\"
%s
\"
"
),
reference
.
GetData
()
);
ThrowIOError
(
errorMsg
);
}
if
(
!
place
->
hasVertex
)
continue
;
double
resolution
=
100
;
//place->GetResolution();
wxPoint
newPos
=
mapPt
(
place
->
vertex
,
resolution
);
module
->
SetPosition
(
newPos
);
if
(
place
->
side
==
T_front
)
{
// reposition and re-orient each component and put on correct side of the board.
// convert from degrees to tenths of degrees used in Kicad.
int
orientation
=
(
int
)
(
place
->
rotation
*
10.0
);
module
->
SetOrientation
(
orientation
);
if
(
module
->
GetLayer
()
!=
CMP_N
)
aBoard
->
Change_Side_Module
(
module
,
0
);
}
else
if
(
place
->
side
==
T_back
)
{
int
orientation
=
(
int
)
(
-
place
->
rotation
*
10.0
-
1800
);
module
->
SetOrientation
(
orientation
);
if
(
module
->
GetLayer
()
!=
COPPER_LAYER_N
)
aBoard
->
Change_Side_Module
(
module
,
0
);
}
}
}
// Walk the NET_OUTs and create tracks and vias anew.
...
...
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