72 wxString msg =
_(
"Board may be corrupted, do not save it.\n Fix problem and try again" );
74 wxString extra = ioe.
What();
87 for(
auto track :
GetBoard()->Tracks() )
91 SetStatusText( wxString(
_(
"Session file imported and merged OK." ) ) );
111 double resValue = aResolution->
GetValue();
117 case T_inch: factor = 25.4e6;
break;
118 case T_mil: factor = 25.4e3;
break;
119 case T_cm: factor = 1e7;
break;
120 case T_mm: factor = 1e6;
break;
121 case T_um: factor = 1e3;
break;
139 -
scale( aPoint.
y, aResolution ) );
151 THROW_IO_ERROR( wxString::Format(
_(
"Session file uses invalid layer id '%s'." ),
176 int aViaDrillDefault )
180 int shapeCount = aPadstack->
Length();
181 int drill_diam_iu = -1;
189 if( drillStartNdx != -1 )
194 if( drillEndNdx != -1 )
197 drillStartNdx, drillEndNdx-drillStartNdx );
199 double drill_um = strtod( diam_txt.c_str(), 0 );
203 if( drill_diam_iu == aViaDrillDefault )
208 if( shapeCount == 0 )
212 else if( shapeCount == 1 )
214 shape = (
SHAPE*) (*aPadstack)[0];
217 if( type != T_circle )
220 GetTokenString( type ) ) );
228 via->SetDrill( drill_diam_iu );
229 via->SetViaType( VIATYPE::THROUGH );
230 via->SetWidth( viaDiam );
233 else if( shapeCount == copperLayerCount )
235 shape = (
SHAPE*) (*aPadstack)[0];
238 if( type != T_circle )
241 GetTokenString( type ) ) );
249 via->SetDrill( drill_diam_iu );
250 via->SetViaType( VIATYPE::THROUGH );
251 via->SetWidth( viaDiam );
256 int topLayerNdx = -1;
257 int botLayerNdx = INT_MAX;
261 for(
int i=0; i<shapeCount; ++i )
263 shape = (
SHAPE*) (*aPadstack)[i];
266 if( type != T_circle )
269 GetTokenString( type ) ) );
278 THROW_IO_ERROR( wxString::Format(
_(
"Session file uses invalid layer id '%s'" ),
282 if( layerNdx > topLayerNdx )
283 topLayerNdx = layerNdx;
285 if( layerNdx < botLayerNdx )
286 botLayerNdx = layerNdx;
294 via->SetDrill( drill_diam_iu );
296 if( ( topLayerNdx == 0 && botLayerNdx == 1 )
297 || ( topLayerNdx == copperLayerCount-2 && botLayerNdx == copperLayerCount-1 ) )
299 via->SetViaType( VIATYPE::MICROVIA );
303 via->SetViaType( VIATYPE::BLIND_BURIED );
306 via->SetWidth( viaDiam );
312 via->SetNetCode( aNetCode );
320 via->SetLocked(
true );
334 THROW_IO_ERROR(
_(
"Session file is missing the \"session\" section") );
340 THROW_IO_ERROR(
_(
"Session file is missing the \"library_out\" section") );
343 std::vector<PCB_TRACK*>
locked;
344 TRACKS tracks = aBoard->
Tracks();
349 if( track->IsLocked() )
351 locked.push_back( track );
356 group->RemoveItem( track );
369 aBoard->
Add( track );
378 for( COMPONENTS::iterator comp=components.begin(); comp!=components.end(); ++comp )
380 PLACES& places = comp->m_places;
381 for(
unsigned i=0; i<places.size(); ++i )
383 PLACE* place = &places[i];
398 wxASSERT( resolution );
403 if( place->
m_side == T_front )
416 else if( place->
m_side == T_back )
431 wxFAIL_MSG( wxT(
"DSN::PARSER did not catch an illegal side := 'back|front'") );
441 for( NET_OUTS::iterator net = net_outs.begin(); net!=net_outs.end(); ++net )
446 if( net->net_id.size() )
448 wxString netName =
From_UTF8( net->net_id.c_str() );
455 WIRES& wires = net->wires;
456 for(
unsigned i = 0; i<wires.size(); ++i )
458 WIRE* wire = &wires[i];
461 if( shape != T_path )
479 for(
unsigned pt=0; pt < path->points.size()-1; ++pt )
482 aBoard->
Add( track );
490 for(
unsigned i=0; i<wire_vias.size(); ++i )
495 if( net->net_id.size() )
497 wxString netName =
From_UTF8( net->net_id.c_str() );
519 THROW_IO_ERROR( wxString::Format(
_(
"A wire_via refers to missing padstack '%s'." ),
525 int via_drill_default = netSettings->m_DefaultNetClass->GetViaDrill();
527 for(
unsigned v = 0; v < wire_via->
m_vertexes.size(); ++v )
constexpr EDA_IU_SCALE pcbIUScale
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.
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.
std::vector< PCB_LAYER_ID > m_pcbLayer2kicad
maps PCB layer number to BOARD layer numbers
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...
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()
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.
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 ...
A set of BOARD_ITEMs (i.e., without duplicates).
void SetWidth(int aWidth)
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
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.
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".