30#include <wx/clipbrd.h> 
   69                                               bool aShowVertexNumbers )
 
   73        if( i == 0 && !aName.empty() )
 
   78        for( 
int j = 0; j < aPolyset.
HoleCount( i ); j++ )
 
 
   85                                                bool aShowVertexNumbers )
 
   92    if( aShowVertexNumbers )
 
 
  105    if( 
name.length() > 0 )
 
 
  152            m_galPanel->GetView()->GetPainter()->GetSettings() );
 
  159    double opacity = 0.5;
 
  166    settings->LoadDisplayOptions( opts );
 
  197    m_galPanel->GetViewControls()->EnableCursorWarping(
false);
 
  200        m_galPanel->GetView()->SetLayerVisible( layer, 
false );
 
 
  241    switch( aShape->
Type() )
 
  246        m_overlay->Circle( cir->GetCenter(), cir->GetRadius() );
 
  253        m_overlay->Line( seg->GetSeg().A, seg->GetSeg().B );
 
  259        auto rect = 
static_cast<SHAPE_RECT*
>( aShape );
 
  260        m_overlay->Rectangle( rect->GetPosition(), rect->GetPosition() + rect->GetSize() );
 
 
  292        bool isEnabled = ent->IsVisible();
 
  293        bool isSelected = ent->m_selected;
 
  296            isEnabled = ent->m_filterMatch;
 
  301        for( 
auto& sh : ent->m_shapes )
 
  304            int lineWidth = ent->m_width;
 
  311                color.Brighten( 0.5 );
 
  323                for( 
auto subshape : cmpnd->Shapes() )
 
 
  348    std::unique_ptr<PNS_LOG_FILE> logFile( 
new PNS_LOG_FILE );
 
  350    wxFileName logFn( aFile );
 
  351    logFn.MakeAbsolute();
 
  353    if( logFile->Load( logFn, 
m_reporter.get() ) )
 
 
  375    int  n_stages = dbgd->GetStageCount();
 
  380    auto extents = 
m_board->GetBoundingBox();
 
 
  402    auto extents = 
m_board->GetBoundingBox();
 
 
  416    wxFileDialog dlg( 
this, 
"Select Log File", 
m_mruPath, wxEmptyString,
 
  418                      wxFD_OPEN | wxFD_FILE_MUST_EXIST );
 
  420    if( dlg.ShowModal() != wxID_CANCEL )
 
  422        wxString logPath = dlg.GetPath();
 
  424        m_mruPath = wxFileName( logPath ).GetPath();
 
 
  437    wxFileDialog dlg( 
this, 
"New log file", 
m_mruPath, wxEmptyString,
 
  439                      wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
 
  441    if( dlg.ShowModal() != wxID_CANCEL )
 
  446        wxASSERT_MSG( create_me.IsAbsolute(), wxS( 
"wxFileDialog returned non-absolute path" ) );
 
 
  517    int  count = dbgd->GetStageCount();
 
 
  545    int  count = dbgd->GetStageCount();
 
 
  565    for( wxTreeListItem item = 
m_itemList->GetFirstItem(); item.IsOk();
 
  573            bool checked = 
m_itemList->GetCheckedState( item ) == wxCHK_CHECKED;
 
  574            bool selected = 
m_itemList->IsSelected( item );
 
 
  587    wxExecute( aCommand );
 
 
  619            if( ent->m_selected )
 
  621                for( 
auto sh : ent->m_shapes )
 
  623                    s += 
"// " + ent->m_name + 
"\n " + sh->Format() + 
"; \n";
 
  632        if( wxTheClipboard->Open() )
 
  636            wxTheClipboard->SetData( 
new wxTextDataObject( s ) );
 
  637            wxTheClipboard->Flush(); 
 
  638            wxTheClipboard->Close();
 
  645        wxVector<wxTreeListItem> selectedItems;
 
  647        if( 
m_itemList->GetSelections( selectedItems ) == 1 )
 
  649            wxString filename = 
m_itemList->GetItemText(selectedItems.back(), 2);
 
  650            wxString line = 
m_itemList->GetItemText(selectedItems.back(), 4);
 
  653            if( !filename.empty() && !line.empty() )
 
  659                    case 0: 
runCommand( wxString::Format( 
"code --goto %s:%s", filepath, line ) ); 
return;
 
  660                    case 1: 
runCommand( wxString::Format( 
"start devenv /edit %s /command \"Gotoln %s\"", filepath, line ) ); 
return; 
 
  661                    case 2: 
runCommand( wxString::Format( 
"clion --line %s %s", line, filepath ) ); 
return;
 
  662                    case 3: 
runCommand( wxString::Format( 
"emacsclient +%s %s", line, filepath ) ); 
return;
 
 
  694        double angle = 180.0 / 
M_PI *
 
  695                       atan2( (
double) s.
B.
y - (
double) s.
A.
y,
 
  696                              (
double) s.
B.
x - (
double) s.
A.
x );
 
  701        double angle_a = fabs( fmod( angle, 45.0 ) );
 
  703        if( angle_a > 1.0 && angle_a < 44.0 )
 
 
  714    std::set<PNS_DEBUG_SHAPE*> processed;
 
  715    std::deque<PNS_DEBUG_SHAPE*> q;
 
  719    while ( q.size() > 0 )
 
  729            chld->m_filterMatch = 
false;
 
  738                    cur->m_filterMatch = match;
 
  741            if( processed.find(chld) == processed.end() )
 
  744                processed.insert( chld );
 
  750    printf(
"total: %d\n", total );
 
 
  760    for( 
int i = 0; i < depth * 2; i++ )
 
  763    if( ent->
m_msg.length() )
 
  764        printf( 
"MSG: %s\n", ent->
m_msg.c_str() );
 
  769    wxTreeListItem ritem;
 
  774    if( ent->
m_msg.length() )
 
  776        ritem = 
m_itemList->AppendItem( item, 
"Child" );
 
  777        m_itemList->SetItemText( ritem, 0, 
"Message" );
 
  782        ritem = 
m_itemList->AppendItem( item, 
"Child" );
 
  791        m_itemList->SetItemText( ritem, 0, wxString::Format( 
"Shapes [%d verts]", n_verts ) );
 
  796    wxString filename = wxFileNameFromPath( fullfilepath );
 
  798    if( !filename.empty() )
 
  801    m_itemList->SetItemText( ritem, 2, filename );
 
  805    int  totalVC = 0, totalVCSimplified = 0;
 
  806    bool is45Degree = 
true;
 
  828        m_itemList->SetItemText( ritem, 5, wxString::Format( 
"%d [%d]", totalVC, totalVCSimplified ) );
 
 
  847    wxTreeListItem child = tree->GetFirstItem ();
 
  849    while( child.IsOk() )
 
  854        if( maxLevel < 0 || idata->m_level <= maxLevel )
 
  855            tree->Expand ( child );
 
  857            tree->Collapse ( child );
 
  858        child = tree->GetNextItem( child );
 
 
  864    wxTreeListItem child = tree->GetFirstItem ();
 
  866    while( child.IsOk() )
 
  868        tree->Collapse ( child );
 
  869        child = tree->GetNextItem( child );
 
 
  876    printf(
"UpdateDUmp %d\n", iter );
 
  881    int  count = dbgd->GetStageCount();
 
  883    wxArrayString dumpStrings;
 
  894    auto st = dbgd->GetStage( iter );
 
  912    m_itemList->CheckItemRecursively( rootItem, wxCHK_UNCHECKED );
 
 
  924    printf(
"DBG updatePnsPreviewItems: %zu items\n", entries.size() );
 
  934    for( 
auto& ent : entries )
 
  936        if ( ent.m_isHideOp )
 
  939            auto parent = ent.m_item->Parent();
 
  943                view->Hide( parent );
 
  949            pitem->
Update( ent.m_item );
 
 
  972static BOARD* loadBoard( 
const std::string& filename )
 
  975    BOARD*              brd = 
nullptr;
 
  979        brd = pi->LoadBoard( wxString( filename.c_str() ), 
nullptr, 
nullptr );
 
  993int render_perftest_main_func( 
int argc, 
char* argv[] )
 
 1000    if( argc >= 2 && std::string( argv[1] ) == 
"-h" )
 
 1002        printf( 
"PCB render performance test. Just renders a board without UI update overhead.\n" );
 
 1008        printf( 
"Expected parameters: board_file\n" );
 
 1013    std::shared_ptr<BOARD> brd ( loadBoard( argv[1] ) );
 
 1018    frame->SetBoard2( brd );
 
 1026        "Renderer performance test",
 
 1027        render_perftest_main_func,
 
 1036    if( l_squared == 0 )
 
 1043    else if( t > l_squared )
 
 1056    double l_squared = d.
Dot(d);
 
 1058    if( l_squared == 0 )
 
 1065    else if( t > l_squared )
 
 1068    double xp = t * d.
x / l_squared;
 
 1069    double yp = t * d.
y / l_squared;
 
 1074int ttt_main_func( 
int argc, 
char* argv[] )
 
 1077    std::vector<VECTOR2I> pts;
 
 1078    std::vector<SEG> segs;
 
 1079    std::vector<VECTOR2D> rv;
 
 1080    std::vector<VECTOR2I> rvi;
 
 1086    for (
int i = 0; i < n ;i++)
 
 1088        pts.push_back(
VECTOR2I(random()%100000000, random()%100000000));
 
 1089        segs.push_back(
SEG( 
VECTOR2I(random()%100000000, random()%100000000), 
VECTOR2I(random()%100000000, random()%100000000) ) );
 
 1093    for(
int i = 0; i < n ; i++)
 
 1095        rvi[i] = NearestPointFixpt( segs[i], pts[i]);
 
 1100    for(
int i = 0; i < n ; i++)
 
 1102        rv[i] = NearestPointDbl( segs[i], pts[i]);
 
 1112        "Renderer performance test",
 
Information pertinent to a Pcbnew printed circuit board.
 
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
 
constexpr void SetHeight(size_type val)
 
constexpr void SetOrigin(const Vec &pos)
 
constexpr size_type GetWidth() const
 
constexpr size_type GetHeight() const
 
constexpr void SetWidth(size_type val)
 
@ GAL_TYPE_OPENGL
OpenGL implementation.
 
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
 
A color representation with 4 components: red, green, blue, alpha.
 
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
 
Abstract interface for drawing on a 2D-surface.
 
PCB specific render settings.
 
Extend VIEW_ITEM by possibility of grouping items into a single object.
 
void SetLineWidth(double aLineWidth)
 
void Polyline(const SHAPE_LINE_CHAIN &aPolyLine)
 
const COLOR4D & GetStrokeColor() const
 
void Line(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 
void Arc(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle)
 
void SetStrokeColor(const COLOR4D &aColor)
 
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
 
double m_TrackOpacity
Opacity override for all tracks.
 
double m_ZoneOpacity
Opacity override for filled zone areas.
 
double m_PadOpacity
Opacity override for SMD pads and PTHs.
 
double m_ViaOpacity
Opacity override for all types of via.
 
ZONE_DISPLAY_MODE m_ZoneDisplayMode
 
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
 
std::shared_ptr< BOARD > m_board
 
std::shared_ptr< PCB_DRAW_PANEL_GAL > m_galPanel
 
void createView(wxWindow *aParent, PCB_DRAW_PANEL_GAL::GAL_TYPE aGalType=PCB_DRAW_PANEL_GAL::GAL_TYPE_OPENGL)
 
virtual void SetBoard(std::shared_ptr< BOARD > b)
 
std::vector< SHAPE * > m_shapes
 
void IterateTree(std::function< bool(PNS_DEBUG_SHAPE *)> visitor, int depth=0)
 
PNS_DEBUG_SHAPE * m_parent
 
PNS::DEBUG_DECORATOR::SRC_LOCATION_INFO m_srcLoc
 
std::vector< PNS_DEBUG_SHAPE * > m_children
 
wxTreeListCtrl * m_itemList
 
wxSplitterWindow * m_mainSplitter
 
wxStaticText * m_algoStatus
 
PNS_LOG_VIEWER_FRAME_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxT("P&S Log Viewer"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(1045, 574), long style=wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL)
 
wxTextCtrl * m_filterString
 
wxSlider * m_rewindSlider
 
wxTextCtrl * m_consoleText
 
std::shared_ptr< WX_TEXT_CTRL_REPORTER > m_reporter
 
std::shared_ptr< PNS_LOG_FILE > m_logFile
 
virtual void onListRightClick(wxMouseEvent &event)
 
std::shared_ptr< PNS_LOG_PLAYER > m_logPlayer
 
std::map< wxString, wxString > m_filenameToPathMap
 
void drawSimpleShape(SHAPE *aShape, bool aIsSelected, const std::string &aName)
 
virtual void onRewindCountText(wxCommandEvent &event) override
 
std::shared_ptr< KIGFX::VIEW_GROUP > m_previewItems
 
PNS_DEBUG_STAGE * getCurrentStage()
 
bool filterStringMatches(PNS_DEBUG_SHAPE *ent)
 
void SetBoard2(std::shared_ptr< BOARD > aBoard)
 
void updateDumpPanel(int iter)
 
virtual void createUserTools() override
 
virtual ~PNS_LOG_VIEWER_FRAME()
 
void buildListTree(wxTreeListItem item, PNS_DEBUG_SHAPE *ent, int depth=0)
 
virtual void onShowVerticesChecked(wxCommandEvent &event) override
 
void SetLogFile(PNS_LOG_FILE *aLog)
 
virtual void onShowThinLinesChecked(wxCommandEvent &event) override
 
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > m_overlay
 
void LoadLogFile(const wxString &aFile)
 
virtual void onListChecked(wxCommandEvent &event)
 
std::shared_ptr< PNS_VIEWER_IFACE > m_viewerIface
 
virtual void onListSelect(wxCommandEvent &event)
 
virtual void onSaveAs(wxCommandEvent &event) override
 
virtual void onRewindScroll(wxScrollEvent &event) override
 
REPORTER * GetConsoleReporter()
 
virtual void onShowRPIsChecked(wxCommandEvent &event) override
 
void updatePnsPreviewItems(int iter)
 
virtual void onBtnRewindRight(wxCommandEvent &event) override
 
virtual void onFilterText(wxCommandEvent &event) override
 
void drawLoggedItems(int iter)
 
PNS_LOG_VIEWER_FRAME(wxFrame *frame)
 
virtual void onOpen(wxCommandEvent &event) override
 
virtual void onBtnRewindLeft(wxCommandEvent &event) override
 
virtual void onExit(wxCommandEvent &event) override
 
void AnnotatedPoint(const VECTOR2I p, int size, std::string name="", bool aShowVertexNumbers=false)
 
void AnnotatedPolyset(const SHAPE_POLY_SET &aL, std::string name="", bool aShowVertexNumbers=false)
 
void AnnotatedPolyline(const SHAPE_LINE_CHAIN &aL, std::string name, bool aShowVertexNumbers=false)
 
PNS_LOG_VIEWER_OVERLAY(KIGFX::GAL *aGal)
 
std::unique_ptr< LABEL_MANAGER > m_labelMgr
 
void Arc(const SHAPE_ARC &arc)
 
std::vector< ENTRY > VIEW_ENTRIES
 
int GetStageCount() const
 
PNS_DEBUG_STAGE * GetStage(int index)
 
A small class to help profiling.
 
A pure virtual class used to derive REPORTER objects from.
 
void Update(const PNS::ITEM *aItem)
 
VECTOR2I::extended_type ecoord
 
int Length() const
Return the length (this).
 
EDA_ANGLE GetCentralAngle() const
Get the "central angle" of the arc - this is the angle at the point of the "pie slice".
 
int GetWidth() const override
 
EDA_ANGLE GetStartAngle() const
 
const VECTOR2I & GetCenter() const
 
SHAPE_TYPE Type() const
Return the type of the shape.
 
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.
 
void Simplify(int aTolerance=0)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
 
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 VECTOR2I & CLastPoint() const
Return the last point in the line chain.
 
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
 
bool IsArcSegment(size_t aSegment) const
 
Represent a set of closed polygons.
 
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
 
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
 
int OutlineCount() const
Return the number of outlines in the set.
 
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
 
An abstract shape on 2D plane.
 
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
 
constexpr extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
 
WX_SHAPE_TREE_ITEM_DATA(PNS_DEBUG_SHAPE *item, int level=0)
 
A wrapper for reporting to a wxTextCtrl object.
 
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
 
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
 
This file is part of the common library.
 
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
 
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
 
@ LAYER_SELECT_OVERLAY
Selected items overlay.
 
PCB_LAYER_ID
A quick note on layer IDs:
 
int drawShapes(int argc, char *argv[])
 
static bool isLine45Degree(const SHAPE_LINE_CHAIN *lc)
 
static void collapseAllChildren(wxTreeListCtrl *tree)
 
static void expandAllChildren(wxTreeListCtrl *tree, int maxLevel=-1)
 
void runCommand(const wxString &aCommand)
 
#define ID_LIST_DISPLAY_LINE
 
#define ID_LIST_SHOW_NONE
 
@ SH_RECT
axis-aligned rectangle
 
@ SH_LINE_CHAIN
line chain (polyline)
 
@ SH_COMPOUND
compound shape, consisting of multiple simple shapes
 
PNS_DEBUG_SHAPE * m_entries
 
wxLogTrace helper definitions.
 
#define KI_TRACE(aWhat,...)
 
T rescale(T aNumerator, T aValue, T aDenominator)
Scale a number (value) by rational (numerator/denominator).
 
VECTOR2< int32_t > VECTOR2I
 
VECTOR2< double > VECTOR2D
 
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
 
Definition of file extensions used in Kicad.