71 wxString msg =
_(
"Board may be corrupted, do not save it.\n Fix problem and try again" );
73 wxString extra = ioe.
What();
90 SetStatusText( wxString(
_(
"Session file imported and merged OK." ) ) );
110 double resValue = aResolution->
GetValue();
116 case T_inch: factor = 25.4e6;
break;
117 case T_mil: factor = 25.4e3;
break;
118 case T_cm: factor = 1e7;
break;
119 case T_mm: factor = 1e6;
break;
120 case T_um: factor = 1e3;
break;
138 -
scale( aPoint.
y, aResolution ) );
150 THROW_IO_ERROR( wxString::Format(
_(
"Session file uses invalid layer id '%s'." ),
180 THROW_IO_ERROR( wxString::Format(
_(
"Session file uses invalid layer id '%s'." ),
207 int aNetCode,
int aViaDrillDefault )
211 int shapeCount = aPadstack->
Length();
212 int drill_diam_iu = -1;
220 if( drillStartNdx != std::string::npos )
226 if( drillEndNdx != std::string::npos )
228 std::string diam_txt( aPadstack->
m_padstack_id, drillStartNdx,
229 drillEndNdx-drillStartNdx );
231 double drill_um = strtod( diam_txt.c_str(),
nullptr );
235 if( drill_diam_iu == aViaDrillDefault )
240 if( shapeCount == 0 )
244 else if( shapeCount == 1 )
246 shape =
static_cast<SHAPE*
>( ( *aPadstack )[0] );
249 if( type != T_circle )
252 GetTokenString( type ) ) );
260 via->SetDrill( drill_diam_iu );
261 via->SetViaType( VIATYPE::THROUGH );
265 else if( shapeCount == copperLayerCount )
267 shape =
static_cast<SHAPE*
>( ( *aPadstack )[0] );
270 if( type != T_circle )
273 GetTokenString( type ) ) );
281 via->SetDrill( drill_diam_iu );
282 via->SetViaType( VIATYPE::THROUGH );
288 int topLayerNdx = -1;
289 int botLayerNdx = INT_MAX;
293 for(
int i = 0; i < shapeCount; ++i )
295 shape =
static_cast<SHAPE*
>( ( *aPadstack )[i] );
298 if( type != T_circle )
301 GetTokenString( type ) ) );
311 THROW_IO_ERROR( wxString::Format(
_(
"Session file uses invalid layer id '%s'" ),
315 if( layerNdx > topLayerNdx )
316 topLayerNdx = layerNdx;
318 if( layerNdx < botLayerNdx )
319 botLayerNdx = layerNdx;
327 via->SetDrill( drill_diam_iu );
329 if( ( topLayerNdx == 0 && botLayerNdx == 1 )
330 || ( topLayerNdx == copperLayerCount - 2 && botLayerNdx == copperLayerCount - 1 ) )
332 via->SetViaType( VIATYPE::MICROVIA );
336 via->SetViaType( VIATYPE::BLIND_BURIED );
339 wxCHECK2( topLayerNdx >= 0, topLayerNdx = 0 );
347 via->SetNetCode( aNetCode );
355 via->SetLocked(
true );
369 THROW_IO_ERROR(
_(
"Session file is missing the \"session\" section") );
375 THROW_IO_ERROR(
_(
"Session file is missing the \"library_out\" section") );
378 std::vector<PCB_TRACK*>
locked;
384 if( track->IsLocked() )
386 locked.push_back( track );
391 group->RemoveItem( track );
404 aBoard->
Add( track );
413 for( COMPONENTS::iterator comp = components.begin(); comp != components.end(); ++comp )
415 PLACES& places = comp->m_places;
417 for(
unsigned i = 0; i < places.size(); ++i )
419 PLACE* place = &places[i];
434 wxASSERT( resolution );
439 if( place->
m_side == T_front )
447 footprint->
Flip( footprint->
GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
452 else if( place->
m_side == T_back )
459 footprint->
Flip( footprint->
GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
467 wxFAIL_MSG( wxT(
"DSN::PARSER did not catch an illegal side := 'back|front'") );
478 for( NET_OUTS::iterator net = net_outs.begin(); net!=net_outs.end(); ++net )
483 if( net->net_id.size() )
485 wxString netName =
From_UTF8( net->net_id.c_str() );
492 WIRES& wires = net->wires;
494 for(
unsigned i = 0; i<wires.size(); ++i )
496 WIRE* wire = &wires[i];
499 if( shape == T_path )
503 for(
unsigned pt = 0; pt <
path->points.size() - 1; ++pt )
507 aBoard->
Add( track );
510 else if ( shape == T_qarc )
536 for(
unsigned i = 0; i < wire_vias.size(); ++i )
541 if( net->net_id.size() )
543 wxString netName =
From_UTF8( net->net_id.c_str() );
566 THROW_IO_ERROR( wxString::Format(
_(
"A wire_via refers to missing padstack '%s'." ),
572 int via_drill_default = netSettings->GetDefaultNetclass()->GetViaDrill();
574 for(
unsigned v = 0; v < wire_via->
m_vertexes.size(); ++v )
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
std::shared_ptr< NET_SETTINGS > m_NetSettings
virtual void SetLocked(bool aLocked)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
int GetCopperLayerCount() const
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.
const TRACKS & Tracks() const
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void DeleteMARKERs()
Delete all MARKERS from the board.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
int Length() const
Return the number of ELEMs in this holder.
virtual UNIT_RES * GetUnits() const
Return the units for this section.
A <library_descriptor> in the specctra dsn specification.
Hold either a via or a pad definition.
std::string m_padstack_id
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
Implement a <placement_reference> in the specctra dsn spec.
std::string m_component_id
reference designator
UNIT_RES * GetUnits() const override
Return the units for this section.
A "(shape ..)" element in the specctra dsn spec.
A DSN data tree, usually coming from a DSN file.
void buildLayerMaps(BOARD *aBoard)
Create a few data translation structures for layer name and number mapping between the DSN::PCB struc...
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
UNIT_RES * m_routeResolution
used during FromSESSION() only, memory for it is not owned here.
BOARD * m_sessionBoard
a copy to avoid passing as an argument, memory for it is not owned here.
void LoadSESSION(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "session" file.
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.
A holder for either a T_unit or T_resolution object which are usually mutually exclusive in the dsn g...
DSN_T GetEngUnits() const
A <wire_via_descriptor> in the specctra dsn spec.
const std::string & GetPadstackId()
A <wire_shape_descriptor> in the specctra dsn spec.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
A set of EDA_ITEMs (i.e., without duplicates).
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.
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Handle the data for a net.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
void SetMid(const VECTOR2I &aMid)
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
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)
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
virtual void SetWidth(int aWidth)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
#define THROW_IO_ERROR(msg)
This file contains miscellaneous commonly used macros and functions.
This source file implements export and import capabilities to the specctra dsn file format.
boost::ptr_vector< NET_OUT > NET_OUTS
static POINT mapPt(const VECTOR2I &pt)
Convert a KiCad point into a DSN file point.
boost::ptr_vector< WIRE > WIRES
boost::ptr_vector< PLACE > PLACES
boost::ptr_vector< WIRE_VIA > WIRE_VIAS
boost::ptr_vector< COMPONENT > COMPONENTS
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
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)
wxString From_UTF8(const char *cstring)
A point in the SPECCTRA DSN coordinate system.
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.
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)