76 wxString msg =
_(
"Board may be corrupted, do not save it.\n Fix problem and try again" );
78 wxString extra = ioe.
What();
95 for(
auto track :
GetBoard()->Tracks() )
99 SetStatusText( wxString(
_(
"Session file imported and merged OK." ) ) );
119 double resValue = aResolution->
GetValue();
125 case T_inch: factor = 25.4e6;
break;
126 case T_mil: factor = 25.4e3;
break;
127 case T_cm: factor = 1e7;
break;
128 case T_mm: factor = 1e6;
break;
129 case T_um: factor = 1e3;
break;
147 -
scale( aPoint.
y, aResolution ) );
184 int aViaDrillDefault )
188 int shapeCount = aPadstack->
Length();
189 int drill_diam_iu = -1;
195 int drillStartNdx = aPadstack->
padstack_id.find(
':' );
197 if( drillStartNdx != -1 )
201 int drillEndNdx = aPadstack->
padstack_id.rfind(
'_' );
202 if( drillEndNdx != -1 )
205 drillStartNdx, drillEndNdx-drillStartNdx );
207 double drill_um = strtod( diam_txt.c_str(), 0 );
211 if( drill_diam_iu == aViaDrillDefault )
216 if( shapeCount == 0 )
220 else if( shapeCount == 1 )
222 shape = (
SHAPE*) (*aPadstack)[0];
225 if( type != T_circle )
228 GetTokenString( type ) ) );
236 via->SetDrill( drill_diam_iu );
238 via->SetWidth( viaDiam );
241 else if( shapeCount == copperLayerCount )
243 shape = (
SHAPE*) (*aPadstack)[0];
246 if( type != T_circle )
249 GetTokenString( type ) ) );
257 via->SetDrill( drill_diam_iu );
259 via->SetWidth( viaDiam );
264 int topLayerNdx = -1;
265 int botLayerNdx = INT_MAX;
269 for(
int i=0; i<shapeCount; ++i )
271 shape = (
SHAPE*) (*aPadstack)[i];
274 if( type != T_circle )
277 GetTokenString( type ) ) );
290 if( layerNdx > topLayerNdx )
291 topLayerNdx = layerNdx;
293 if( layerNdx < botLayerNdx )
294 botLayerNdx = layerNdx;
302 via->SetDrill( drill_diam_iu );
304 if( ( topLayerNdx == 0 && botLayerNdx == 1 )
305 || ( topLayerNdx == copperLayerCount-2 && botLayerNdx == copperLayerCount-1 ) )
314 via->SetWidth( viaDiam );
320 via->SetNetCode( aNetCode );
328 via->SetLocked(
true );
342 THROW_IO_ERROR(
_(
"Session file is missing the \"session\" section") );
348 THROW_IO_ERROR(
_(
"Session file is missing the \"library_out\" section") );
351 std::vector<PCB_TRACK*>
locked;
353 while( !aBoard->
Tracks().empty() )
356 aBoard->
Tracks().pop_back();
359 locked.push_back( track );
371 aBoard->
Add( track );
380 for( COMPONENTS::iterator comp=components.begin(); comp!=components.end(); ++comp )
382 PLACES& places = comp->places;
383 for(
unsigned i=0; i<places.size(); ++i )
385 PLACE* place = &places[i];
400 wxASSERT( resolution );
405 if( place->
side == T_front )
418 else if( place->
side == T_back )
433 wxFAIL_MSG( wxT(
"DSN::PARSER did not catch an illegal side := 'back|front'") );
443 for( NET_OUTS::iterator net = net_outs.begin(); net!=net_outs.end(); ++net )
448 if( net->net_id.size() )
450 wxString netName =
FROM_UTF8( net->net_id.c_str() );
457 WIRES& wires = net->wires;
458 for(
unsigned i = 0; i<wires.size(); ++i )
460 WIRE* wire = &wires[i];
463 if( shape != T_path )
481 for(
unsigned pt=0; pt < path->points.size()-1; ++pt )
484 aBoard->
Add( track );
492 for(
unsigned i=0; i<wire_vias.size(); ++i )
497 if( net->net_id.size() )
499 wxString netName =
FROM_UTF8( net->net_id.c_str() );
527 int via_drill_default = netSettings->m_DefaultNetClass->GetViaDrill();
529 for(
unsigned v = 0; v < wire_via->
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.
virtual bool IsLocked() const
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
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.
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 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 give...
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.
void RecacheAllItems()
Rebuild GAL display lists.
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 ...
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.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
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
static double scale(int kicadDist)
Convert a distance from Pcbnew internal units to the reported Specctra DSN units in floating point fo...
boost::ptr_vector< PLACE > PLACES
boost::ptr_vector< WIRE_VIA > WIRE_VIAS
boost::ptr_vector< COMPONENT > COMPONENTS
#define UNDEFINED_DRILL_DIAMETER
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
A point in the SPECCTRA DSN coordinate system.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".