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
49using namespace DSN;
50
51bool PCB_EDIT_FRAME::ImportSpecctraSession( const wxString& fullFileName )
52{
53 // To avoid issues with undo/redo lists (dangling pointers) clear the lists
54 // todo: use undo/redo feature
56
57 if( GetCanvas() ) // clear view:
58 {
59 for( PCB_TRACK* track : GetBoard()->Tracks() )
60 GetCanvas()->GetView()->Remove( track );
61 }
62
63 try
64 {
65 DSN::ImportSpecctraSession( GetBoard(), fullFileName );
66 }
67 catch( const IO_ERROR& ioe )
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 OnModify();
78
79 if( GetCanvas() ) // Update view:
80 {
81 // Update footprint positions
82
83 // add imported tracks (previous tracks are removed, therefore all are new)
84 for( PCB_TRACK* track : GetBoard()->Tracks() )
85 GetCanvas()->GetView()->Add( track );
86 }
87
88 SetStatusText( wxString( _( "Session file imported and merged OK." ) ) );
89
90 Refresh();
91
92 return true;
93}
94
95
96namespace DSN {
97
98
106static int scale( double distance, UNIT_RES* aResolution )
107{
108 double resValue = aResolution->GetValue();
109 double factor;
110
111 switch( aResolution->GetEngUnits() )
112 {
113 default:
114 case T_inch: factor = 25.4e6; break; // nanometers per inch
115 case T_mil: factor = 25.4e3; break; // nanometers per mil
116 case T_cm: factor = 1e7; break; // nanometers per cm
117 case T_mm: factor = 1e6; break; // nanometers per mm
118 case T_um: factor = 1e3; break; // nanometers per um
119 }
120
121 return KiROUND( factor * distance / resValue );
122}
123
124
133static VECTOR2I mapPt( const POINT& aPoint, UNIT_RES* aResolution )
134{
135 VECTOR2I ret( scale( aPoint.x, aResolution ),
136 -scale( aPoint.y, aResolution ) ); // negate y
137
138 return ret;
139}
140
141
142PCB_TRACK* SPECCTRA_DB::makeTRACK( WIRE* wire, PATH* aPath, int aPointIndex, int aNetcode )
143{
144 int layerNdx = findLayerName( aPath->layer_id );
145
146 if( layerNdx == -1 )
147 {
148 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'." ),
149 From_UTF8( aPath->layer_id.c_str() ) ) );
150 }
151
152 PCB_TRACK* track = new PCB_TRACK( m_sessionBoard );
153
154 track->SetStart( mapPt( aPath->points[aPointIndex + 0], m_routeResolution ) );
155 track->SetEnd( mapPt( aPath->points[aPointIndex + 1], m_routeResolution ) );
156 track->SetLayer( m_pcbLayer2kicad[layerNdx] );
157 track->SetWidth( scale( aPath->aperture_width, m_routeResolution ) );
158 track->SetNetCode( aNetcode );
159
160 // a track can be locked.
161 // However specctra as 4 types, none is exactly the same as our locked option
162 // wire->wire_type = T_fix, T_route, T_normal or T_protect
163 // fix and protect could be used as lock option
164 // but protect is returned for all tracks having initially the route or protect property
165 if( wire->m_wire_type == T_fix )
166 track->SetLocked( true );
167
168 return track;
169}
170
171
172PCB_ARC* SPECCTRA_DB::makeARC( WIRE* wire, QARC* aQarc, int aNetcode )
173{
174 int layerNdx = findLayerName( aQarc->layer_id );
175
176 if( layerNdx == -1 )
177 {
178 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'." ),
179 From_UTF8( aQarc->layer_id.c_str() ) ) );
180 }
181
182 PCB_ARC* arc = new PCB_ARC( m_sessionBoard );
183
184 arc->SetStart( mapPt( aQarc->vertex[0], m_routeResolution ) );
185 arc->SetEnd( mapPt( aQarc->vertex[1], m_routeResolution ) );
186 arc->SetMid( CalcArcMid(arc->GetStart(), arc->GetEnd(), mapPt( aQarc->vertex[2], m_routeResolution ) ) );
187 arc->SetLayer( m_pcbLayer2kicad[layerNdx] );
189 arc->SetNetCode( aNetcode );
190
191 // a track can be locked.
192 // However specctra as 4 types, none is exactly the same as our locked option
193 // wire->wire_type = T_fix, T_route, T_normal or T_protect
194 // fix and protect could be used as lock option
195 // but protect is returned for all tracks having initially the route or protect property
196 if( wire->m_wire_type == T_fix )
197 arc->SetLocked( true );
198
199 return arc;
200}
201
202
203PCB_VIA* SPECCTRA_DB::makeVIA( WIRE_VIA* aVia, PADSTACK* aPadstack, const POINT& aPoint,
204 int aNetCode, int aViaDrillDefault )
205{
206 PCB_VIA* via = nullptr;
207 SHAPE* shape;
208 int shapeCount = aPadstack->Length();
209 int drill_diam_iu = -1;
210 int copperLayerCount = m_sessionBoard->GetCopperLayerCount();
211
212
213 // The drill diameter is encoded in the padstack name if Pcbnew did the DSN export.
214 // It is after the colon and before the last '_'
215 size_t drillStartNdx = aPadstack->m_padstack_id.find( ':' );
216
217 if( drillStartNdx != std::string::npos )
218 {
219 ++drillStartNdx; // skip over the ':'
220
221 size_t drillEndNdx = aPadstack->m_padstack_id.rfind( '_' );
222
223 if( drillEndNdx != std::string::npos )
224 {
225 std::string diam_txt( aPadstack->m_padstack_id, drillStartNdx,
226 drillEndNdx-drillStartNdx );
227
228 double drill_um{};
229 fast_float::from_chars( diam_txt.data(), diam_txt.data() + diam_txt.size(), drill_um,
230 fast_float::chars_format::skip_white_space );
231
232 drill_diam_iu = static_cast<int>( drill_um * ( pcbIUScale.IU_PER_MM / 1000.0 ) );
233
234 if( drill_diam_iu == aViaDrillDefault )
235 drill_diam_iu = UNDEFINED_DRILL_DIAMETER;
236 }
237 }
238
239 if( shapeCount == 0 )
240 {
241 THROW_IO_ERROR( _( "Session via padstack has no shapes" ) );
242 }
243 else if( shapeCount == 1 )
244 {
245 shape = static_cast<SHAPE*>( ( *aPadstack )[0] );
246 DSN_T type = shape->shape->Type();
247
248 if( type != T_circle )
249 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s." ), GetTokenString( type ) ) );
250
251 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
252 int viaDiam = scale( circle->diameter, m_routeResolution );
253
254 via = new PCB_VIA( m_sessionBoard );
255 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
256 via->SetDrill( drill_diam_iu );
257 via->SetViaType( VIATYPE::THROUGH );
258 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
259 via->SetLayerPair( F_Cu, B_Cu );
260 }
261 else if( shapeCount == copperLayerCount )
262 {
263 shape = static_cast<SHAPE*>( ( *aPadstack )[0] );
264 DSN_T type = shape->shape->Type();
265
266 if( type != T_circle )
267 {
268 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s" ), GetTokenString( type ) ) );
269 }
270
271 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
272 int viaDiam = scale( circle->diameter, m_routeResolution );
273
274 via = new PCB_VIA( m_sessionBoard );
275 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
276 via->SetDrill( drill_diam_iu );
277 via->SetViaType( VIATYPE::THROUGH );
278 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
279 via->SetLayerPair( F_Cu, B_Cu );
280 }
281 else // VIA_MICROVIA or VIA_BLIND_BURIED
282 {
283 int topLayerNdx = -1; // session layer detectors
284 int botLayerNdx = INT_MAX;
285
286 int viaDiam = -1;
287
288 for( int i = 0; i < shapeCount; ++i )
289 {
290 shape = static_cast<SHAPE*>( ( *aPadstack )[i] );
291 DSN_T type = shape->shape->Type();
292
293 if( type != T_circle )
294 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s" ), GetTokenString( type ) ) );
295
296 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
297
298 int layerNdx = findLayerName( circle->layer_id );
299
300 if( layerNdx == -1 )
301 {
302 wxString layerName = From_UTF8( circle->layer_id.c_str() );
303 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'" ), layerName ) );
304 }
305
306 if( layerNdx > topLayerNdx )
307 topLayerNdx = layerNdx;
308
309 if( layerNdx < botLayerNdx )
310 botLayerNdx = layerNdx;
311
312 if( viaDiam == -1 )
313 viaDiam = scale( circle->diameter, m_routeResolution );
314 }
315
316 via = new PCB_VIA( m_sessionBoard );
317 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
318 via->SetDrill( drill_diam_iu );
319
320 if( ( topLayerNdx == 0 && botLayerNdx == 1 )
321 || ( topLayerNdx == copperLayerCount - 2 && botLayerNdx == copperLayerCount - 1 ) )
322 {
323 via->SetViaType( VIATYPE::MICROVIA );
324 }
325 else if( topLayerNdx > 0 && botLayerNdx < copperLayerCount - 1 )
326 {
327 via->SetViaType( VIATYPE::BURIED );
328 }
329 else
330 {
331 via->SetViaType( VIATYPE::BLIND );
332 }
333
334 wxCHECK2( topLayerNdx >= 0, topLayerNdx = 0 );
335
336 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
337 via->SetLayerPair( m_pcbLayer2kicad[ topLayerNdx ], m_pcbLayer2kicad[ botLayerNdx ] );
338 }
339
340 wxASSERT( via );
341
342 via->SetNetCode( aNetCode );
343
344 // a via can be locked.
345 // However specctra as 4 types, none is exactly the same as our locked option
346 // aVia->via_type = T_fix, T_route, T_normal or T_protect
347 // fix and protect could be used as lock option
348 // but protect is returned for all tracks having initially the route or protect property
349 if( aVia->m_via_type == T_fix )
350 via->SetLocked( true );
351
352 return via;
353}
354
355
356// no UI code in this function, throw exception to report problems to the
357// UI handler: void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
358
360{
361 m_sessionBoard = aBoard; // not owned here
362
363 if( !m_session )
364 THROW_IO_ERROR( _("Session file is missing the \"session\" section") );
365
366 if( !m_session->route )
367 THROW_IO_ERROR( _("Session file is missing the \"routes\" section") );
368
369 if( !m_session->route->library )
370 THROW_IO_ERROR( _("Session file is missing the \"library_out\" section") );
371
372 // delete the old tracks and vias but save locked tracks/vias; they will be re-added later
373 std::vector<PCB_TRACK*> locked;
374 TRACKS tracks = aBoard->Tracks();
375 aBoard->RemoveAll( { PCB_TRACE_T } );
376
377 for( PCB_TRACK* track : tracks )
378 {
379 if( track->IsLocked() )
380 {
381 locked.push_back( track );
382 }
383 else
384 {
385 if( EDA_GROUP* group = track->GetParentGroup() )
386 group->RemoveItem( track );
387
388 delete track;
389 }
390 }
391
392 aBoard->DeleteMARKERs();
393
394 buildLayerMaps( aBoard );
395
396 // Add locked tracks: because they are exported as Fix tracks, they are not
397 // in .ses file.
398 for( PCB_TRACK* track : locked )
399 aBoard->Add( track );
400
401 if( m_session->placement )
402 {
403 // Walk the PLACEMENT object's COMPONENTs list, and for each PLACE within
404 // each COMPONENT, reposition and re-orient each component and put on
405 // correct side of the board.
406 boost::ptr_vector<COMPONENT>& components = m_session->placement->m_components;
407
408 for( COMPONENT& component : components)
409 {
410 for( PLACE& place : component.m_places )
411 {
412 wxString reference = From_UTF8( place.m_component_id.c_str() );
413 FOOTPRINT* footprint = aBoard->FindFootprintByReference( reference );
414
415 if( !footprint )
416 THROW_IO_ERROR( wxString::Format( _( "Reference '%s' not found." ), reference ) );
417
418 if( !place.m_hasVertex )
419 continue;
420
421 UNIT_RES* resolution = place.GetUnits();
422 wxASSERT( resolution );
423
424 VECTOR2I newPos = mapPt( place.m_vertex, resolution );
425 footprint->SetPosition( newPos );
426
427 if( place.m_side == T_front )
428 {
429 // convert from degrees to tenths of degrees used in KiCad.
430 EDA_ANGLE orientation( place.m_rotation, DEGREES_T );
431
432 if( footprint->GetLayer() != F_Cu )
433 {
434 // footprint is on copper layer (back)
435 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
436 }
437
438 footprint->SetOrientation( orientation );
439 }
440 else if( place.m_side == T_back )
441 {
442 EDA_ANGLE orientation( place.m_rotation + 180.0, DEGREES_T );
443
444 if( footprint->GetLayer() != B_Cu )
445 {
446 // footprint is on component layer (front)
447 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
448 }
449
450 footprint->SetOrientation( orientation );
451 }
452 else
453 {
454 // as I write this, the PARSER *is* catching this, so we should never see below:
455 wxFAIL_MSG( wxT("DSN::PARSER did not catch an illegal side := 'back|front'") );
456 }
457 }
458 }
459 }
460
461 m_routeResolution = m_session->route->GetUnits();
462
463 // Walk the NET_OUTs and create tracks and vias anew.
464 boost::ptr_vector<NET_OUT>& net_outs = m_session->route->net_outs;
465
466 for( NET_OUT& net_out : net_outs )
467 {
468 int netoutCode = 0;
469
470 // page 143 of spec says wire's net_id is optional
471 if( net_out.net_id.size() )
472 {
473 wxString netName = From_UTF8( net_out.net_id.c_str() );
474 NETINFO_ITEM* netinfo = aBoard->FindNet( netName );
475
476 if( netinfo )
477 netoutCode = netinfo->GetNetCode();
478 }
479
480 for( WIRE& wire : net_out.wires )
481 {
482 DSN_T shape = wire.m_shape->Type();
483
484 if( shape == T_path )
485 {
486 PATH* path = static_cast<PATH*>( wire.m_shape );
487
488 for( unsigned pt = 0; pt < path->points.size() - 1; ++pt )
489 {
490 PCB_TRACK* track;
491 track = makeTRACK( &wire, path, pt, netoutCode );
492 aBoard->Add( track );
493 }
494 }
495 else if ( shape == T_qarc )
496 {
497 QARC* qarc = static_cast<QARC*>( wire.m_shape );
498
499 PCB_ARC* arc = makeARC( &wire, qarc, netoutCode );
500 aBoard->Add( arc );
501 }
502 else
503 {
504 /*
505 * shape == T_polygon is expected from freerouter if you have a zone on a non-
506 * "power" type layer, i.e. a T_signal layer and the design does a round-trip
507 * back in as session here. We kept our own zones in the BOARD, so ignore this
508 * so called 'wire'.
509
510 wxString netId = From_UTF8( wire->net_id.c_str() );
511 THROW_IO_ERROR( wxString::Format( _( "Unsupported wire shape: '%s' for net: '%s'" ),
512 DLEX::GetTokenString(shape).GetData(),
513 netId.GetData() ) );
514 */
515 }
516 }
517
518 for( WIRE_VIA& wire_via : net_out.wire_vias )
519 {
520 int netCode = 0;
521
522 // page 144 of spec says wire_via's net_id is optional
523 if( net_out.net_id.size() )
524 {
525 wxString netName = From_UTF8( net_out.net_id.c_str() );
526 NETINFO_ITEM* netvia = aBoard->FindNet( netName );
527
528 if( netvia )
529 netCode = netvia->GetNetCode();
530 }
531
532 // example: (via Via_15:8_mil 149000 -71000 )
533
534 PADSTACK* padstack = m_session->route->library->FindPADSTACK( wire_via.GetPadstackId() );
535
536 if( !padstack )
537 {
538 // Dick Feb 29, 2008:
539 // Freerouter has a bug where it will not round trip all vias. Vias which have
540 // a (use_via) element will be round tripped. Vias which do not, don't come back
541 // in in the session library, even though they may be actually used in the
542 // pre-routed, protected wire_vias. So until that is fixed, create the padstack
543 // from its name as a work around.
544 wxString psid( From_UTF8( wire_via.GetPadstackId().c_str() ) );
545
546 THROW_IO_ERROR( wxString::Format( _( "A wire_via refers to missing padstack '%s'." ), psid ) );
547 }
548
549 std::shared_ptr<NET_SETTINGS>& netSettings = aBoard->GetDesignSettings().m_NetSettings;
550
551 int via_drill_default = netSettings->GetDefaultNetclass()->GetViaDrill();
552
553 for( unsigned v = 0; v < wire_via.m_vertexes.size(); ++v )
554 {
555 PCB_VIA* via = makeVIA( &wire_via, padstack, wire_via.m_vertexes[v], netCode, via_drill_default );
556 aBoard->Add( via );
557 }
558 }
559 }
560}
561
562
563bool ImportSpecctraSession( BOARD* aBoard, const wxString& fullFileName )
564{
565 SPECCTRA_DB db;
566 LOCALE_IO toggle;
567
568 db.LoadSESSION( fullFileName );
569 db.FromSESSION( aBoard );
570
571 aBoard->GetConnectivity()->ClearRatsnest();
572 aBoard->BuildConnectivity();
573
574 return true;
575}
576} // 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:356
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1295
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition board.cpp:2657
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:201
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:1538
const TRACKS & Tracks() const
Definition board.h:418
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition board.cpp:2739
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1149
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition board.cpp:1785
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:634
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