77 wxString msg =
_(
"Board may be corrupted, do not save it.\n Fix problem and try again" );
79 wxString extra = ioe.
What();
96 for(
auto track :
GetBoard()->Tracks() )
100 SetStatusText( wxString(
_(
"Session file imported and merged OK." ) ) );
120 double resValue = aResolution->
GetValue();
126 case T_inch: factor = 25.4e6;
break;
127 case T_mil: factor = 25.4e3;
break;
128 case T_cm: factor = 1e7;
break;
129 case T_mm: factor = 1e6;
break;
130 case T_um: factor = 1e3;
break;
148 -
scale( aPoint.
y, aResolution ) );
160 THROW_IO_ERROR( wxString::Format(
_(
"Session file uses invalid layer id '%s'." ),
185 int aViaDrillDefault )
189 int shapeCount = aPadstack->
Length();
190 int drill_diam_iu = -1;
198 if( drillStartNdx != -1 )
203 if( drillEndNdx != -1 )
206 drillStartNdx, drillEndNdx-drillStartNdx );
208 double drill_um = strtod( diam_txt.c_str(), 0 );
212 if( drill_diam_iu == aViaDrillDefault )
217 if( shapeCount == 0 )
221 else if( shapeCount == 1 )
223 shape = (
SHAPE*) (*aPadstack)[0];
226 if( type != T_circle )
229 GetTokenString( type ) ) );
237 via->SetDrill( drill_diam_iu );
238 via->SetViaType( VIATYPE::THROUGH );
239 via->SetWidth( viaDiam );
242 else if( shapeCount == copperLayerCount )
244 shape = (
SHAPE*) (*aPadstack)[0];
247 if( type != T_circle )
250 GetTokenString( type ) ) );
258 via->SetDrill( drill_diam_iu );
259 via->SetViaType( VIATYPE::THROUGH );
260 via->SetWidth( viaDiam );
265 int topLayerNdx = -1;
266 int botLayerNdx = INT_MAX;
270 for(
int i=0; i<shapeCount; ++i )
272 shape = (
SHAPE*) (*aPadstack)[i];
275 if( type != T_circle )
278 GetTokenString( type ) ) );
287 THROW_IO_ERROR( wxString::Format(
_(
"Session file uses invalid layer id '%s'" ),
291 if( layerNdx > topLayerNdx )
292 topLayerNdx = layerNdx;
294 if( layerNdx < botLayerNdx )
295 botLayerNdx = layerNdx;
303 via->SetDrill( drill_diam_iu );
305 if( ( topLayerNdx == 0 && botLayerNdx == 1 )
306 || ( topLayerNdx == copperLayerCount-2 && botLayerNdx == copperLayerCount-1 ) )
308 via->SetViaType( VIATYPE::MICROVIA );
312 via->SetViaType( VIATYPE::BLIND_BURIED );
315 via->SetWidth( viaDiam );
321 via->SetNetCode( aNetCode );
329 via->SetLocked(
true );
343 THROW_IO_ERROR(
_(
"Session file is missing the \"session\" section") );
349 THROW_IO_ERROR(
_(
"Session file is missing the \"library_out\" section") );
352 std::vector<PCB_TRACK*>
locked;
354 while( !aBoard->
Tracks().empty() )
357 aBoard->
Tracks().pop_back();
361 locked.push_back( track );
366 group->RemoveItem( track );
379 aBoard->
Add( track );
388 for( COMPONENTS::iterator comp=components.begin(); comp!=components.end(); ++comp )
390 PLACES& places = comp->m_places;
391 for(
unsigned i=0; i<places.size(); ++i )
393 PLACE* place = &places[i];
408 wxASSERT( resolution );
413 if( place->
m_side == T_front )
426 else if( place->
m_side == T_back )
441 wxFAIL_MSG( wxT(
"DSN::PARSER did not catch an illegal side := 'back|front'") );
451 for( NET_OUTS::iterator net = net_outs.begin(); net!=net_outs.end(); ++net )
456 if( net->net_id.size() )
458 wxString netName =
From_UTF8( net->net_id.c_str() );
465 WIRES& wires = net->wires;
466 for(
unsigned i = 0; i<wires.size(); ++i )
468 WIRE* wire = &wires[i];
471 if( shape != T_path )
489 for(
unsigned pt=0; pt < path->points.size()-1; ++pt )
492 aBoard->
Add( track );
500 for(
unsigned i=0; i<wire_vias.size(); ++i )
505 if( net->net_id.size() )
507 wxString netName =
From_UTF8( net->net_id.c_str() );
529 THROW_IO_ERROR( wxString::Format(
_(
"A wire_via refers to missing padstack '%s'." ),
535 int via_drill_default = netSettings->m_DefaultNetClass->GetViaDrill();
537 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)
PCB_GROUP * GetParentGroup() const
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.
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.
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 ...
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
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.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".