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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25
26/* This source is a complement to specctra.cpp and implements the import of
27 a specctra session file (*.ses), and import of a specctra design file
28 (*.dsn) file. The specification for the grammar of the specctra dsn file
29 used to develop this code is given here:
30 http://tech.groups.yahoo.com/group/kicad-users/files/ then file "specctra.pdf"
31 Also see the comments at the top of the specctra.cpp file itself.
32*/
33
34#include "specctra.h"
35
36#include <confirm.h> // DisplayErrorMessage()
37#include <gestfich.h> // EDA_FileSelector()
38#include <fast_float/fast_float.h>
39#include <pcb_edit_frame.h>
40#include <locale_io.h>
41#include <macros.h>
42#include <board.h>
44#include <footprint.h>
45#include <pcb_group.h>
46#include <pcb_track.h>
48#include <view/view.h>
49#include <math/util.h> // for KiROUND
50#include <pcbnew_settings.h>
51#include <string_utils.h>
52
53using namespace DSN;
54
55bool PCB_EDIT_FRAME::ImportSpecctraSession( const wxString& fullFileName )
56{
57 // To avoid issues with undo/redo lists (dangling pointers) clear the lists
58 // todo: use undo/redo feature
60
61 if( GetCanvas() ) // clear view:
62 {
63 for( PCB_TRACK* track : GetBoard()->Tracks() )
64 GetCanvas()->GetView()->Remove( track );
65 }
66
67 try
68 {
69 DSN::ImportSpecctraSession( GetBoard(), fullFileName );
70 }
71 catch( const IO_ERROR& ioe )
72 {
73 wxString msg = _( "Board may be corrupted, do not save it.\n Fix problem and try again" );
74
75 wxString extra = ioe.What();
76
77 DisplayErrorMessage( this, msg, extra );
78 return false;
79 }
80
81 OnModify();
82
83 if( GetCanvas() ) // Update view:
84 {
85 // Update footprint positions
86
87 // add imported tracks (previous tracks are removed, therefore all are new)
88 for( PCB_TRACK* track : GetBoard()->Tracks() )
89 GetCanvas()->GetView()->Add( track );
90 }
91
92 SetStatusText( wxString( _( "Session file imported and merged OK." ) ) );
93
94 Refresh();
95
96 return true;
97}
98
99
100namespace DSN {
101
102
110static int scale( double distance, UNIT_RES* aResolution )
111{
112 double resValue = aResolution->GetValue();
113 double factor;
114
115 switch( aResolution->GetEngUnits() )
116 {
117 default:
118 case T_inch: factor = 25.4e6; break; // nanometers per inch
119 case T_mil: factor = 25.4e3; break; // nanometers per mil
120 case T_cm: factor = 1e7; break; // nanometers per cm
121 case T_mm: factor = 1e6; break; // nanometers per mm
122 case T_um: factor = 1e3; break; // nanometers per um
123 }
124
125 return KiROUND( factor * distance / resValue );
126}
127
128
137static VECTOR2I mapPt( const POINT& aPoint, UNIT_RES* aResolution )
138{
139 VECTOR2I ret( scale( aPoint.x, aResolution ),
140 -scale( aPoint.y, aResolution ) ); // negate y
141
142 return ret;
143}
144
145
146PCB_TRACK* SPECCTRA_DB::makeTRACK( WIRE* wire, PATH* aPath, int aPointIndex, int aNetcode )
147{
148 int layerNdx = findLayerName( aPath->layer_id );
149
150 if( layerNdx == -1 )
151 {
152 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'." ),
153 From_UTF8( aPath->layer_id.c_str() ) ) );
154 }
155
156 PCB_TRACK* track = new PCB_TRACK( m_sessionBoard );
157
158 track->SetStart( mapPt( aPath->points[aPointIndex + 0], m_routeResolution ) );
159 track->SetEnd( mapPt( aPath->points[aPointIndex + 1], m_routeResolution ) );
160 track->SetLayer( m_pcbLayer2kicad[layerNdx] );
161 track->SetWidth( scale( aPath->aperture_width, m_routeResolution ) );
162 track->SetNetCode( aNetcode );
163
164 // a track can be locked.
165 // However specctra as 4 types, none is exactly the same as our locked option
166 // wire->wire_type = T_fix, T_route, T_normal or T_protect
167 // fix and protect could be used as lock option
168 // but protect is returned for all tracks having initially the route or protect property
169 if( wire->m_wire_type == T_fix )
170 track->SetLocked( true );
171
172 return track;
173}
174
175
176PCB_ARC* SPECCTRA_DB::makeARC( WIRE* wire, QARC* aQarc, int aNetcode )
177{
178 int layerNdx = findLayerName( aQarc->layer_id );
179
180 if( layerNdx == -1 )
181 {
182 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'." ),
183 From_UTF8( aQarc->layer_id.c_str() ) ) );
184 }
185
186 PCB_ARC* arc = new PCB_ARC( m_sessionBoard );
187
188 arc->SetStart( mapPt( aQarc->vertex[0], m_routeResolution ) );
189 arc->SetEnd( mapPt( aQarc->vertex[1], m_routeResolution ) );
190 arc->SetMid( CalcArcMid(arc->GetStart(), arc->GetEnd(),
191 mapPt( aQarc->vertex[2], m_routeResolution ) ) );
192 arc->SetLayer( m_pcbLayer2kicad[layerNdx] );
194 arc->SetNetCode( aNetcode );
195
196 // a track can be locked.
197 // However specctra as 4 types, none is exactly the same as our locked option
198 // wire->wire_type = T_fix, T_route, T_normal or T_protect
199 // fix and protect could be used as lock option
200 // but protect is returned for all tracks having initially the route or protect property
201 if( wire->m_wire_type == T_fix )
202 arc->SetLocked( true );
203
204 return arc;
205}
206
207
208PCB_VIA* SPECCTRA_DB::makeVIA( WIRE_VIA* aVia, PADSTACK* aPadstack, const POINT& aPoint,
209 int aNetCode, int aViaDrillDefault )
210{
211 PCB_VIA* via = nullptr;
212 SHAPE* shape;
213 int shapeCount = aPadstack->Length();
214 int drill_diam_iu = -1;
215 int copperLayerCount = m_sessionBoard->GetCopperLayerCount();
216
217
218 // The drill diameter is encoded in the padstack name if Pcbnew did the DSN export.
219 // It is after the colon and before the last '_'
220 size_t drillStartNdx = aPadstack->m_padstack_id.find( ':' );
221
222 if( drillStartNdx != std::string::npos )
223 {
224 ++drillStartNdx; // skip over the ':'
225
226 size_t drillEndNdx = aPadstack->m_padstack_id.rfind( '_' );
227
228 if( drillEndNdx != std::string::npos )
229 {
230 std::string diam_txt( aPadstack->m_padstack_id, drillStartNdx,
231 drillEndNdx-drillStartNdx );
232
233 double drill_um{};
234 fast_float::from_chars( diam_txt.data(), diam_txt.data() + diam_txt.size(), drill_um,
235 fast_float::chars_format::skip_white_space );
236
237 drill_diam_iu = static_cast<int>( drill_um * ( pcbIUScale.IU_PER_MM / 1000.0 ) );
238
239 if( drill_diam_iu == aViaDrillDefault )
240 drill_diam_iu = UNDEFINED_DRILL_DIAMETER;
241 }
242 }
243
244 if( shapeCount == 0 )
245 {
246 THROW_IO_ERROR( _( "Session via padstack has no shapes" ) );
247 }
248 else if( shapeCount == 1 )
249 {
250 shape = static_cast<SHAPE*>( ( *aPadstack )[0] );
251 DSN_T type = shape->shape->Type();
252
253 if( type != T_circle )
254 {
255 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s." ),
256 GetTokenString( type ) ) );
257 }
258
259 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
260 int viaDiam = scale( circle->diameter, m_routeResolution );
261
262 via = new PCB_VIA( m_sessionBoard );
263 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
264 via->SetDrill( drill_diam_iu );
265 via->SetViaType( VIATYPE::THROUGH );
266 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
267 via->SetLayerPair( F_Cu, B_Cu );
268 }
269 else if( shapeCount == copperLayerCount )
270 {
271 shape = static_cast<SHAPE*>( ( *aPadstack )[0] );
272 DSN_T type = shape->shape->Type();
273
274 if( type != T_circle )
275 {
276 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s" ),
277 GetTokenString( type ) ) );
278 }
279
280 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
281 int viaDiam = scale( circle->diameter, m_routeResolution );
282
283 via = new PCB_VIA( m_sessionBoard );
284 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
285 via->SetDrill( drill_diam_iu );
286 via->SetViaType( VIATYPE::THROUGH );
287 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
288 via->SetLayerPair( F_Cu, B_Cu );
289 }
290 else // VIA_MICROVIA or VIA_BLIND_BURIED
291 {
292 int topLayerNdx = -1; // session layer detectors
293 int botLayerNdx = INT_MAX;
294
295 int viaDiam = -1;
296
297 for( int i = 0; i < shapeCount; ++i )
298 {
299 shape = static_cast<SHAPE*>( ( *aPadstack )[i] );
300 DSN_T type = shape->shape->Type();
301
302 if( type != T_circle )
303 {
304 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s" ),
305 GetTokenString( type ) ) );
306 }
307
308 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
309
310 int layerNdx = findLayerName( circle->layer_id );
311
312 if( layerNdx == -1 )
313 {
314 wxString layerName = From_UTF8( circle->layer_id.c_str() );
315 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'" ),
316 layerName ) );
317 }
318
319 if( layerNdx > topLayerNdx )
320 topLayerNdx = layerNdx;
321
322 if( layerNdx < botLayerNdx )
323 botLayerNdx = layerNdx;
324
325 if( viaDiam == -1 )
326 viaDiam = scale( circle->diameter, m_routeResolution );
327 }
328
329 via = new PCB_VIA( m_sessionBoard );
330 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
331 via->SetDrill( drill_diam_iu );
332
333 if( ( topLayerNdx == 0 && botLayerNdx == 1 )
334 || ( topLayerNdx == copperLayerCount - 2 && botLayerNdx == copperLayerCount - 1 ) )
335 {
336 via->SetViaType( VIATYPE::MICROVIA );
337 }
338 else
339 {
340 via->SetViaType( VIATYPE::BLIND_BURIED );
341 }
342
343 wxCHECK2( topLayerNdx >= 0, topLayerNdx = 0 );
344
345 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
346 via->SetLayerPair( m_pcbLayer2kicad[ topLayerNdx ], m_pcbLayer2kicad[ botLayerNdx ] );
347 }
348
349 wxASSERT( via );
350
351 via->SetNetCode( aNetCode );
352
353 // a via can be locked.
354 // However specctra as 4 types, none is exactly the same as our locked option
355 // aVia->via_type = T_fix, T_route, T_normal or T_protect
356 // fix and protect could be used as lock option
357 // but protect is returned for all tracks having initially the route or protect property
358 if( aVia->m_via_type == T_fix )
359 via->SetLocked( true );
360
361 return via;
362}
363
364
365// no UI code in this function, throw exception to report problems to the
366// UI handler: void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
367
369{
370 m_sessionBoard = aBoard; // not owned here
371
372 if( !m_session )
373 THROW_IO_ERROR( _("Session file is missing the \"session\" section") );
374
375 if( !m_session->route )
376 THROW_IO_ERROR( _("Session file is missing the \"routes\" section") );
377
378 if( !m_session->route->library )
379 THROW_IO_ERROR( _("Session file is missing the \"library_out\" section") );
380
381 // delete the old tracks and vias but save locked tracks/vias; they will be re-added later
382 std::vector<PCB_TRACK*> locked;
383 TRACKS tracks = aBoard->Tracks();
384 aBoard->RemoveAll( { PCB_TRACE_T } );
385
386 for( PCB_TRACK* track : tracks )
387 {
388 if( track->IsLocked() )
389 {
390 locked.push_back( track );
391 }
392 else
393 {
394 if( EDA_GROUP* group = track->GetParentGroup() )
395 group->RemoveItem( track );
396
397 delete track;
398 }
399 }
400
401 aBoard->DeleteMARKERs();
402
403 buildLayerMaps( aBoard );
404
405 // Add locked tracks: because they are exported as Fix tracks, they are not
406 // in .ses file.
407 for( PCB_TRACK* track : locked )
408 aBoard->Add( track );
409
410 if( m_session->placement )
411 {
412 // Walk the PLACEMENT object's COMPONENTs list, and for each PLACE within
413 // each COMPONENT, reposition and re-orient each component and put on
414 // correct side of the board.
415 COMPONENTS& components = m_session->placement->m_components;
416
417 for( COMPONENTS::iterator comp = components.begin(); comp != components.end(); ++comp )
418 {
419 PLACES& places = comp->m_places;
420
421 for( unsigned i = 0; i < places.size(); ++i )
422 {
423 PLACE* place = &places[i]; // '&' even though places[] holds a pointer!
424
425 wxString reference = From_UTF8( place->m_component_id.c_str() );
426 FOOTPRINT* footprint = aBoard->FindFootprintByReference( reference );
427
428 if( !footprint )
429 {
430 THROW_IO_ERROR( wxString::Format( _( "Reference '%s' not found." ),
431 reference ) );
432 }
433
434 if( !place->m_hasVertex )
435 continue;
436
437 UNIT_RES* resolution = place->GetUnits();
438 wxASSERT( resolution );
439
440 VECTOR2I newPos = mapPt( place->m_vertex, resolution );
441 footprint->SetPosition( newPos );
442
443 if( place->m_side == T_front )
444 {
445 // convert from degrees to tenths of degrees used in KiCad.
446 EDA_ANGLE orientation( place->m_rotation, DEGREES_T );
447
448 if( footprint->GetLayer() != F_Cu )
449 {
450 // footprint is on copper layer (back)
451 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
452 }
453
454 footprint->SetOrientation( orientation );
455 }
456 else if( place->m_side == T_back )
457 {
458 EDA_ANGLE orientation( place->m_rotation + 180.0, DEGREES_T );
459
460 if( footprint->GetLayer() != B_Cu )
461 {
462 // footprint is on component layer (front)
463 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
464 }
465
466 footprint->SetOrientation( orientation );
467 }
468 else
469 {
470 // as I write this, the PARSER *is* catching this, so we should never see below:
471 wxFAIL_MSG( wxT("DSN::PARSER did not catch an illegal side := 'back|front'") );
472 }
473 }
474 }
475 }
476
477 m_routeResolution = m_session->route->GetUnits();
478
479 // Walk the NET_OUTs and create tracks and vias anew.
480 NET_OUTS& net_outs = m_session->route->net_outs;
481
482 for( NET_OUTS::iterator net = net_outs.begin(); net!=net_outs.end(); ++net )
483 {
484 int netoutCode = 0;
485
486 // page 143 of spec says wire's net_id is optional
487 if( net->net_id.size() )
488 {
489 wxString netName = From_UTF8( net->net_id.c_str() );
490 NETINFO_ITEM* netinfo = aBoard->FindNet( netName );
491
492 if( netinfo )
493 netoutCode = netinfo->GetNetCode();
494 }
495
496 WIRES& wires = net->wires;
497
498 for( unsigned i = 0; i<wires.size(); ++i )
499 {
500 WIRE* wire = &wires[i];
501 DSN_T shape = wire->m_shape->Type();
502
503 if( shape == T_path )
504 {
505 PATH* path = static_cast<PATH*>( wire->m_shape );
506
507 for( unsigned pt = 0; pt < path->points.size() - 1; ++pt )
508 {
509 PCB_TRACK* track;
510 track = makeTRACK( wire, path, pt, netoutCode );
511 aBoard->Add( track );
512 }
513 }
514 else if ( shape == T_qarc )
515 {
516 QARC* qarc = static_cast<QARC*>( wire->m_shape );
517
518 PCB_ARC* arc = makeARC( wire, qarc, netoutCode );
519 aBoard->Add( arc );
520 }
521 else
522 {
523 /*
524 * shape == T_polygon is expected from freerouter if you have a zone on a non-
525 * "power" type layer, i.e. a T_signal layer and the design does a round-trip
526 * back in as session here. We kept our own zones in the BOARD, so ignore this
527 * so called 'wire'.
528
529 wxString netId = From_UTF8( wire->net_id.c_str() );
530 THROW_IO_ERROR( wxString::Format( _( "Unsupported wire shape: '%s' for net: '%s'" ),
531 DLEX::GetTokenString(shape).GetData(),
532 netId.GetData() ) );
533 */
534 }
535 }
536
537 WIRE_VIAS& wire_vias = net->wire_vias;
538 LIBRARY& library = *m_session->route->library;
539
540 for( unsigned i = 0; i < wire_vias.size(); ++i )
541 {
542 int netCode = 0;
543
544 // page 144 of spec says wire_via's net_id is optional
545 if( net->net_id.size() )
546 {
547 wxString netName = From_UTF8( net->net_id.c_str() );
548 NETINFO_ITEM* netvia = aBoard->FindNet( netName );
549
550 if( netvia )
551 netCode = netvia->GetNetCode();
552 }
553
554 WIRE_VIA* wire_via = &wire_vias[i];
555
556 // example: (via Via_15:8_mil 149000 -71000 )
557
558 PADSTACK* padstack = 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 PCB_VIA* via = makeVIA( wire_via, padstack, wire_via->m_vertexes[v], netCode,
581 via_drill_default );
582 aBoard->Add( via );
583 }
584 }
585 }
586}
587
588
589bool ImportSpecctraSession( BOARD* aBoard, const wxString& fullFileName )
590{
591 SPECCTRA_DB db;
592 LOCALE_IO toggle;
593
594 db.LoadSESSION( fullFileName );
595 db.FromSESSION( aBoard );
596
597 aBoard->GetConnectivity()->ClearRatsnest();
598 aBoard->BuildConnectivity();
599
600 return true;
601}
602} // namespace DSN
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:990
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
std::shared_ptr< NET_SETTINGS > m_NetSettings
void SetLocked(bool aLocked) override
Definition board_item.h:323
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:280
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:317
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1163
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition board.cpp:2152
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:188
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:1443
const TRACKS & Tracks() const
Definition board.h:356
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition board.cpp:2236
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1040
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition board.cpp:1560
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:521
void ClearRatsnest()
Function Clear() Erases the connectivity database.
int Length() const
Return the number of ELEMs in this holder.
Definition specctra.h:322
virtual UNIT_RES * GetUnits() const
Return the units for this section.
DSN_T Type() const
Definition specctra.h:215
A <library_descriptor> in the specctra dsn specification.
Definition specctra.h:2257
Hold either a via or a pad definition.
Definition specctra.h:2126
std::string m_padstack_id
Definition specctra.h:2225
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
Definition specctra.h:588
POINTS points
Definition specctra.h:658
double aperture_width
Definition specctra.h:656
std::string layer_id
Definition specctra.h:655
Implement a <placement_reference> in the specctra dsn spec.
Definition specctra.h:1693
bool m_hasVertex
Definition specctra.h:1744
POINT m_vertex
Definition specctra.h:1745
DSN_T m_side
Definition specctra.h:1740
double m_rotation
Definition specctra.h:1742
std::string m_component_id
reference designator
Definition specctra.h:1738
std::string layer_id
Definition specctra.h:842
double aperture_width
Definition specctra.h:843
POINT vertex[3]
Definition specctra.h:844
A "(shape ..)" element in the specctra dsn spec.
Definition specctra.h:1899
A DSN data tree, usually coming from a DSN file.
Definition specctra.h:3651
void buildLayerMaps(BOARD *aBoard)
Create a few data translation structures for layer name and number mapping between the DSN::PCB struc...
Definition specctra.cpp:77
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:4000
UNIT_RES * m_routeResolution
used during FromSESSION() only, memory for it is not owned here.
Definition specctra.h:4003
BOARD * m_sessionBoard
a copy to avoid passing as an argument, memory for it is not owned here.
Definition specctra.h:4006
SESSION * m_session
Definition specctra.h:3989
void LoadSESSION(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "session" file.
Definition specctra.cpp:269
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:100
A holder for either a T_unit or T_resolution object which are usually mutually exclusive in the dsn g...
Definition specctra.h:408
DSN_T GetEngUnits() const
Definition specctra.h:424
int GetValue() const
Definition specctra.h:425
ELEM * shape
Definition specctra.h:898
A <wire_via_descriptor> in the specctra dsn spec.
Definition specctra.h:2993
DSN_T m_via_type
Definition specctra.h:3126
const std::string & GetPadstackId()
Definition specctra.h:3004
POINTS m_vertexes
Definition specctra.h:3123
A <wire_shape_descriptor> in the specctra dsn spec.
Definition specctra.h:2884
DSN_T m_wire_type
Definition specctra.h:2978
ELEM * m_shape
Definition specctra.h:2974
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:46
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:257
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I GetPosition() const override
Definition footprint.h:245
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:57
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition pcb_view.cpp:74
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:41
Handle the data for a net.
Definition netinfo.h:54
int GetNetCode() const
Definition netinfo.h:106
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:145
void SetMid(const VECTOR2I &aMid)
Definition pcb_track.h:344
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:148
void SetStart(const VECTOR2I &aStart)
Definition pcb_track.h:151
const VECTOR2I & GetStart() const
Definition pcb_track.h:152
const VECTOR2I & GetEnd() const
Definition pcb_track.h:149
virtual void SetWidth(int aWidth)
Definition pcb_track.h:145
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:194
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:65
@ F_Cu
Definition layer_ids.h:64
This file contains miscellaneous commonly used macros and functions.
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:29
This source file implements export and import capabilities to the specctra dsn file format.
Definition specctra.cpp:64
boost::ptr_vector< NET_OUT > NET_OUTS
Definition specctra.h:3454
static POINT mapPt(const VECTOR2I &pt)
Convert a KiCad point into a DSN file point.
boost::ptr_vector< WIRE > WIRES
Definition specctra.h:2986
static double scale(int kicadDist)
Convert a distance from Pcbnew internal units to the reported Specctra DSN units in floating point fo...
boost::ptr_vector< PLACE > PLACES
Definition specctra.h:1766
boost::ptr_vector< WIRE_VIA > WIRE_VIAS
Definition specctra.h:3133
boost::ptr_vector< COMPONENT > COMPONENTS
Definition specctra.h:1817
bool ImportSpecctraSession(BOARD *aBoard, const wxString &fullFileName)
Helper method to import SES file to a board.
Class to handle a set of BOARD_ITEMs.
@ THROUGH
Definition pcb_track.h:67
@ BLIND_BURIED
Definition pcb_track.h:68
@ MICROVIA
Definition pcb_track.h:69
#define UNDEFINED_DRILL_DIAMETER
Definition pcb_track.h:109
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
DSN::T DSN_T
Definition specctra.h:54
const int scale
wxString From_UTF8(const char *cstring)
A point in the SPECCTRA DSN coordinate system.
Definition specctra.h:108
double y
Definition specctra.h:110
double x
Definition specctra.h:109
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:209
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:96
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695