KiCad PCB EDA Suite
Loading...
Searching...
No Matches
specctra_import.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21
22/* This source is a complement to specctra.cpp and implements the import of
23 a specctra session file (*.ses), and import of a specctra design file
24 (*.dsn) file. The specification for the grammar of the specctra dsn file
25 used to develop this code is given here:
26 http://tech.groups.yahoo.com/group/kicad-users/files/ then file "specctra.pdf"
27 Also see the comments at the top of the specctra.cpp file itself.
28*/
29
30#include "specctra.h"
31
32#include <confirm.h> // DisplayErrorMessage()
33#include <fast_float/fast_float.h>
34#include <pcb_edit_frame.h>
36#include <locale_io.h>
37#include <macros.h>
38#include <board.h>
39#include <board_commit.h>
41#include <commit.h>
42#include <footprint.h>
43#include <pcb_track.h>
44#include <math/util.h> // for KiROUND
45#include <pcbnew_settings.h>
46#include <string_utils.h>
47#include <tool/actions.h>
48#include <tool/tool_manager.h>
49#include <wx/log.h>
50
51using namespace DSN;
52
53bool PCB_EDIT_FRAME::ImportSpecctraSession( const wxString& fullFileName )
54{
55 BOARD_COMMIT commit( this );
56
57 // Avoid dangling selection pointers when tracks/vias are removed by the import.
59 tools->RunAction( ACTIONS::selectionClear );
60
61 try
62 {
63 DSN::ImportSpecctraSession( GetBoard(), fullFileName, commit );
64 }
65 catch( const IO_ERROR& ioe )
66 {
67 commit.Revert();
68
69 wxString msg = _( "Board may be corrupted, do not save it.\n Fix problem and try again" );
70
71 wxString extra = ioe.What();
72
73 DisplayErrorMessage( this, msg, extra );
74 return false;
75 }
76
77 commit.Push( _( "Import Specctra Session" ) );
78
79 SetStatusText( wxString( _( "Session file imported and merged OK." ) ) );
80
81 return true;
82}
83
84
85namespace DSN {
86
87
95static int scale( double distance, UNIT_RES* aResolution )
96{
97 double resValue = aResolution->GetValue();
98 double factor;
99
100 switch( aResolution->GetEngUnits() )
101 {
102 default:
103 case T_inch: factor = 25.4e6; break; // nanometers per inch
104 case T_mil: factor = 25.4e3; break; // nanometers per mil
105 case T_cm: factor = 1e7; break; // nanometers per cm
106 case T_mm: factor = 1e6; break; // nanometers per mm
107 case T_um: factor = 1e3; break; // nanometers per um
108 }
109
110 return KiROUND( factor * distance / resValue );
111}
112
113
122static VECTOR2I mapPt( const POINT& aPoint, UNIT_RES* aResolution )
123{
124 VECTOR2I ret( scale( aPoint.x, aResolution ),
125 -scale( aPoint.y, aResolution ) ); // negate y
126
127 return ret;
128}
129
130
131PCB_TRACK* SPECCTRA_DB::makeTRACK( WIRE* wire, PATH* aPath, int aPointIndex, int aNetcode )
132{
133 int layerNdx = findLayerName( aPath->layer_id );
134
135 if( layerNdx == -1 )
136 THROW_IO_ERRORF( _( "Session file uses invalid layer id '%s'." ), From_UTF8( aPath->layer_id.c_str() ) );
137
138 PCB_TRACK* track = new PCB_TRACK( m_sessionBoard );
139
140 track->SetStart( mapPt( aPath->points[aPointIndex + 0], m_routeResolution ) );
141 track->SetEnd( mapPt( aPath->points[aPointIndex + 1], m_routeResolution ) );
142 track->SetLayer( m_pcbLayer2kicad[layerNdx] );
143 track->SetWidth( scale( aPath->aperture_width, m_routeResolution ) );
144 track->SetNetCode( aNetcode );
145
146 // a track can be locked.
147 // However specctra as 4 types, none is exactly the same as our locked option
148 // wire->wire_type = T_fix, T_route, T_normal or T_protect
149 // fix and protect could be used as lock option
150 // but protect is returned for all tracks having initially the route or protect property
151 if( wire->m_wire_type == T_fix )
152 track->SetLocked( true );
153
154 return track;
155}
156
157
158PCB_ARC* SPECCTRA_DB::makeARC( WIRE* wire, QARC* aQarc, int aNetcode )
159{
160 int layerNdx = findLayerName( aQarc->layer_id );
161
162 if( layerNdx == -1 )
163 THROW_IO_ERRORF( _( "Session file uses invalid layer id '%s'." ), From_UTF8( aQarc->layer_id.c_str() ) );
164
165 PCB_ARC* arc = new PCB_ARC( m_sessionBoard );
166
167 arc->SetStart( mapPt( aQarc->vertex[0], m_routeResolution ) );
168 arc->SetEnd( mapPt( aQarc->vertex[1], m_routeResolution ) );
169 arc->SetMid( CalcArcMid(arc->GetStart(), arc->GetEnd(), mapPt( aQarc->vertex[2], m_routeResolution ) ) );
170 arc->SetLayer( m_pcbLayer2kicad[layerNdx] );
172 arc->SetNetCode( aNetcode );
173
174 // a track can be locked.
175 // However specctra as 4 types, none is exactly the same as our locked option
176 // wire->wire_type = T_fix, T_route, T_normal or T_protect
177 // fix and protect could be used as lock option
178 // but protect is returned for all tracks having initially the route or protect property
179 if( wire->m_wire_type == T_fix )
180 arc->SetLocked( true );
181
182 return arc;
183}
184
185
186PCB_VIA* SPECCTRA_DB::makeVIA( WIRE_VIA* aVia, PADSTACK* aPadstack, const POINT& aPoint,
187 int aNetCode, int aViaDrillDefault )
188{
189 PCB_VIA* via = nullptr;
190 SHAPE* shape;
191 int shapeCount = aPadstack->Length();
192 int drill_diam_iu = -1;
193 int copperLayerCount = m_sessionBoard->GetCopperLayerCount();
194
195
196 // The drill diameter is encoded in the padstack name if Pcbnew did the DSN export.
197 // It is after the colon and before the last '_'
198 size_t drillStartNdx = aPadstack->m_padstack_id.find( ':' );
199
200 if( drillStartNdx != std::string::npos )
201 {
202 ++drillStartNdx; // skip over the ':'
203
204 size_t drillEndNdx = aPadstack->m_padstack_id.rfind( '_' );
205
206 if( drillEndNdx != std::string::npos )
207 {
208 std::string diam_txt( aPadstack->m_padstack_id, drillStartNdx,
209 drillEndNdx-drillStartNdx );
210
211 double drill_um{};
212 fast_float::from_chars( diam_txt.data(), diam_txt.data() + diam_txt.size(), drill_um,
213 fast_float::chars_format::skip_white_space );
214
215 drill_diam_iu = static_cast<int>( drill_um * ( pcbIUScale.IU_PER_MM / 1000.0 ) );
216
217 if( drill_diam_iu == aViaDrillDefault )
218 drill_diam_iu = UNDEFINED_DRILL_DIAMETER;
219 }
220 }
221
222 if( shapeCount == 0 )
223 {
224 THROW_IO_ERROR( _( "Session via padstack has no shapes" ) );
225 }
226 else if( shapeCount == 1 )
227 {
228 shape = static_cast<SHAPE*>( ( *aPadstack )[0] );
229 DSN_T type = shape->shape->Type();
230
231 if( type != T_circle )
232 THROW_IO_ERRORF( _( "Unsupported via shape: %s." ), GetTokenString( type ) );
233
234 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
235 int viaDiam = scale( circle->diameter, m_routeResolution );
236
237 via = new PCB_VIA( m_sessionBoard );
238 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
239 via->SetDrill( drill_diam_iu );
240 via->SetViaType( VIATYPE::THROUGH );
241 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
242 via->SetLayerPair( F_Cu, B_Cu );
243 }
244 else if( shapeCount == copperLayerCount )
245 {
246 shape = static_cast<SHAPE*>( ( *aPadstack )[0] );
247 DSN_T type = shape->shape->Type();
248
249 if( type != T_circle )
250 THROW_IO_ERRORF( _( "Unsupported via shape: %s" ), GetTokenString( type ) );
251
252 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
253 int viaDiam = scale( circle->diameter, m_routeResolution );
254
255 via = new PCB_VIA( m_sessionBoard );
256 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
257 via->SetDrill( drill_diam_iu );
258 via->SetViaType( VIATYPE::THROUGH );
259 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
260 via->SetLayerPair( F_Cu, B_Cu );
261 }
262 else // VIA_MICROVIA or VIA_BLIND_BURIED
263 {
264 int topLayerNdx = -1; // session layer detectors
265 int botLayerNdx = INT_MAX;
266
267 int viaDiam = -1;
268
269 for( int i = 0; i < shapeCount; ++i )
270 {
271 shape = static_cast<SHAPE*>( ( *aPadstack )[i] );
272 DSN_T type = shape->shape->Type();
273
274 if( type != T_circle )
275 THROW_IO_ERRORF( _( "Unsupported via shape: %s" ), GetTokenString( type ) );
276
277 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
278
279 int layerNdx = findLayerName( circle->layer_id );
280
281 if( layerNdx == -1 )
282 {
283 wxString layerName = From_UTF8( circle->layer_id.c_str() );
284 THROW_IO_ERRORF( _( "Session file uses invalid layer id '%s'" ), layerName );
285 }
286
287 if( layerNdx > topLayerNdx )
288 topLayerNdx = layerNdx;
289
290 if( layerNdx < botLayerNdx )
291 botLayerNdx = layerNdx;
292
293 if( viaDiam == -1 )
294 viaDiam = scale( circle->diameter, m_routeResolution );
295 }
296
297 via = new PCB_VIA( m_sessionBoard );
298 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
299 via->SetDrill( drill_diam_iu );
300
301 if( ( topLayerNdx == 0 && botLayerNdx == 1 )
302 || ( topLayerNdx == copperLayerCount - 2 && botLayerNdx == copperLayerCount - 1 ) )
303 {
304 via->SetViaType( VIATYPE::MICROVIA );
305 }
306 else if( topLayerNdx > 0 && botLayerNdx < copperLayerCount - 1 )
307 {
308 via->SetViaType( VIATYPE::BURIED );
309 }
310 else
311 {
312 via->SetViaType( VIATYPE::BLIND );
313 }
314
315 wxCHECK2( topLayerNdx >= 0, topLayerNdx = 0 );
316
317 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
318 via->SetLayerPair( m_pcbLayer2kicad[ topLayerNdx ], m_pcbLayer2kicad[ botLayerNdx ] );
319 }
320
321 wxASSERT( via );
322
323 via->SetNetCode( aNetCode );
324
325 // a via can be locked.
326 // However specctra as 4 types, none is exactly the same as our locked option
327 // aVia->via_type = T_fix, T_route, T_normal or T_protect
328 // fix and protect could be used as lock option
329 // but protect is returned for all tracks having initially the route or protect property
330 if( aVia->m_via_type == T_fix )
331 via->SetLocked( true );
332
333 return via;
334}
335
336
337// no UI code in this function, throw exception to report problems to the
338// UI handler: void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
339
340void SPECCTRA_DB::FromSESSION( BOARD* aBoard, COMMIT& aCommit )
341{
342 m_sessionBoard = aBoard; // not owned here
343
344 if( !m_session )
345 THROW_IO_ERROR( _("Session file is missing the \"session\" section") );
346
347 if( !m_session->route )
348 THROW_IO_ERROR( _("Session file is missing the \"routes\" section") );
349
350 if( !m_session->route->library )
351 THROW_IO_ERROR( _("Session file is missing the \"library_out\" section") );
352
353 // Remove unlocked tracks/vias (locked ones stay; they are exported as fixed and omitted
354 // from the .ses).
355 for( PCB_TRACK* track : aBoard->Tracks() )
356 {
357 if( !track->IsLocked() )
358 aCommit.Remove( track );
359 }
360
361 aBoard->DeleteMARKERs();
362
363 buildLayerMaps( aBoard );
364
365 // A single unresolvable place, wire, or via (e.g. a uniquified fiducial id or an unknown layer
366 // from a foreign router) must not sink the whole session, so skipped items are counted and
367 // reported once at the end.
368 int skipped = 0;
369
370 if( m_session->placement )
371 {
372 // Walk the PLACEMENT object's COMPONENTs list, and for each PLACE within
373 // each COMPONENT, reposition and re-orient each component and put on
374 // correct side of the board.
375 boost::ptr_vector<COMPONENT>& components = m_session->placement->m_components;
376
377 for( COMPONENT& component : components)
378 {
379 for( PLACE& place : component.m_places )
380 {
381 wxString reference = From_UTF8( place.m_component_id.c_str() );
382 FOOTPRINT* footprint = aBoard->FindFootprintByReference( reference );
383
384 if( !footprint )
385 {
386 ++skipped;
387 continue;
388 }
389
390 if( !place.m_hasVertex )
391 continue;
392
393 UNIT_RES* resolution = place.GetUnits();
394 wxASSERT( resolution );
395
396 aCommit.Modify( footprint );
397
398 VECTOR2I newPos = mapPt( place.m_vertex, resolution );
399 footprint->SetPosition( newPos );
400
401 if( place.m_side == T_front )
402 {
403 // convert from degrees to tenths of degrees used in KiCad.
404 EDA_ANGLE orientation( place.m_rotation, DEGREES_T );
405
406 if( footprint->GetLayer() != F_Cu )
407 {
408 // footprint is on copper layer (back)
409 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
410 }
411
412 footprint->SetOrientation( orientation );
413 }
414 else if( place.m_side == T_back )
415 {
416 EDA_ANGLE orientation( place.m_rotation + 180.0, DEGREES_T );
417
418 if( footprint->GetLayer() != B_Cu )
419 {
420 // footprint is on component layer (front)
421 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
422 }
423
424 footprint->SetOrientation( orientation );
425 }
426 else
427 {
428 // as I write this, the PARSER *is* catching this, so we should never see below:
429 wxFAIL_MSG( wxT("DSN::PARSER did not catch an illegal side := 'back|front'") );
430 }
431 }
432 }
433 }
434
435 m_routeResolution = m_session->route->GetUnits();
436
437 // Walk the NET_OUTs and create tracks and vias anew.
438 boost::ptr_vector<NET_OUT>& net_outs = m_session->route->net_outs;
439
440 // Item-local failures (unknown layer id, missing padstack) throw from the make* helpers; run
441 // each item through this guard so one bad wire or via is dropped instead of aborting.
442 auto skipOnError = [&skipped]( auto&& aBuild )
443 {
444 try
445 {
446 aBuild();
447 }
448 catch( const IO_ERROR& )
449 {
450 ++skipped;
451 }
452 };
453
454 for( NET_OUT& net_out : net_outs )
455 {
456 int netoutCode = 0;
457
458 // page 143 of spec says wire's net_id is optional
459 if( net_out.net_id.size() )
460 {
461 wxString netName = From_UTF8( net_out.net_id.c_str() );
462 NETINFO_ITEM* netinfo = aBoard->FindNet( netName );
463
464 if( netinfo )
465 netoutCode = netinfo->GetNetCode();
466 }
467
468 for( WIRE& wire : net_out.wires )
469 {
470 skipOnError( [&]()
471 {
472 DSN_T shape = wire.m_shape->Type();
473
474 if( shape == T_path )
475 {
476 PATH* path = static_cast<PATH*>( wire.m_shape );
477
478 for( unsigned pt = 0; pt < path->points.size() - 1; ++pt )
479 aCommit.Add( makeTRACK( &wire, path, pt, netoutCode ) );
480 }
481 else if( shape == T_qarc )
482 {
483 QARC* qarc = static_cast<QARC*>( wire.m_shape );
484
485 aCommit.Add( makeARC( &wire, qarc, netoutCode ) );
486 }
487 else if( shape == T_polygon )
488 {
489 // Wire polygons are zone fills from FreeRouter / Specctra
490 // ((polygon ...) or Specctra's (poly ...)). The board already has its
491 // zones; keep those and ignore the session pour geometry.
492 }
493 else
494 {
495 wxString netId = From_UTF8( wire.m_net_id.c_str() );
496 THROW_IO_ERRORF(_( "Unsupported wire shape: '%s' for net: '%s'" ), GetTokenText( shape ), netId );
497 }
498 } );
499 }
500
501 for( WIRE_VIA& wire_via : net_out.wire_vias )
502 {
503 skipOnError( [&]()
504 {
505 int netCode = 0;
506
507 // page 144 of spec says wire_via's net_id is optional
508 if( net_out.net_id.size() )
509 {
510 wxString netName = From_UTF8( net_out.net_id.c_str() );
511 NETINFO_ITEM* netvia = aBoard->FindNet( netName );
512
513 if( netvia )
514 netCode = netvia->GetNetCode();
515 }
516
517 // example: (via Via_15:8_mil 149000 -71000 )
518
519 PADSTACK* padstack = m_session->route->library->FindPADSTACK( wire_via.GetPadstackId() );
520
521 if( !padstack )
522 {
523 // Dick Feb 29, 2008:
524 // Freerouter has a bug where it will not round trip all vias. Vias which have
525 // a (use_via) element will be round tripped. Vias which do not, don't come back
526 // in in the session library, even though they may be actually used in the
527 // pre-routed, protected wire_vias. So until that is fixed, create the padstack
528 // from its name as a work around.
529 wxString psid( From_UTF8( wire_via.GetPadstackId().c_str() ) );
530
531 THROW_IO_ERRORF( _( "A wire_via refers to missing padstack '%s'." ), psid );
532 }
533
534 std::shared_ptr<NET_SETTINGS>& netSettings = aBoard->GetDesignSettings().m_NetSettings;
535
536 int via_drill_default = netSettings->GetDefaultNetclass()->GetViaDrill();
537
538 for( unsigned v = 0; v < wire_via.m_vertexes.size(); ++v )
539 aCommit.Add( makeVIA( &wire_via, padstack, wire_via.m_vertexes[v], netCode, via_drill_default ) );
540 } );
541 }
542 }
543
544 if( skipped > 0 )
545 {
546 wxLogWarning( wxString::Format( _( "%d session item(s) were skipped due to unresolved "
547 "reference, layer, or padstack." ), skipped ) );
548 }
549}
550
551
552bool ImportSpecctraSession( BOARD* aBoard, const wxString& fullFileName, COMMIT& aCommit )
553{
554 SPECCTRA_DB db;
555 LOCALE_IO toggle;
556
557 db.LoadSESSION( fullFileName );
558 db.FromSESSION( aBoard, aCommit );
559
560 return true;
561}
562} // namespace DSN
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:220
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
virtual void Revert() override
Revert the commit by restoring the modified items state.
virtual bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
std::shared_ptr< NET_SETTINGS > m_NetSettings
void SetLocked(bool aLocked) override
Definition board_item.h:386
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:373
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition board.cpp:2777
const TRACKS & Tracks() const
Definition board.h:419
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition board.cpp:2859
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1158
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition board.cpp:1852
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition commit.h:68
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition commit.h:86
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:102
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Definition commit.h:74
Implement a <component_descriptor> in the specctra dsn spec.
Definition specctra.h:1752
int Length() const
Return the number of ELEMs in this holder.
Definition specctra.h:317
virtual UNIT_RES * GetUnits() const
Return the units for this section.
DSN_T Type() const
Definition specctra.h:210
A <net_out_descriptor> of the specctra dsn spec.
Definition specctra.h:3355
Hold either a via or a pad definition.
Definition specctra.h:2095
std::string m_padstack_id
Definition specctra.h:2194
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
Definition specctra.h:580
std::vector< POINT > points
Definition specctra.h:650
double aperture_width
Definition specctra.h:648
std::string layer_id
Definition specctra.h:647
Implement a <placement_reference> in the specctra dsn spec.
Definition specctra.h:1674
bool m_hasVertex
Definition specctra.h:1725
POINT m_vertex
Definition specctra.h:1726
DSN_T m_side
Definition specctra.h:1721
double m_rotation
Definition specctra.h:1723
std::string m_component_id
reference designator
Definition specctra.h:1719
std::string layer_id
Definition specctra.h:831
double aperture_width
Definition specctra.h:832
POINT vertex[3]
Definition specctra.h:833
A "(shape ..)" element in the specctra dsn spec.
Definition specctra.h:1873
A DSN data tree, usually coming from a DSN file.
Definition specctra.h:3603
void buildLayerMaps(BOARD *aBoard)
Create a few data translation structures for layer name and number mapping between the DSN::PCB struc...
Definition specctra.cpp:73
PCB_TRACK * makeTRACK(WIRE *wire, PATH *aPath, int aPointIndex, int aNetcode)
Create a TRACK form the PATH and BOARD info.
std::map< int, PCB_LAYER_ID > m_pcbLayer2kicad
maps PCB layer number to BOARD layer numbers
Definition specctra.h:3953
UNIT_RES * m_routeResolution
used during FromSESSION() only, memory for it is not owned here.
Definition specctra.h:3956
BOARD * m_sessionBoard
a copy to avoid passing as an argument, memory for it is not owned here.
Definition specctra.h:3959
void FromSESSION(BOARD *aBoard, COMMIT &aCommit)
Add the entire SESSION info to a BOARD but does not write it out.
SESSION * m_session
Definition specctra.h:3942
void LoadSESSION(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "session" file.
Definition specctra.cpp:265
PCB_VIA * makeVIA(WIRE_VIA *aVia, PADSTACK *aPadstack, const POINT &aPoint, int aNetCode, int aViaDrillDefault)
Instantiate a KiCad VIA on the heap and initializes it with internal values consistent with the given...
PCB_ARC * makeARC(WIRE *wire, QARC *aQarc, int aNetcode)
Create an ARC form the PATH and BOARD info.
int findLayerName(const std::string &aLayerName) const
Return the PCB layer index for a given layer name, within the specctra sessionfile.
Definition specctra.cpp:96
A holder for either a T_unit or T_resolution object which are usually mutually exclusive in the dsn g...
Definition specctra.h:403
DSN_T GetEngUnits() const
Definition specctra.h:419
int GetValue() const
Definition specctra.h:420
ELEM * shape
Definition specctra.h:887
A <wire_via_descriptor> in the specctra dsn spec.
Definition specctra.h:2950
DSN_T m_via_type
Definition specctra.h:3081
const std::string & GetPadstackId()
Definition specctra.h:2961
std::vector< POINT > m_vertexes
Definition specctra.h:3078
A <wire_shape_descriptor> in the specctra dsn spec.
Definition specctra.h:2835
DSN_T m_wire_type
Definition specctra.h:2937
ELEM * m_shape
Definition specctra.h:2933
std::string m_net_id
Definition specctra.h:2935
void SetPosition(const VECTOR2I &aPos) override
void SetOrientation(const EDA_ANGLE &aNewAngle)
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition footprint.h:420
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I GetPosition() const override
Definition footprint.h:406
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
Handle the data for a net.
Definition netinfo.h:46
int GetNetCode() const
Definition netinfo.h:94
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:177
void SetMid(const VECTOR2I &aMid)
Definition pcb_track.h:285
BOARD * GetBoard() const
bool ImportSpecctraSession(const wxString &aFullFilename)
Import a specctra *.ses file and use it to relocate footprints and to replace all vias and tracks in ...
void SetEnd(const VECTOR2I &aEnd)
Definition pcb_track.h:89
void SetStart(const VECTOR2I &aStart)
Definition pcb_track.h:92
const VECTOR2I & GetStart() const
Definition pcb_track.h:93
const VECTOR2I & GetEnd() const
Definition pcb_track.h:90
virtual void SetWidth(int aWidth)
Definition pcb_track.h:86
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Master controller class:
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
This file is part of the common library.
#define _(s)
@ DEGREES_T
Definition eda_angle.h:31
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define THROW_IO_ERRORF(msg,...)
@ B_Cu
Definition layer_ids.h:61
@ F_Cu
Definition layer_ids.h:60
This file contains miscellaneous commonly used macros and functions.
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:25
This source file implements export and import capabilities to the specctra dsn file format.
Definition specctra.cpp:60
const char * GetTokenText(T aTok)
The DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.
Definition specctra.cpp:67
static POINT mapPt(const VECTOR2I &pt)
Convert a KiCad point into a DSN file point.
static double scale(int kicadDist)
Convert a distance from Pcbnew internal units to the reported Specctra DSN units in floating point fo...
bool ImportSpecctraSession(BOARD *aBoard, const wxString &fullFileName, COMMIT &aCommit)
Helper method to import SES file to a board.
#define UNDEFINED_DRILL_DIAMETER
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
DSN::T DSN_T
Definition specctra.h:51
const int scale
wxString From_UTF8(const char *cstring)
A point in the SPECCTRA DSN coordinate system.
Definition specctra.h:105
double y
Definition specctra.h:107
double x
Definition specctra.h:106
std::string path
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
const VECTOR2I CalcArcMid(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aMinArcAngle=true)
Return the middle point of an arc, half-way between aStart and aEnd.
Definition trigo.cpp:205
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683