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>
40#include <footprint.h>
41#include <pcb_group.h>
42#include <pcb_track.h>
44#include <view/view.h>
45#include <math/util.h> // for KiROUND
46#include <pcbnew_settings.h>
47#include <string_utils.h>
48#include <wx/log.h>
49
50using namespace DSN;
51
52bool PCB_EDIT_FRAME::ImportSpecctraSession( const wxString& fullFileName )
53{
54 // To avoid issues with undo/redo lists (dangling pointers) clear the lists
55 // todo: use undo/redo feature
57
58 if( GetCanvas() ) // clear view:
59 {
60 for( PCB_TRACK* track : GetBoard()->Tracks() )
61 GetCanvas()->GetView()->Remove( track );
62 }
63
64 try
65 {
66 DSN::ImportSpecctraSession( GetBoard(), fullFileName );
67 }
68 catch( const IO_ERROR& ioe )
69 {
70 wxString msg = _( "Board may be corrupted, do not save it.\n Fix problem and try again" );
71
72 wxString extra = ioe.What();
73
74 DisplayErrorMessage( this, msg, extra );
75 return false;
76 }
77
78 OnModify();
79
80 if( GetCanvas() ) // Update view:
81 {
82 // Update footprint positions
83
84 // add imported tracks (previous tracks are removed, therefore all are new)
85 for( PCB_TRACK* track : GetBoard()->Tracks() )
86 GetCanvas()->GetView()->Add( track );
87 }
88
89 SetStatusText( wxString( _( "Session file imported and merged OK." ) ) );
90
91 Refresh();
92
93 return true;
94}
95
96
97namespace DSN {
98
99
107static int scale( double distance, UNIT_RES* aResolution )
108{
109 double resValue = aResolution->GetValue();
110 double factor;
111
112 switch( aResolution->GetEngUnits() )
113 {
114 default:
115 case T_inch: factor = 25.4e6; break; // nanometers per inch
116 case T_mil: factor = 25.4e3; break; // nanometers per mil
117 case T_cm: factor = 1e7; break; // nanometers per cm
118 case T_mm: factor = 1e6; break; // nanometers per mm
119 case T_um: factor = 1e3; break; // nanometers per um
120 }
121
122 return KiROUND( factor * distance / resValue );
123}
124
125
134static VECTOR2I mapPt( const POINT& aPoint, UNIT_RES* aResolution )
135{
136 VECTOR2I ret( scale( aPoint.x, aResolution ),
137 -scale( aPoint.y, aResolution ) ); // negate y
138
139 return ret;
140}
141
142
143PCB_TRACK* SPECCTRA_DB::makeTRACK( WIRE* wire, PATH* aPath, int aPointIndex, int aNetcode )
144{
145 int layerNdx = findLayerName( aPath->layer_id );
146
147 if( layerNdx == -1 )
148 {
149 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'." ),
150 From_UTF8( aPath->layer_id.c_str() ) ) );
151 }
152
153 PCB_TRACK* track = new PCB_TRACK( m_sessionBoard );
154
155 track->SetStart( mapPt( aPath->points[aPointIndex + 0], m_routeResolution ) );
156 track->SetEnd( mapPt( aPath->points[aPointIndex + 1], m_routeResolution ) );
157 track->SetLayer( m_pcbLayer2kicad[layerNdx] );
158 track->SetWidth( scale( aPath->aperture_width, m_routeResolution ) );
159 track->SetNetCode( aNetcode );
160
161 // a track can be locked.
162 // However specctra as 4 types, none is exactly the same as our locked option
163 // wire->wire_type = T_fix, T_route, T_normal or T_protect
164 // fix and protect could be used as lock option
165 // but protect is returned for all tracks having initially the route or protect property
166 if( wire->m_wire_type == T_fix )
167 track->SetLocked( true );
168
169 return track;
170}
171
172
173PCB_ARC* SPECCTRA_DB::makeARC( WIRE* wire, QARC* aQarc, int aNetcode )
174{
175 int layerNdx = findLayerName( aQarc->layer_id );
176
177 if( layerNdx == -1 )
178 {
179 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'." ),
180 From_UTF8( aQarc->layer_id.c_str() ) ) );
181 }
182
183 PCB_ARC* arc = new PCB_ARC( m_sessionBoard );
184
185 arc->SetStart( mapPt( aQarc->vertex[0], m_routeResolution ) );
186 arc->SetEnd( mapPt( aQarc->vertex[1], m_routeResolution ) );
187 arc->SetMid( CalcArcMid(arc->GetStart(), arc->GetEnd(), mapPt( aQarc->vertex[2], m_routeResolution ) ) );
188 arc->SetLayer( m_pcbLayer2kicad[layerNdx] );
190 arc->SetNetCode( aNetcode );
191
192 // a track can be locked.
193 // However specctra as 4 types, none is exactly the same as our locked option
194 // wire->wire_type = T_fix, T_route, T_normal or T_protect
195 // fix and protect could be used as lock option
196 // but protect is returned for all tracks having initially the route or protect property
197 if( wire->m_wire_type == T_fix )
198 arc->SetLocked( true );
199
200 return arc;
201}
202
203
204PCB_VIA* SPECCTRA_DB::makeVIA( WIRE_VIA* aVia, PADSTACK* aPadstack, const POINT& aPoint,
205 int aNetCode, int aViaDrillDefault )
206{
207 PCB_VIA* via = nullptr;
208 SHAPE* shape;
209 int shapeCount = aPadstack->Length();
210 int drill_diam_iu = -1;
211 int copperLayerCount = m_sessionBoard->GetCopperLayerCount();
212
213
214 // The drill diameter is encoded in the padstack name if Pcbnew did the DSN export.
215 // It is after the colon and before the last '_'
216 size_t drillStartNdx = aPadstack->m_padstack_id.find( ':' );
217
218 if( drillStartNdx != std::string::npos )
219 {
220 ++drillStartNdx; // skip over the ':'
221
222 size_t drillEndNdx = aPadstack->m_padstack_id.rfind( '_' );
223
224 if( drillEndNdx != std::string::npos )
225 {
226 std::string diam_txt( aPadstack->m_padstack_id, drillStartNdx,
227 drillEndNdx-drillStartNdx );
228
229 double drill_um{};
230 fast_float::from_chars( diam_txt.data(), diam_txt.data() + diam_txt.size(), drill_um,
231 fast_float::chars_format::skip_white_space );
232
233 drill_diam_iu = static_cast<int>( drill_um * ( pcbIUScale.IU_PER_MM / 1000.0 ) );
234
235 if( drill_diam_iu == aViaDrillDefault )
236 drill_diam_iu = UNDEFINED_DRILL_DIAMETER;
237 }
238 }
239
240 if( shapeCount == 0 )
241 {
242 THROW_IO_ERROR( _( "Session via padstack has no shapes" ) );
243 }
244 else if( shapeCount == 1 )
245 {
246 shape = static_cast<SHAPE*>( ( *aPadstack )[0] );
247 DSN_T type = shape->shape->Type();
248
249 if( type != T_circle )
250 THROW_IO_ERROR( wxString::Format( _( "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 if( shapeCount == copperLayerCount )
263 {
264 shape = static_cast<SHAPE*>( ( *aPadstack )[0] );
265 DSN_T type = shape->shape->Type();
266
267 if( type != T_circle )
268 {
269 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s" ), GetTokenString( type ) ) );
270 }
271
272 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
273 int viaDiam = scale( circle->diameter, m_routeResolution );
274
275 via = new PCB_VIA( m_sessionBoard );
276 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
277 via->SetDrill( drill_diam_iu );
278 via->SetViaType( VIATYPE::THROUGH );
279 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
280 via->SetLayerPair( F_Cu, B_Cu );
281 }
282 else // VIA_MICROVIA or VIA_BLIND_BURIED
283 {
284 int topLayerNdx = -1; // session layer detectors
285 int botLayerNdx = INT_MAX;
286
287 int viaDiam = -1;
288
289 for( int i = 0; i < shapeCount; ++i )
290 {
291 shape = static_cast<SHAPE*>( ( *aPadstack )[i] );
292 DSN_T type = shape->shape->Type();
293
294 if( type != T_circle )
295 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s" ), GetTokenString( type ) ) );
296
297 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
298
299 int layerNdx = findLayerName( circle->layer_id );
300
301 if( layerNdx == -1 )
302 {
303 wxString layerName = From_UTF8( circle->layer_id.c_str() );
304 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'" ), layerName ) );
305 }
306
307 if( layerNdx > topLayerNdx )
308 topLayerNdx = layerNdx;
309
310 if( layerNdx < botLayerNdx )
311 botLayerNdx = layerNdx;
312
313 if( viaDiam == -1 )
314 viaDiam = scale( circle->diameter, m_routeResolution );
315 }
316
317 via = new PCB_VIA( m_sessionBoard );
318 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
319 via->SetDrill( drill_diam_iu );
320
321 if( ( topLayerNdx == 0 && botLayerNdx == 1 )
322 || ( topLayerNdx == copperLayerCount - 2 && botLayerNdx == copperLayerCount - 1 ) )
323 {
324 via->SetViaType( VIATYPE::MICROVIA );
325 }
326 else if( topLayerNdx > 0 && botLayerNdx < copperLayerCount - 1 )
327 {
328 via->SetViaType( VIATYPE::BURIED );
329 }
330 else
331 {
332 via->SetViaType( VIATYPE::BLIND );
333 }
334
335 wxCHECK2( topLayerNdx >= 0, topLayerNdx = 0 );
336
337 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
338 via->SetLayerPair( m_pcbLayer2kicad[ topLayerNdx ], m_pcbLayer2kicad[ botLayerNdx ] );
339 }
340
341 wxASSERT( via );
342
343 via->SetNetCode( aNetCode );
344
345 // a via can be locked.
346 // However specctra as 4 types, none is exactly the same as our locked option
347 // aVia->via_type = T_fix, T_route, T_normal or T_protect
348 // fix and protect could be used as lock option
349 // but protect is returned for all tracks having initially the route or protect property
350 if( aVia->m_via_type == T_fix )
351 via->SetLocked( true );
352
353 return via;
354}
355
356
357// no UI code in this function, throw exception to report problems to the
358// UI handler: void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
359
361{
362 m_sessionBoard = aBoard; // not owned here
363
364 if( !m_session )
365 THROW_IO_ERROR( _("Session file is missing the \"session\" section") );
366
367 if( !m_session->route )
368 THROW_IO_ERROR( _("Session file is missing the \"routes\" section") );
369
370 if( !m_session->route->library )
371 THROW_IO_ERROR( _("Session file is missing the \"library_out\" section") );
372
373 // delete the old tracks and vias but save locked tracks/vias; they will be re-added later
374 std::vector<PCB_TRACK*> locked;
375 TRACKS tracks = aBoard->Tracks();
376 aBoard->RemoveAll( { PCB_TRACE_T } );
377
378 for( PCB_TRACK* track : tracks )
379 {
380 if( track->IsLocked() )
381 {
382 locked.push_back( track );
383 }
384 else
385 {
386 if( EDA_GROUP* group = track->GetParentGroup() )
387 group->RemoveItem( track );
388
389 delete track;
390 }
391 }
392
393 aBoard->DeleteMARKERs();
394
395 buildLayerMaps( aBoard );
396
397 // Add locked tracks: because they are exported as Fix tracks, they are not
398 // in .ses file.
399 for( PCB_TRACK* track : locked )
400 aBoard->Add( track );
401
402 // A single unresolvable place, wire, or via (e.g. a uniquified fiducial id or an unknown layer
403 // from a foreign router) must not sink the whole session, so skipped items are counted and
404 // reported once at the end.
405 int skipped = 0;
406
407 if( m_session->placement )
408 {
409 // Walk the PLACEMENT object's COMPONENTs list, and for each PLACE within
410 // each COMPONENT, reposition and re-orient each component and put on
411 // correct side of the board.
412 boost::ptr_vector<COMPONENT>& components = m_session->placement->m_components;
413
414 for( COMPONENT& component : components)
415 {
416 for( PLACE& place : component.m_places )
417 {
418 wxString reference = From_UTF8( place.m_component_id.c_str() );
419 FOOTPRINT* footprint = aBoard->FindFootprintByReference( reference );
420
421 if( !footprint )
422 {
423 ++skipped;
424 continue;
425 }
426
427 if( !place.m_hasVertex )
428 continue;
429
430 UNIT_RES* resolution = place.GetUnits();
431 wxASSERT( resolution );
432
433 VECTOR2I newPos = mapPt( place.m_vertex, resolution );
434 footprint->SetPosition( newPos );
435
436 if( place.m_side == T_front )
437 {
438 // convert from degrees to tenths of degrees used in KiCad.
439 EDA_ANGLE orientation( place.m_rotation, DEGREES_T );
440
441 if( footprint->GetLayer() != F_Cu )
442 {
443 // footprint is on copper layer (back)
444 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
445 }
446
447 footprint->SetOrientation( orientation );
448 }
449 else if( place.m_side == T_back )
450 {
451 EDA_ANGLE orientation( place.m_rotation + 180.0, DEGREES_T );
452
453 if( footprint->GetLayer() != B_Cu )
454 {
455 // footprint is on component layer (front)
456 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
457 }
458
459 footprint->SetOrientation( orientation );
460 }
461 else
462 {
463 // as I write this, the PARSER *is* catching this, so we should never see below:
464 wxFAIL_MSG( wxT("DSN::PARSER did not catch an illegal side := 'back|front'") );
465 }
466 }
467 }
468 }
469
470 m_routeResolution = m_session->route->GetUnits();
471
472 // Walk the NET_OUTs and create tracks and vias anew.
473 boost::ptr_vector<NET_OUT>& net_outs = m_session->route->net_outs;
474
475 // Item-local failures (unknown layer id, missing padstack) throw from the make* helpers; run
476 // each item through this guard so one bad wire or via is dropped instead of aborting.
477 auto skipOnError = [&skipped]( auto&& aBuild )
478 {
479 try
480 {
481 aBuild();
482 }
483 catch( const IO_ERROR& )
484 {
485 ++skipped;
486 }
487 };
488
489 for( NET_OUT& net_out : net_outs )
490 {
491 int netoutCode = 0;
492
493 // page 143 of spec says wire's net_id is optional
494 if( net_out.net_id.size() )
495 {
496 wxString netName = From_UTF8( net_out.net_id.c_str() );
497 NETINFO_ITEM* netinfo = aBoard->FindNet( netName );
498
499 if( netinfo )
500 netoutCode = netinfo->GetNetCode();
501 }
502
503 for( WIRE& wire : net_out.wires )
504 {
505 skipOnError( [&]()
506 {
507 DSN_T shape = wire.m_shape->Type();
508
509 if( shape == T_path )
510 {
511 PATH* path = static_cast<PATH*>( wire.m_shape );
512
513 for( unsigned pt = 0; pt < path->points.size() - 1; ++pt )
514 aBoard->Add( makeTRACK( &wire, path, pt, netoutCode ) );
515 }
516 else if( shape == T_qarc )
517 {
518 QARC* qarc = static_cast<QARC*>( wire.m_shape );
519
520 aBoard->Add( makeARC( &wire, qarc, netoutCode ) );
521 }
522 else
523 {
524 /*
525 * shape == T_polygon is expected from freerouter if you have a zone on a non-
526 * "power" type layer, i.e. a T_signal layer and the design does a round-trip
527 * back in as session here. We kept our own zones in the BOARD, so ignore this
528 * so called 'wire'.
529
530 wxString netId = From_UTF8( wire->net_id.c_str() );
531 THROW_IO_ERROR( wxString::Format( _( "Unsupported wire shape: '%s' for net: '%s'" ),
532 DLEX::GetTokenString(shape).GetData(),
533 netId.GetData() ) );
534 */
535 }
536 } );
537 }
538
539 for( WIRE_VIA& wire_via : net_out.wire_vias )
540 {
541 skipOnError( [&]()
542 {
543 int netCode = 0;
544
545 // page 144 of spec says wire_via's net_id is optional
546 if( net_out.net_id.size() )
547 {
548 wxString netName = From_UTF8( net_out.net_id.c_str() );
549 NETINFO_ITEM* netvia = aBoard->FindNet( netName );
550
551 if( netvia )
552 netCode = netvia->GetNetCode();
553 }
554
555 // example: (via Via_15:8_mil 149000 -71000 )
556
557 PADSTACK* padstack =
558 m_session->route->library->FindPADSTACK( wire_via.GetPadstackId() );
559
560 if( !padstack )
561 {
562 // Dick Feb 29, 2008:
563 // Freerouter has a bug where it will not round trip all vias. Vias which have
564 // a (use_via) element will be round tripped. Vias which do not, don't come back
565 // in in the session library, even though they may be actually used in the
566 // pre-routed, protected wire_vias. So until that is fixed, create the padstack
567 // from its name as a work around.
568 wxString psid( From_UTF8( wire_via.GetPadstackId().c_str() ) );
569
570 THROW_IO_ERROR( wxString::Format( _( "A wire_via refers to missing padstack '%s'." ),
571 psid ) );
572 }
573
574 std::shared_ptr<NET_SETTINGS>& netSettings = aBoard->GetDesignSettings().m_NetSettings;
575
576 int via_drill_default = netSettings->GetDefaultNetclass()->GetViaDrill();
577
578 for( unsigned v = 0; v < wire_via.m_vertexes.size(); ++v )
579 {
580 aBoard->Add( makeVIA( &wire_via, padstack, wire_via.m_vertexes[v], netCode,
581 via_drill_default ) );
582 }
583 } );
584 }
585 }
586
587 if( skipped > 0 )
588 {
589 wxLogWarning( wxString::Format( _( "%d session item(s) were skipped due to unresolved "
590 "reference, layer, or padstack." ), skipped ) );
591 }
592}
593
594
595bool ImportSpecctraSession( BOARD* aBoard, const wxString& fullFileName )
596{
597 SPECCTRA_DB db;
598 LOCALE_IO toggle;
599
600 db.LoadSESSION( fullFileName );
601 db.FromSESSION( aBoard );
602
603 aBoard->GetConnectivity()->ClearRatsnest();
604 aBoard->BuildConnectivity();
605
606 return true;
607}
608} // namespace DSN
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
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:358
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:373
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1350
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition board.cpp:2727
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition board.cpp:200
void RemoveAll(std::initializer_list< KICAD_T > aTypes={ PCB_NETINFO_T, PCB_MARKER_T, PCB_GROUP_T, PCB_ZONE_T, PCB_GENERATOR_T, PCB_FOOTPRINT_T, PCB_TRACE_T, PCB_SHAPE_T })
An efficient way to remove all items of a certain type from the board.
Definition board.cpp:1592
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:2809
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1153
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition board.cpp:1838
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:642
void ClearRatsnest()
Function Clear() Erases the connectivity database.
Implement a <component_descriptor> in the specctra dsn spec.
Definition specctra.h:1751
int Length() const
Return the number of ELEMs in this holder.
Definition specctra.h:316
virtual UNIT_RES * GetUnits() const
Return the units for this section.
DSN_T Type() const
Definition specctra.h:209
A <net_out_descriptor> of the specctra dsn spec.
Definition specctra.h:3346
Hold either a via or a pad definition.
Definition specctra.h:2094
std::string m_padstack_id
Definition specctra.h:2193
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
Definition specctra.h:579
std::vector< POINT > points
Definition specctra.h:649
double aperture_width
Definition specctra.h:647
std::string layer_id
Definition specctra.h:646
Implement a <placement_reference> in the specctra dsn spec.
Definition specctra.h:1673
bool m_hasVertex
Definition specctra.h:1724
POINT m_vertex
Definition specctra.h:1725
DSN_T m_side
Definition specctra.h:1720
double m_rotation
Definition specctra.h:1722
std::string m_component_id
reference designator
Definition specctra.h:1718
std::string layer_id
Definition specctra.h:830
double aperture_width
Definition specctra.h:831
POINT vertex[3]
Definition specctra.h:832
A "(shape ..)" element in the specctra dsn spec.
Definition specctra.h:1872
A DSN data tree, usually coming from a DSN file.
Definition specctra.h:3589
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:3937
UNIT_RES * m_routeResolution
used during FromSESSION() only, memory for it is not owned here.
Definition specctra.h:3940
BOARD * m_sessionBoard
a copy to avoid passing as an argument, memory for it is not owned here.
Definition specctra.h:3943
SESSION * m_session
Definition specctra.h:3926
void LoadSESSION(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "session" file.
Definition specctra.cpp:265
void FromSESSION(BOARD *aBoard)
Add the entire SESSION info to a BOARD but does not write it out.
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:402
DSN_T GetEngUnits() const
Definition specctra.h:418
int GetValue() const
Definition specctra.h:419
ELEM * shape
Definition specctra.h:886
A <wire_via_descriptor> in the specctra dsn spec.
Definition specctra.h:2941
DSN_T m_via_type
Definition specctra.h:3072
const std::string & GetPadstackId()
Definition specctra.h:2952
std::vector< POINT > m_vertexes
Definition specctra.h:3069
A <wire_shape_descriptor> in the specctra dsn spec.
Definition specctra.h:2834
DSN_T m_wire_type
Definition specctra.h:2928
ELEM * m_shape
Definition specctra.h:2924
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:42
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:417
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I GetPosition() const override
Definition footprint.h:403
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()
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition pcb_view.cpp:53
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition pcb_view.cpp:70
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
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
BOARD * GetBoard() const
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void OnModify() override
Must be called after a board change to set the modified flag.
bool ImportSpecctraSession(const wxString &aFullFilename)
Import a specctra *.ses file and use it to relocate MODULEs and to replace all vias and tracks in an ...
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
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
@ 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
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)
Helper method to import SES file to a board.
Class to handle a set of BOARD_ITEMs.
std::deque< PCB_TRACK * > TRACKS
#define UNDEFINED_DRILL_DIAMETER
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
DSN::T DSN_T
Definition specctra.h:50
const int scale
wxString From_UTF8(const char *cstring)
A point in the SPECCTRA DSN coordinate system.
Definition specctra.h:104
double y
Definition specctra.h:106
double x
Definition specctra.h:105
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
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:89
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683