29#include <wx/filedlg.h> 
   52    return iu / 1e9 / 0.0254;
 
 
  112        return outLayers.none();
 
 
 
  136    virtual bool Run() 
override;
 
  176                m_reporter->Report( 
_( 
"File contains pad shapes that are not supported by the " 
  177                                       "Hyperlynx exporter (supported shapes are oval, rectangle, " 
  178                                       "rounded rectangle, and circle)." ),
 
  180                m_reporter->Report( 
_( 
"They have been exported as oval pads." ),
 
  188        snprintf( buf, 
sizeof( buf ), 
"%d, %.9f, %.9f, %.1f, M",
 
 
  212    std::map<BOARD_ITEM*, HYPERLYNX_PAD_STACK*> 
m_padMap;
 
  214    std::shared_ptr<FILE_OUTPUTFORMATTER>       
m_out;
 
 
  254    m_out->Print( 0, 
"{VERSION=2.14}\n" );
 
  255    m_out->Print( 0, 
"{UNITS=ENGLISH LENGTH}\n\n" );
 
 
  265    if( outLayers.none() )
 
  270    if( outLayers == layerMask )
 
  278            m_out->Print( 1, 
"(\"%s\", %s)\n",
 
  279                          (
const char*) 
m_board->GetLayerName( l ).c_str(),
 
  284    m_out->Print( 0, 
"}\n\n" );
 
 
  292    m_out->Print( 0, 
"{BOARD \"%s\"\n", (
const char*) 
m_board->GetFileName().c_str() );
 
  294    if( !
m_board->GetBoardPolygonOutlines( outlines ) )
 
  296        wxLogError( 
_( 
"Board outline is malformed. Run DRC for a full analysis." ) );
 
  307            m_out->Print( 1, 
"(PERIMETER_SEGMENT X1=%.9f Y1=%.9f X2=%.9f Y2=%.9f)\n",
 
  315    m_out->Print( 0, 
"}\n\n" );
 
 
  331    LSEQ layers = 
m_board->GetDesignSettings().GetEnabledLayers().CuStack();
 
  336    m_out->Print( 0, 
"{STACKUP\n" );
 
  344            layer_name = 
m_board->GetLayerName( item->GetBrdLayerId() );
 
  345            int plating_thickness = 0;
 
  346            double resistivity = 1.724e-8;  
 
  347            m_out->Print( 1, 
"(SIGNAL T=%g P=%g C=%g L=\"%.20s\" M=COPPER)\n",
 
  348                          iu2hyp( item->GetThickness( 0 ) ),
 
  349                          iu2hyp( plating_thickness ),
 
  355            if( item->GetSublayersCount() < 2 )
 
  357                m_out->Print( 1, 
"(DIELECTRIC T=%g C=%g L=\"DE_%.17s\" M=\"%.20s\")\n",
 
  358                              iu2hyp( item->GetThickness( 0 ) ),
 
  359                              item->GetEpsilonR( 0 ),
 
  361                              TO_UTF8( item->GetMaterial( 0 ) ) );
 
  363            else for( 
int idx = 0; idx < item->GetSublayersCount(); idx++ )
 
  365                m_out->Print( 1, 
"(DIELECTRIC T=%g C=%g L=\"DE%d_%.16s\" M=\"%.20s\")\n",
 
  366                              iu2hyp( item->GetThickness( idx ) ),
 
  367                              item->GetEpsilonR( idx ),
 
  370                              TO_UTF8( item->GetMaterial( idx ) ) );
 
  375    m_out->Print( 0, 
"}\n\n" );
 
 
  383    m_out->Print( 0, 
"{DEVICES\n" );
 
  387        wxString ref = footprint->GetReference();
 
  388        wxString layerName = 
m_board->GetLayerName( footprint->GetLayer() );
 
  391            ref = wxT( 
"EMPTY" );
 
  393        m_out->Print( 1, 
"(? REF=\"%s\" L=\"%s\")\n",
 
  394                      (
const char*) ref.c_str(),
 
  395                      (
const char*) layerName.c_str() );
 
  397    m_out->Print( 0, 
"}\n\n" );
 
 
  407        for( 
PAD* 
pad : footprint->Pads() )
 
 
  440                wxString ref = 
pad->GetParentFootprint()->GetReference();
 
  443                    ref = wxT( 
"EMPTY" );
 
  445                wxString padName = 
pad->GetNumber();
 
  447                if( padName.IsEmpty() )
 
  448                    padName = wxT( 
"1" );
 
  451                m_out->Print( 1, 
"(PIN X=%.10f Y=%.10f R=\"%s.%s\" P=%d)\n",
 
  454                              (
const char*) ref.c_str(),
 
  455                              (
const char*) padName.c_str(),
 
  456                              pstackIter->second->GetId() );
 
  465                m_out->Print( 1, 
"(VIA X=%.10f Y=%.10f P=%d)\n",
 
  468                              pstackIter->second->GetId() );
 
  473            const wxString layerName = 
m_board->GetLayerName( track->GetLayer() );
 
  475            m_out->Print( 1, 
"(SEG X1=%.10f Y1=%.10f X2=%.10f Y2=%.10f W=%.10f L=\"%s\")\n",
 
  476                          iu2hyp( track->GetStart().x ),
 
  477                          iu2hyp( -track->GetStart().y ),
 
  478                          iu2hyp( track->GetEnd().x ),
 
  479                          iu2hyp( -track->GetEnd().y ),
 
  480                          iu2hyp( track->GetWidth() ),
 
  481                          (
const char*) layerName.c_str() );
 
  485            const wxString layerName = 
m_board->GetLayerName( arc->GetLayer() );
 
  490                std::swap( start, 
end );
 
  492            m_out->Print( 1, 
"(ARC X1=%.10f Y1=%.10f X2=%.10f Y2=%.10f XC=%.10f YC=%.10f R=%.10f W=%.10f L=\"%s\")\n",
 
  497                          iu2hyp( arc->GetCenter().x ),
 
  498                          iu2hyp( -arc->GetCenter().y ),
 
  499                          iu2hyp( arc->GetRadius() ),
 
  500                          iu2hyp( arc->GetWidth() ),
 
  501                          (
const char*) layerName.c_str() );
 
  507                const wxString layerName   = 
m_board->GetLayerName( layer );
 
  517                    m_out->Print( 1, 
"{POLYGON T=POUR L=\"%s\" ID=%d X=%.10f Y=%.10f\n",
 
  518                                  (
const char*) layerName.c_str(),
 
  525                        m_out->Print( 2, 
"(LINE X=%.10f Y=%.10f)\n",
 
  531                    m_out->Print( 1, 
"}\n" );
 
  533                    for( 
int h = 0; h < fill.
HoleCount( i ); h++ )
 
  538                        m_out->Print( 1, 
"{POLYVOID ID=%d X=%.10f Y=%.10f\n",
 
  543                        for( 
int v = 0; v < holeShape.
PointCount(); v++ )
 
  545                            m_out->Print( 2, 
"(LINE X=%.10f Y=%.10f)\n",
 
  550                        m_out->Print( 2, 
"(LINE X=%.10f Y=%.10f)\n",
 
  553                        m_out->Print( 1, 
"}\n" );
 
 
  568    std::vector<BOARD_ITEM*> rv;
 
  576                if( item->GetNetCode() == netcode || ( netcode < 0 && item->GetNetCode() <= 0 ) )
 
  584        for( 
PAD* 
pad : footprint->Pads() )
 
  594            rv.push_back( item );
 
  600            rv.push_back( zone );
 
 
  613        int  netcode = netInfo->GetNetCode();
 
  614        bool isNullNet = netInfo->GetNetCode() <= 0 || netInfo->GetNetname().IsEmpty();
 
  621        if( netObjects.size() )
 
  623            m_out->Print( 0, 
"{NET=\"%s\"\n", (
const char*) netInfo->GetNetname().c_str() );
 
  625            m_out->Print( 0, 
"}\n\n" );
 
  635        m_out->Print( 0, 
"{NET=\"EmptyNet%d\"\n", idx );
 
  637        m_out->Print( 0, 
"}\n\n" );
 
 
  671    wxString    wildcard =  wxT( 
"*.hyp" );
 
  673    wxFileName  fn = 
board->GetFileName();
 
  675    fn.SetExt( wxT(
"hyp") );
 
  677    wxFileDialog dlg( 
m_frame, 
_( 
"Export Hyperlynx Layout" ), fn.GetPath(), fn.GetFullName(),
 
  678                      wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
 
  680    if( dlg.ShowModal() != wxID_OK )
 
  686    fn.SetExt( wxT( 
"hyp" ) );
 
 
@ BS_ITEM_TYPE_DIELECTRIC
 
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
 
int ExportHyperlynx(const TOOL_EVENT &aEvent)
 
void SetOutputFilename(const wxFileName &aPath)
 
void SetBoard(BOARD *aBoard)
 
wxFileName m_outputFilePath
 
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
 
Manage one layer needed to make a physical board.
 
Manage layers needed to make a physical board.
 
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
 
Information pertinent to a Pcbnew printed circuit board.
 
virtual bool Run() override
 
void writeSinglePadStack(HYPERLYNX_PAD_STACK &aStack)
 
const std::string formatPadShape(const HYPERLYNX_PAD_STACK &aStack)
 
std::vector< HYPERLYNX_PAD_STACK * > m_padStacks
 
std::map< BOARD_ITEM *, HYPERLYNX_PAD_STACK * > m_padMap
 
bool writeNetObjects(const std::vector< BOARD_ITEM * > &aObjects)
 
HYPERLYNX_PAD_STACK * addPadStack(HYPERLYNX_PAD_STACK stack)
 
std::shared_ptr< FILE_OUTPUTFORMATTER > m_out
 
const std::vector< BOARD_ITEM * > collectNetObjects(int netcode)
 
friend class HYPERLYNX_EXPORTER
 
HYPERLYNX_PAD_STACK(BOARD *aBoard, const PAD *aPad)
 
bool operator==(const HYPERLYNX_PAD_STACK &other) const
 
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
 
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
 
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
 
LSET is a set of PCB_LAYER_IDs.
 
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
 
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
 
static LSET AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
 
Handle the data for a net.
 
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
 
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
 
const VECTOR2I & GetDrillSize() const
 
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
 
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
 
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
 
int GetWidth() const override
 
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
 
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
 
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
 
int PointCount() const
Return the number of points (vertices) in this line chain.
 
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
 
int SegmentCount() const
Return the number of segments in this line chain.
 
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
 
Represent a set of closed polygons.
 
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
 
void Simplify()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
 
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
 
int OutlineCount() const
Return the number of outlines in the set.
 
SHAPE_POLY_SET CloneDropTriangulation() const
 
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
 
Handle a list of polygons defining a copper zone.
 
static double iu2hyp(double iu)
 
PCB_LAYER_ID
A quick note on layer IDs:
 
This file contains miscellaneous commonly used macros and functions.
 
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
 
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
 
@ PTH
Plated through hole pad.
 
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
 
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
 
Casted dyn_cast(From aObject)
A lightweight dynamic downcast.
 
VECTOR2< int32_t > VECTOR2I