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 <fast_float/fast_float.h>
38#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(), mapPt( aQarc->vertex[2], m_routeResolution ) ) );
191 arc->SetLayer( m_pcbLayer2kicad[layerNdx] );
193 arc->SetNetCode( aNetcode );
194
195 // a track can be locked.
196 // However specctra as 4 types, none is exactly the same as our locked option
197 // wire->wire_type = T_fix, T_route, T_normal or T_protect
198 // fix and protect could be used as lock option
199 // but protect is returned for all tracks having initially the route or protect property
200 if( wire->m_wire_type == T_fix )
201 arc->SetLocked( true );
202
203 return arc;
204}
205
206
207PCB_VIA* SPECCTRA_DB::makeVIA( WIRE_VIA* aVia, PADSTACK* aPadstack, const POINT& aPoint,
208 int aNetCode, int aViaDrillDefault )
209{
210 PCB_VIA* via = nullptr;
211 SHAPE* shape;
212 int shapeCount = aPadstack->Length();
213 int drill_diam_iu = -1;
214 int copperLayerCount = m_sessionBoard->GetCopperLayerCount();
215
216
217 // The drill diameter is encoded in the padstack name if Pcbnew did the DSN export.
218 // It is after the colon and before the last '_'
219 size_t drillStartNdx = aPadstack->m_padstack_id.find( ':' );
220
221 if( drillStartNdx != std::string::npos )
222 {
223 ++drillStartNdx; // skip over the ':'
224
225 size_t drillEndNdx = aPadstack->m_padstack_id.rfind( '_' );
226
227 if( drillEndNdx != std::string::npos )
228 {
229 std::string diam_txt( aPadstack->m_padstack_id, drillStartNdx,
230 drillEndNdx-drillStartNdx );
231
232 double drill_um{};
233 fast_float::from_chars( diam_txt.data(), diam_txt.data() + diam_txt.size(), drill_um,
234 fast_float::chars_format::skip_white_space );
235
236 drill_diam_iu = static_cast<int>( drill_um * ( pcbIUScale.IU_PER_MM / 1000.0 ) );
237
238 if( drill_diam_iu == aViaDrillDefault )
239 drill_diam_iu = UNDEFINED_DRILL_DIAMETER;
240 }
241 }
242
243 if( shapeCount == 0 )
244 {
245 THROW_IO_ERROR( _( "Session via padstack has no shapes" ) );
246 }
247 else if( shapeCount == 1 )
248 {
249 shape = static_cast<SHAPE*>( ( *aPadstack )[0] );
250 DSN_T type = shape->shape->Type();
251
252 if( type != T_circle )
253 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s." ), GetTokenString( type ) ) );
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" ), GetTokenString( type ) ) );
273 }
274
275 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
276 int viaDiam = scale( circle->diameter, m_routeResolution );
277
278 via = new PCB_VIA( m_sessionBoard );
279 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
280 via->SetDrill( drill_diam_iu );
281 via->SetViaType( VIATYPE::THROUGH );
282 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
283 via->SetLayerPair( F_Cu, B_Cu );
284 }
285 else // VIA_MICROVIA or VIA_BLIND_BURIED
286 {
287 int topLayerNdx = -1; // session layer detectors
288 int botLayerNdx = INT_MAX;
289
290 int viaDiam = -1;
291
292 for( int i = 0; i < shapeCount; ++i )
293 {
294 shape = static_cast<SHAPE*>( ( *aPadstack )[i] );
295 DSN_T type = shape->shape->Type();
296
297 if( type != T_circle )
298 THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s" ), GetTokenString( type ) ) );
299
300 CIRCLE* circle = static_cast<CIRCLE*>( shape->shape );
301
302 int layerNdx = findLayerName( circle->layer_id );
303
304 if( layerNdx == -1 )
305 {
306 wxString layerName = From_UTF8( circle->layer_id.c_str() );
307 THROW_IO_ERROR( wxString::Format( _( "Session file uses invalid layer id '%s'" ), layerName ) );
308 }
309
310 if( layerNdx > topLayerNdx )
311 topLayerNdx = layerNdx;
312
313 if( layerNdx < botLayerNdx )
314 botLayerNdx = layerNdx;
315
316 if( viaDiam == -1 )
317 viaDiam = scale( circle->diameter, m_routeResolution );
318 }
319
320 via = new PCB_VIA( m_sessionBoard );
321 via->SetPosition( mapPt( aPoint, m_routeResolution ) );
322 via->SetDrill( drill_diam_iu );
323
324 if( ( topLayerNdx == 0 && botLayerNdx == 1 )
325 || ( topLayerNdx == copperLayerCount - 2 && botLayerNdx == copperLayerCount - 1 ) )
326 {
327 via->SetViaType( VIATYPE::MICROVIA );
328 }
329 else if( topLayerNdx > 0 && botLayerNdx < copperLayerCount - 1 )
330 {
331 via->SetViaType( VIATYPE::BURIED );
332 }
333 else
334 {
335 via->SetViaType( VIATYPE::BLIND );
336 }
337
338 wxCHECK2( topLayerNdx >= 0, topLayerNdx = 0 );
339
340 via->SetWidth( ::PADSTACK::ALL_LAYERS, viaDiam );
341 via->SetLayerPair( m_pcbLayer2kicad[ topLayerNdx ], m_pcbLayer2kicad[ botLayerNdx ] );
342 }
343
344 wxASSERT( via );
345
346 via->SetNetCode( aNetCode );
347
348 // a via can be locked.
349 // However specctra as 4 types, none is exactly the same as our locked option
350 // aVia->via_type = T_fix, T_route, T_normal or T_protect
351 // fix and protect could be used as lock option
352 // but protect is returned for all tracks having initially the route or protect property
353 if( aVia->m_via_type == T_fix )
354 via->SetLocked( true );
355
356 return via;
357}
358
359
360// no UI code in this function, throw exception to report problems to the
361// UI handler: void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
362
364{
365 m_sessionBoard = aBoard; // not owned here
366
367 if( !m_session )
368 THROW_IO_ERROR( _("Session file is missing the \"session\" section") );
369
370 if( !m_session->route )
371 THROW_IO_ERROR( _("Session file is missing the \"routes\" section") );
372
373 if( !m_session->route->library )
374 THROW_IO_ERROR( _("Session file is missing the \"library_out\" section") );
375
376 // delete the old tracks and vias but save locked tracks/vias; they will be re-added later
377 std::vector<PCB_TRACK*> locked;
378 TRACKS tracks = aBoard->Tracks();
379 aBoard->RemoveAll( { PCB_TRACE_T } );
380
381 for( PCB_TRACK* track : tracks )
382 {
383 if( track->IsLocked() )
384 {
385 locked.push_back( track );
386 }
387 else
388 {
389 if( EDA_GROUP* group = track->GetParentGroup() )
390 group->RemoveItem( track );
391
392 delete track;
393 }
394 }
395
396 aBoard->DeleteMARKERs();
397
398 buildLayerMaps( aBoard );
399
400 // Add locked tracks: because they are exported as Fix tracks, they are not
401 // in .ses file.
402 for( PCB_TRACK* track : locked )
403 aBoard->Add( track );
404
405 if( m_session->placement )
406 {
407 // Walk the PLACEMENT object's COMPONENTs list, and for each PLACE within
408 // each COMPONENT, reposition and re-orient each component and put on
409 // correct side of the board.
410 boost::ptr_vector<COMPONENT>& components = m_session->placement->m_components;
411
412 for( COMPONENT& component : components)
413 {
414 for( PLACE& place : component.m_places )
415 {
416 wxString reference = From_UTF8( place.m_component_id.c_str() );
417 FOOTPRINT* footprint = aBoard->FindFootprintByReference( reference );
418
419 if( !footprint )
420 THROW_IO_ERROR( wxString::Format( _( "Reference '%s' not found." ), reference ) );
421
422 if( !place.m_hasVertex )
423 continue;
424
425 UNIT_RES* resolution = place.GetUnits();
426 wxASSERT( resolution );
427
428 VECTOR2I newPos = mapPt( place.m_vertex, resolution );
429 footprint->SetPosition( newPos );
430
431 if( place.m_side == T_front )
432 {
433 // convert from degrees to tenths of degrees used in KiCad.
434 EDA_ANGLE orientation( place.m_rotation, DEGREES_T );
435
436 if( footprint->GetLayer() != F_Cu )
437 {
438 // footprint is on copper layer (back)
439 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
440 }
441
442 footprint->SetOrientation( orientation );
443 }
444 else if( place.m_side == T_back )
445 {
446 EDA_ANGLE orientation( place.m_rotation + 180.0, DEGREES_T );
447
448 if( footprint->GetLayer() != B_Cu )
449 {
450 // footprint is on component layer (front)
451 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
452 }
453
454 footprint->SetOrientation( orientation );
455 }
456 else
457 {
458 // as I write this, the PARSER *is* catching this, so we should never see below:
459 wxFAIL_MSG( wxT("DSN::PARSER did not catch an illegal side := 'back|front'") );
460 }
461 }
462 }
463 }
464
465 m_routeResolution = m_session->route->GetUnits();
466
467 // Walk the NET_OUTs and create tracks and vias anew.
468 boost::ptr_vector<NET_OUT>& net_outs = m_session->route->net_outs;
469
470 for( NET_OUT& net_out : net_outs )
471 {
472 int netoutCode = 0;
473
474 // page 143 of spec says wire's net_id is optional
475 if( net_out.net_id.size() )
476 {
477 wxString netName = From_UTF8( net_out.net_id.c_str() );
478 NETINFO_ITEM* netinfo = aBoard->FindNet( netName );
479
480 if( netinfo )
481 netoutCode = netinfo->GetNetCode();
482 }
483
484 for( WIRE& wire : net_out.wires )
485 {
486 DSN_T shape = wire.m_shape->Type();
487
488 if( shape == T_path )
489 {
490 PATH* path = static_cast<PATH*>( wire.m_shape );
491
492 for( unsigned pt = 0; pt < path->points.size() - 1; ++pt )
493 {
494 PCB_TRACK* track;
495 track = makeTRACK( &wire, path, pt, netoutCode );
496 aBoard->Add( track );
497 }
498 }
499 else if ( shape == T_qarc )
500 {
501 QARC* qarc = static_cast<QARC*>( wire.m_shape );
502
503 PCB_ARC* arc = makeARC( &wire, qarc, netoutCode );
504 aBoard->Add( arc );
505 }
506 else
507 {
508 /*
509 * shape == T_polygon is expected from freerouter if you have a zone on a non-
510 * "power" type layer, i.e. a T_signal layer and the design does a round-trip
511 * back in as session here. We kept our own zones in the BOARD, so ignore this
512 * so called 'wire'.
513
514 wxString netId = From_UTF8( wire->net_id.c_str() );
515 THROW_IO_ERROR( wxString::Format( _( "Unsupported wire shape: '%s' for net: '%s'" ),
516 DLEX::GetTokenString(shape).GetData(),
517 netId.GetData() ) );
518 */
519 }
520 }
521
522 for( WIRE_VIA& wire_via : net_out.wire_vias )
523 {
524 int netCode = 0;
525
526 // page 144 of spec says wire_via's net_id is optional
527 if( net_out.net_id.size() )
528 {
529 wxString netName = From_UTF8( net_out.net_id.c_str() );
530 NETINFO_ITEM* netvia = aBoard->FindNet( netName );
531
532 if( netvia )
533 netCode = netvia->GetNetCode();
534 }
535
536 // example: (via Via_15:8_mil 149000 -71000 )
537
538 PADSTACK* padstack = m_session->route->library->FindPADSTACK( wire_via.GetPadstackId() );
539
540 if( !padstack )
541 {
542 // Dick Feb 29, 2008:
543 // Freerouter has a bug where it will not round trip all vias. Vias which have
544 // a (use_via) element will be round tripped. Vias which do not, don't come back
545 // in in the session library, even though they may be actually used in the
546 // pre-routed, protected wire_vias. So until that is fixed, create the padstack
547 // from its name as a work around.
548 wxString psid( From_UTF8( wire_via.GetPadstackId().c_str() ) );
549
550 THROW_IO_ERROR( wxString::Format( _( "A wire_via refers to missing padstack '%s'." ), psid ) );
551 }
552
553 std::shared_ptr<NET_SETTINGS>& netSettings = aBoard->GetDesignSettings().m_NetSettings;
554
555 int via_drill_default = netSettings->GetDefaultNetclass()->GetViaDrill();
556
557 for( unsigned v = 0; v < wire_via.m_vertexes.size(); ++v )
558 {
559 PCB_VIA* via = makeVIA( &wire_via, padstack, wire_via.m_vertexes[v], netCode, via_drill_default );
560 aBoard->Add( via );
561 }
562 }
563 }
564}
565
566
567bool ImportSpecctraSession( BOARD* aBoard, const wxString& fullFileName )
568{
569 SPECCTRA_DB db;
570 LOCALE_IO toggle;
571
572 db.LoadSESSION( fullFileName );
573 db.FromSESSION( aBoard );
574
575 aBoard->GetConnectivity()->ClearRatsnest();
576 aBoard->BuildConnectivity();
577
578 return true;
579}
580} // 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.
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:328
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1222
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition board.cpp:2371
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
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:1483
const TRACKS & Tracks() const
Definition board.h:361
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition board.cpp:2453
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1082
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition board.cpp:1718
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:563
void ClearRatsnest()
Function Clear() Erases the connectivity database.
Implement a <component_descriptor> in the specctra dsn spec.
Definition specctra.h:1755
int Length() const
Return the number of ELEMs in this holder.
Definition specctra.h:320
virtual UNIT_RES * GetUnits() const
Return the units for this section.
DSN_T Type() const
Definition specctra.h:213
A <net_out_descriptor> of the specctra dsn spec.
Definition specctra.h:3350
Hold either a via or a pad definition.
Definition specctra.h:2098
std::string m_padstack_id
Definition specctra.h:2197
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
Definition specctra.h:583
std::vector< POINT > points
Definition specctra.h:653
double aperture_width
Definition specctra.h:651
std::string layer_id
Definition specctra.h:650
Implement a <placement_reference> in the specctra dsn spec.
Definition specctra.h:1677
bool m_hasVertex
Definition specctra.h:1728
POINT m_vertex
Definition specctra.h:1729
DSN_T m_side
Definition specctra.h:1724
double m_rotation
Definition specctra.h:1726
std::string m_component_id
reference designator
Definition specctra.h:1722
std::string layer_id
Definition specctra.h:834
double aperture_width
Definition specctra.h:835
POINT vertex[3]
Definition specctra.h:836
A "(shape ..)" element in the specctra dsn spec.
Definition specctra.h:1876
A DSN data tree, usually coming from a DSN file.
Definition specctra.h:3593
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:3941
UNIT_RES * m_routeResolution
used during FromSESSION() only, memory for it is not owned here.
Definition specctra.h:3944
BOARD * m_sessionBoard
a copy to avoid passing as an argument, memory for it is not owned here.
Definition specctra.h:3947
SESSION * m_session
Definition specctra.h:3930
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:406
DSN_T GetEngUnits() const
Definition specctra.h:422
int GetValue() const
Definition specctra.h:423
ELEM * shape
Definition specctra.h:890
A <wire_via_descriptor> in the specctra dsn spec.
Definition specctra.h:2945
DSN_T m_via_type
Definition specctra.h:3076
const std::string & GetPadstackId()
Definition specctra.h:2956
std::vector< POINT > m_vertexes
Definition specctra.h:3073
A <wire_shape_descriptor> in the specctra dsn spec.
Definition specctra.h:2838
DSN_T m_wire_type
Definition specctra.h:2932
ELEM * m_shape
Definition specctra.h:2928
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:339
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I GetPosition() const override
Definition footprint.h:327
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:177
void SetMid(const VECTOR2I &aMid)
Definition pcb_track.h:346
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:150
void SetStart(const VECTOR2I &aStart)
Definition pcb_track.h:153
const VECTOR2I & GetStart() const
Definition pcb_track.h:154
const VECTOR2I & GetEnd() const
Definition pcb_track.h:151
virtual void SetWidth(int aWidth)
Definition pcb_track.h:147
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:202
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
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.
@ THROUGH
Definition pcb_track.h:68
@ MICROVIA
Definition pcb_track.h:71
#define UNDEFINED_DRILL_DIAMETER
Definition pcb_track.h:111
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
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: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