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 != std::string::npos )
195 if( drillEndNdx != std::string::npos )
197 std::string diam_txt( aPadstack->
m_padstack_id, drillStartNdx,
198 drillEndNdx-drillStartNdx );
200 double drill_um = strtod( diam_txt.c_str(),
nullptr );
204 if( drill_diam_iu == aViaDrillDefault )
209 if( shapeCount == 0 )
213 else if( shapeCount == 1 )
215 shape = (
SHAPE*) (*aPadstack)[0];
218 if( type != T_circle )
221 GetTokenString( type ) ) );
229 via->SetDrill( drill_diam_iu );
230 via->SetViaType( VIATYPE::THROUGH );
234 else if( shapeCount == copperLayerCount )
236 shape = (
SHAPE*) (*aPadstack)[0];
239 if( type != T_circle )
242 GetTokenString( type ) ) );
250 via->SetDrill( drill_diam_iu );
251 via->SetViaType( VIATYPE::THROUGH );
257 int topLayerNdx = -1;
258 int botLayerNdx = INT_MAX;
262 for(
int i=0; i<shapeCount; ++i )
264 shape = (
SHAPE*) (*aPadstack)[i];
267 if( type != T_circle )
270 GetTokenString( type ) ) );
279 THROW_IO_ERROR( wxString::Format(
_(
"Session file uses invalid layer id '%s'" ),
283 if( layerNdx > topLayerNdx )
284 topLayerNdx = layerNdx;
286 if( layerNdx < botLayerNdx )
287 botLayerNdx = layerNdx;
295 via->SetDrill( drill_diam_iu );
297 if( ( topLayerNdx == 0 && botLayerNdx == 1 )
298 || ( topLayerNdx == copperLayerCount-2 && botLayerNdx == copperLayerCount-1 ) )
300 via->SetViaType( VIATYPE::MICROVIA );
304 via->SetViaType( VIATYPE::BLIND_BURIED );
313 via->SetNetCode( aNetCode );
321 via->SetLocked(
true );
335 THROW_IO_ERROR(
_(
"Session file is missing the \"session\" section") );
341 THROW_IO_ERROR(
_(
"Session file is missing the \"library_out\" section") );
344 std::vector<PCB_TRACK*>
locked;
345 TRACKS tracks = aBoard->
Tracks();
350 if( track->IsLocked() )
352 locked.push_back( track );
357 group->RemoveItem( track );
370 aBoard->
Add( track );
379 for( COMPONENTS::iterator comp=components.begin(); comp!=components.end(); ++comp )
381 PLACES& places = comp->m_places;
382 for(
unsigned i=0; i<places.size(); ++i )
384 PLACE* place = &places[i];
399 wxASSERT( resolution );
404 if( place->
m_side == T_front )
412 footprint->
Flip( footprint->
GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
417 else if( place->
m_side == T_back )
424 footprint->
Flip( footprint->
GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
432 wxFAIL_MSG( wxT(
"DSN::PARSER did not catch an illegal side := 'back|front'") );
442 for( NET_OUTS::iterator net = net_outs.begin(); net!=net_outs.end(); ++net )
447 if( net->net_id.size() )
449 wxString netName =
From_UTF8( net->net_id.c_str() );
456 WIRES& wires = net->wires;
457 for(
unsigned i = 0; i<wires.size(); ++i )
459 WIRE* wire = &wires[i];
462 if( shape != T_path )
480 for(
unsigned pt=0; pt < path->points.size()-1; ++pt )
483 aBoard->
Add( track );
491 for(
unsigned i=0; i<wire_vias.size(); ++i )
496 if( net->net_id.size() )
498 wxString netName =
From_UTF8( net->net_id.c_str() );
520 THROW_IO_ERROR( wxString::Format(
_(
"A wire_via refers to missing padstack '%s'." ),
526 int via_drill_default = netSettings->GetDefaultNetclass()->GetViaDrill();
528 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.
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.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
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 SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
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.
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)