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
35#include <confirm.h> // DisplayErrorMessage()
36#include <gestfich.h> // EDA_FileSelector()
37#include <pcb_edit_frame.h>
38#include <locale_io.h>
39#include <macros.h>
40#include <board.h>
42#include <footprint.h>
43#include <pcb_group.h>
44#include <pcb_track.h>
46#include <view/view.h>
47#include "specctra.h"
48#include <math/util.h> // for KiROUND
49#include <pcbnew_settings.h>
50
51using namespace DSN;
52
53bool PCB_EDIT_FRAME::ImportSpecctraSession( const wxString& fullFileName )
54{
55 // To avoid issues with undo/redo lists (dangling pointers) clear the lists
56 // todo: use undo/redo feature
58
59 if( GetCanvas() ) // clear view:
60 {
61 for( PCB_TRACK* track : GetBoard()->Tracks() )
62 GetCanvas()->GetView()->Remove( track );
63 }
64
65 try
66 {
67 DSN::ImportSpecctraSession( GetBoard(), fullFileName );
68 }
69 catch( const IO_ERROR& ioe )
70 {
71 wxString msg = _( "Board may be corrupted, do not save it.\n Fix problem and try again" );
72
73 wxString extra = ioe.What();
74
75 DisplayErrorMessage( this, msg, extra );
76 return false;
77 }
78
79 OnModify();
80
81 if( GetCanvas() ) // Update view:
82 {
83 // Update footprint positions
84
85 // add imported tracks (previous tracks are removed, therefore all are new)
86 for( PCB_TRACK* track : GetBoard()->Tracks() )
87 GetCanvas()->GetView()->Add( track );
88 }
89
90 SetStatusText( wxString( _( "Session file imported and merged OK." ) ) );
91
92 Refresh();
93
94 return true;
95}
96
97
98namespace DSN {
99
100
108static int scale( double distance, UNIT_RES* aResolution )
109{
110 double resValue = aResolution->GetValue();
111 double factor;
112
113 switch( aResolution->GetEngUnits() )
114 {
115 default:
116 case T_inch: factor = 25.4e6; break; // nanometers per inch
117 case T_mil: factor = 25.4e3; break; // nanometers per mil
118 case T_cm: factor = 1e7; break; // nanometers per cm
119 case T_mm: factor = 1e6; break; // nanometers per mm
120 case T_um: factor = 1e3; break; // nanometers per um
121 }
122
123 return KiROUND( factor * distance / resValue );
124}
125
126
135static VECTOR2I mapPt( const POINT& aPoint, UNIT_RES* aResolution )
136{
137 VECTOR2I ret( scale( aPoint.x, aResolution ),
138 -scale( aPoint.y, aResolution ) ); // negate y
139
140 return ret;
141}
142
143
144PCB_TRACK* SPECCTRA_DB::makeTRACK( WIRE* wire, PATH* aPath, int aPointIndex, int aNetcode )
145{
146 int layerNdx = findLayerName( aPath->layer_id );
147
148 if( layerNdx == -1 )
149 {
150 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'." ),
151 From_UTF8( aPath->layer_id.c_str() ) ) );
152 }
153
154 PCB_TRACK* track = new PCB_TRACK( m_sessionBoard );
155
156 track->SetStart( mapPt( aPath->points[aPointIndex + 0], m_routeResolution ) );
157 track->SetEnd( mapPt( aPath->points[aPointIndex + 1], m_routeResolution ) );
158 track->SetLayer( m_pcbLayer2kicad[layerNdx] );
159 track->SetWidth( scale( aPath->aperture_width, m_routeResolution ) );
160 track->SetNetCode( aNetcode );
161
162 // a track can be locked.
163 // However specctra as 4 types, none is exactly the same as our locked option
164 // wire->wire_type = T_fix, T_route, T_normal or T_protect
165 // fix and protect could be used as lock option
166 // but protect is returned for all tracks having initially the route or protect property
167 if( wire->m_wire_type == T_fix )
168 track->SetLocked( true );
169
170 return track;
171}
172
173
174PCB_ARC* SPECCTRA_DB::makeARC( WIRE* wire, QARC* aQarc, int aNetcode )
175{
176 int layerNdx = findLayerName( aQarc->layer_id );
177
178 if( layerNdx == -1 )
179 {
180 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'." ),
181 From_UTF8( aQarc->layer_id.c_str() ) ) );
182 }
183
184 PCB_ARC* arc = new PCB_ARC( m_sessionBoard );
185
186 arc->SetStart( mapPt( aQarc->vertex[0], m_routeResolution ) );
187 arc->SetEnd( mapPt( aQarc->vertex[1], m_routeResolution ) );
188 arc->SetMid( CalcArcMid(arc->GetStart(), arc->GetEnd(),
189 mapPt( aQarc->vertex[2], m_routeResolution ) ) );
190 arc->SetLayer( m_pcbLayer2kicad[layerNdx] );
192 arc->SetNetCode( aNetcode );
193
194 // a track can be locked.
195 // However specctra as 4 types, none is exactly the same as our locked option
196 // wire->wire_type = T_fix, T_route, T_normal or T_protect
197 // fix and protect could be used as lock option
198 // but protect is returned for all tracks having initially the route or protect property
199 if( wire->m_wire_type == T_fix )
200 arc->SetLocked( true );
201
202 return arc;
203}
204
205
206PCB_VIA* SPECCTRA_DB::makeVIA( WIRE_VIA* aVia, PADSTACK* aPadstack, const POINT& aPoint,
207 int aNetCode, int aViaDrillDefault )
208{
209 PCB_VIA* via = nullptr;
210 SHAPE* shape;
211 int shapeCount = aPadstack->Length();
212 int drill_diam_iu = -1;
213 int copperLayerCount = m_sessionBoard->GetCopperLayerCount();
214
215
216 // The drill diameter is encoded in the padstack name if Pcbnew did the DSN export.
217 // It is after the colon and before the last '_'
218 size_t drillStartNdx = aPadstack->m_padstack_id.find( ':' );
219
220 if( drillStartNdx != std::string::npos )
221 {
222 ++drillStartNdx; // skip over the ':'
223
224 size_t drillEndNdx = aPadstack->m_padstack_id.rfind( '_' );
225
226 if( drillEndNdx != std::string::npos )
227 {
228 std::string diam_txt( aPadstack->m_padstack_id, drillStartNdx,
229 drillEndNdx-drillStartNdx );
230
231 double drill_um = strtod( diam_txt.c_str(), nullptr );
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 {
251 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s." ),
252 GetTokenString( type ) ) );
253 }
254
255 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
256 int viaDiam = scale( circle->diameter, m_routeResolution );
257
258 via = new PCB_VIA( m_sessionBoard );
259 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
260 via->SetDrill( drill_diam_iu );
261 via->SetViaType( VIATYPE::THROUGH );
262 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
263 via->SetLayerPair( F_Cu, B_Cu );
264 }
265 else if( shapeCount == copperLayerCount )
266 {
267 shape = static_cast<SHAPE*>( ( *aPadstack )[0] );
268 DSN_T type = shape->shape->Type();
269
270 if( type != T_circle )
271 {
272 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s" ),
273 GetTokenString( type ) ) );
274 }
275
276 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
277 int viaDiam = scale( circle->diameter, m_routeResolution );
278
279 via = new PCB_VIA( m_sessionBoard );
280 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
281 via->SetDrill( drill_diam_iu );
282 via->SetViaType( VIATYPE::THROUGH );
283 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
284 via->SetLayerPair( F_Cu, B_Cu );
285 }
286 else // VIA_MICROVIA or VIA_BLIND_BURIED
287 {
288 int topLayerNdx = -1; // session layer detectors
289 int botLayerNdx = INT_MAX;
290
291 int viaDiam = -1;
292
293 for( int i = 0; i < shapeCount; ++i )
294 {
295 shape = static_cast<SHAPE*>( ( *aPadstack )[i] );
296 DSN_T type = shape->shape->Type();
297
298 if( type != T_circle )
299 {
300 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s" ),
301 GetTokenString( type ) ) );
302 }
303
304 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
305
306 int layerNdx = findLayerName( circle->layer_id );
307
308 if( layerNdx == -1 )
309 {
310 wxString layerName = From_UTF8( circle->layer_id.c_str() );
311 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'" ),
312 layerName ) );
313 }
314
315 if( layerNdx > topLayerNdx )
316 topLayerNdx = layerNdx;
317
318 if( layerNdx < botLayerNdx )
319 botLayerNdx = layerNdx;
320
321 if( viaDiam == -1 )
322 viaDiam = scale( circle->diameter, m_routeResolution );
323 }
324
325 via = new PCB_VIA( m_sessionBoard );
326 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
327 via->SetDrill( drill_diam_iu );
328
329 if( ( topLayerNdx == 0 && botLayerNdx == 1 )
330 || ( topLayerNdx == copperLayerCount - 2 && botLayerNdx == copperLayerCount - 1 ) )
331 {
332 via->SetViaType( VIATYPE::MICROVIA );
333 }
334 else
335 {
336 via->SetViaType( VIATYPE::BLIND_BURIED );
337 }
338
339 wxCHECK2( topLayerNdx >= 0, topLayerNdx = 0 );
340
341 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
342 via->SetLayerPair( m_pcbLayer2kicad[ topLayerNdx ], m_pcbLayer2kicad[ botLayerNdx ] );
343 }
344
345 wxASSERT( via );
346
347 via->SetNetCode( aNetCode );
348
349 // a via can be locked.
350 // However specctra as 4 types, none is exactly the same as our locked option
351 // aVia->via_type = T_fix, T_route, T_normal or T_protect
352 // fix and protect could be used as lock option
353 // but protect is returned for all tracks having initially the route or protect property
354 if( aVia->m_via_type == T_fix )
355 via->SetLocked( true );
356
357 return via;
358}
359
360
361// no UI code in this function, throw exception to report problems to the
362// UI handler: void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
363
365{
366 m_sessionBoard = aBoard; // not owned here
367
368 if( !m_session )
369 THROW_IO_ERROR( _("Session file is missing the \"session\" section") );
370
371 if( !m_session->route )
372 THROW_IO_ERROR( _("Session file is missing the \"routes\" section") );
373
374 if( !m_session->route->library )
375 THROW_IO_ERROR( _("Session file is missing the \"library_out\" section") );
376
377 // delete the old tracks and vias but save locked tracks/vias; they will be re-added later
378 std::vector<PCB_TRACK*> locked;
379 TRACKS tracks = aBoard->Tracks();
380 aBoard->RemoveAll( { PCB_TRACE_T } );
381
382 for( PCB_TRACK* track : tracks )
383 {
384 if( track->IsLocked() )
385 {
386 locked.push_back( track );
387 }
388 else
389 {
390 if( PCB_GROUP* group = track->GetParentGroup() )
391 group->RemoveItem( track );
392
393 delete track;
394 }
395 }
396
397 aBoard->DeleteMARKERs();
398
399 buildLayerMaps( aBoard );
400
401 // Add locked tracks: because they are exported as Fix tracks, they are not
402 // in .ses file.
403 for( PCB_TRACK* track : locked )
404 aBoard->Add( track );
405
406 if( m_session->placement )
407 {
408 // Walk the PLACEMENT object's COMPONENTs list, and for each PLACE within
409 // each COMPONENT, reposition and re-orient each component and put on
410 // correct side of the board.
412
413 for( COMPONENTS::iterator comp = components.begin(); comp != components.end(); ++comp )
414 {
415 PLACES& places = comp->m_places;
416
417 for( unsigned i = 0; i < places.size(); ++i )
418 {
419 PLACE* place = &places[i]; // '&' even though places[] holds a pointer!
420
421 wxString reference = From_UTF8( place->m_component_id.c_str() );
422 FOOTPRINT* footprint = aBoard->FindFootprintByReference( reference );
423
424 if( !footprint )
425 {
426 THROW_IO_ERROR( wxString::Format( _( "Reference '%s' not found." ),
427 reference ) );
428 }
429
430 if( !place->m_hasVertex )
431 continue;
432
433 UNIT_RES* resolution = place->GetUnits();
434 wxASSERT( resolution );
435
436 VECTOR2I newPos = mapPt( place->m_vertex, resolution );
437 footprint->SetPosition( newPos );
438
439 if( place->m_side == T_front )
440 {
441 // convert from degrees to tenths of degrees used in KiCad.
442 EDA_ANGLE orientation( place->m_rotation, DEGREES_T );
443
444 if( footprint->GetLayer() != F_Cu )
445 {
446 // footprint is on copper layer (back)
447 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
448 }
449
450 footprint->SetOrientation( orientation );
451 }
452 else if( place->m_side == T_back )
453 {
454 EDA_ANGLE orientation( place->m_rotation + 180.0, DEGREES_T );
455
456 if( footprint->GetLayer() != B_Cu )
457 {
458 // footprint is on component layer (front)
459 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
460 }
461
462 footprint->SetOrientation( orientation );
463 }
464 else
465 {
466 // as I write this, the PARSER *is* catching this, so we should never see below:
467 wxFAIL_MSG( wxT("DSN::PARSER did not catch an illegal side := 'back|front'") );
468 }
469 }
470 }
471 }
472
474
475 // Walk the NET_OUTs and create tracks and vias anew.
476 NET_OUTS& net_outs = m_session->route->net_outs;
477
478 for( NET_OUTS::iterator net = net_outs.begin(); net!=net_outs.end(); ++net )
479 {
480 int netoutCode = 0;
481
482 // page 143 of spec says wire's net_id is optional
483 if( net->net_id.size() )
484 {
485 wxString netName = From_UTF8( net->net_id.c_str() );
486 NETINFO_ITEM* netinfo = aBoard->FindNet( netName );
487
488 if( netinfo )
489 netoutCode = netinfo->GetNetCode();
490 }
491
492 WIRES& wires = net->wires;
493
494 for( unsigned i = 0; i<wires.size(); ++i )
495 {
496 WIRE* wire = &wires[i];
497 DSN_T shape = wire->m_shape->Type();
498
499 if( shape == T_path )
500 {
501 PATH* path = static_cast<PATH*>( wire->m_shape );
502
503 for( unsigned pt = 0; pt < path->points.size() - 1; ++pt )
504 {
505 PCB_TRACK* track;
506 track = makeTRACK( wire, path, pt, netoutCode );
507 aBoard->Add( track );
508 }
509 }
510 else if ( shape == T_qarc )
511 {
512 QARC* qarc = static_cast<QARC*>( wire->m_shape );
513
514 PCB_ARC* arc = makeARC( wire, qarc, netoutCode );
515 aBoard->Add( arc );
516 }
517 else
518 {
519 /*
520 * shape == T_polygon is expected from freerouter if you have a zone on a non-
521 * "power" type layer, i.e. a T_signal layer and the design does a round-trip
522 * back in as session here. We kept our own zones in the BOARD, so ignore this
523 * so called 'wire'.
524
525 wxString netId = From_UTF8( wire->net_id.c_str() );
526 THROW_IO_ERROR( wxString::Format( _( "Unsupported wire shape: '%s' for net: '%s'" ),
527 DLEX::GetTokenString(shape).GetData(),
528 netId.GetData() ) );
529 */
530 }
531 }
532
533 WIRE_VIAS& wire_vias = net->wire_vias;
535
536 for( unsigned i = 0; i < wire_vias.size(); ++i )
537 {
538 int netCode = 0;
539
540 // page 144 of spec says wire_via's net_id is optional
541 if( net->net_id.size() )
542 {
543 wxString netName = From_UTF8( net->net_id.c_str() );
544 NETINFO_ITEM* netvia = aBoard->FindNet( netName );
545
546 if( netvia )
547 netCode = netvia->GetNetCode();
548 }
549
550 WIRE_VIA* wire_via = &wire_vias[i];
551
552 // example: (via Via_15:8_mil 149000 -71000 )
553
554 PADSTACK* padstack = library.FindPADSTACK( wire_via->GetPadstackId() );
555
556 if( !padstack )
557 {
558 // Dick Feb 29, 2008:
559 // Freerouter has a bug where it will not round trip all vias. Vias which have
560 // a (use_via) element will be round tripped. Vias which do not, don't come back
561 // in in the session library, even though they may be actually used in the
562 // pre-routed, protected wire_vias. So until that is fixed, create the padstack
563 // from its name as a work around.
564 wxString psid( From_UTF8( wire_via->GetPadstackId().c_str() ) );
565
566 THROW_IO_ERROR( wxString::Format( _( "A wire_via refers to missing padstack '%s'." ),
567 psid ) );
568 }
569
570 std::shared_ptr<NET_SETTINGS>& netSettings = aBoard->GetDesignSettings().m_NetSettings;
571
572 int via_drill_default = netSettings->GetDefaultNetclass()->GetViaDrill();
573
574 for( unsigned v = 0; v < wire_via->m_vertexes.size(); ++v )
575 {
576 PCB_VIA* via = makeVIA( wire_via, padstack, wire_via->m_vertexes[v], netCode,
577 via_drill_default );
578 aBoard->Add( via );
579 }
580 }
581 }
582}
583
584
585bool ImportSpecctraSession( BOARD* aBoard, const wxString& fullFileName )
586{
587 SPECCTRA_DB db;
588 LOCALE_IO toggle;
589
590 db.LoadSESSION( fullFileName );
591 db.FromSESSION( aBoard );
592
593 aBoard->GetConnectivity()->ClearRatsnest();
594 aBoard->BuildConnectivity();
595
596 return true;
597}
598} // namespace DSN
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
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
virtual void SetLocked(bool aLocked)
Definition: board_item.h:330
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:290
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:295
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:1045
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1964
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:190
int GetCopperLayerCount() const
Definition: board.cpp:783
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:1290
const TRACKS & Tracks() const
Definition: board.h:334
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition: board.cpp:2050
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:937
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition: board.cpp:1403
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:483
std::string layer_id
Definition: specctra.h:775
double diameter
Definition: specctra.h:777
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.
Definition: specctra.cpp:3772
DSN_T Type() const
Definition: specctra.h:210
A <library_descriptor> in the specctra dsn specification.
Definition: specctra.h:2252
Hold either a via or a pad definition.
Definition: specctra.h:2121
std::string m_padstack_id
Definition: specctra.h:2220
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
Definition: specctra.h:583
POINTS points
Definition: specctra.h:653
double aperture_width
Definition: specctra.h:651
std::string layer_id
Definition: specctra.h:650
COMPONENTS m_components
Definition: specctra.h:1882
Implement a <placement_reference> in the specctra dsn spec.
Definition: specctra.h:1688
bool m_hasVertex
Definition: specctra.h:1739
POINT m_vertex
Definition: specctra.h:1740
DSN_T m_side
Definition: specctra.h:1735
double m_rotation
Definition: specctra.h:1737
std::string m_component_id
reference designator
Definition: specctra.h:1733
std::string layer_id
Definition: specctra.h:837
double aperture_width
Definition: specctra.h:838
POINT vertex[3]
Definition: specctra.h:839
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition: specctra.h:3473
NET_OUTS net_outs
Definition: specctra.h:3516
LIBRARY * library
Definition: specctra.h:3515
PLACEMENT * placement
Definition: specctra.h:3628
ROUTE * route
Definition: specctra.h:3630
A "(shape ..)" element in the specctra dsn spec.
Definition: specctra.h:1894
A DSN data tree, usually coming from a DSN file.
Definition: specctra.h:3646
void buildLayerMaps(BOARD *aBoard)
Create a few data translation structures for layer name and number mapping between the DSN::PCB struc...
Definition: specctra.cpp:76
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:3995
UNIT_RES * m_routeResolution
used during FromSESSION() only, memory for it is not owned here.
Definition: specctra.h:3998
BOARD * m_sessionBoard
a copy to avoid passing as an argument, memory for it is not owned here.
Definition: specctra.h:4001
SESSION * m_session
Definition: specctra.h:3984
void LoadSESSION(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "session" file.
Definition: specctra.cpp:268
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:99
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:893
A <wire_via_descriptor> in the specctra dsn spec.
Definition: specctra.h:2988
DSN_T m_via_type
Definition: specctra.h:3121
const std::string & GetPadstackId()
Definition: specctra.h:2999
POINTS m_vertexes
Definition: specctra.h:3118
A <wire_shape_descriptor> in the specctra dsn spec.
Definition: specctra.h:2879
DSN_T m_wire_type
Definition: specctra.h:2973
ELEM * m_shape
Definition: specctra.h:2969
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:2439
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2527
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: footprint.h:234
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: footprint.cpp:2377
VECTOR2I GetPosition() const override
Definition: footprint.h:222
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
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:49
Handle the data for a net.
Definition: netinfo.h:56
int GetNetCode() const
Definition: netinfo.h:108
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition: padstack.h:144
void SetMid(const VECTOR2I &aMid)
Definition: pcb_track.h:304
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 ...
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:52
void SetEnd(const VECTOR2I &aEnd)
Definition: pcb_track.h:118
void SetStart(const VECTOR2I &aStart)
Definition: pcb_track.h:121
const VECTOR2I & GetStart() const
Definition: pcb_track.h:122
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:119
virtual void SetWidth(int aWidth)
Definition: pcb_track.h:115
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:195
This file is part of the common library.
#define _(s)
@ DEGREES_T
Definition: eda_angle.h:31
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:39
@ B_Cu
Definition: layer_ids.h:65
@ F_Cu
Definition: layer_ids.h:64
This file contains miscellaneous commonly used macros and functions.
This source file implements export and import capabilities to the specctra dsn file format.
Definition: specctra.cpp:63
boost::ptr_vector< NET_OUT > NET_OUTS
Definition: specctra.h:3449
static POINT mapPt(const VECTOR2I &pt)
Convert a KiCad point into a DSN file point.
boost::ptr_vector< WIRE > WIRES
Definition: specctra.h:2981
boost::ptr_vector< PLACE > PLACES
Definition: specctra.h:1761
boost::ptr_vector< WIRE_VIA > WIRE_VIAS
Definition: specctra.h:3128
boost::ptr_vector< COMPONENT > COMPONENTS
Definition: specctra.h:1812
bool ImportSpecctraSession(BOARD *aBoard, const wxString &fullFileName)
Helper method to import SES file to a board.
Class to handle a set of BOARD_ITEMs.
#define UNDEFINED_DRILL_DIAMETER
Definition: pcb_track.h:81
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:49
const int scale
wxString From_UTF8(const char *cstring)
A point in the SPECCTRA DSN coordinate system.
Definition: specctra.h:103
double y
Definition: specctra.h:105
double x
Definition: specctra.h:104
const double IU_PER_MM
Definition: base_units.h:76
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