27#include <wx/clipbrd.h>
67 bool aShowVertexNumbers )
71 if( i == 0 && !aName.empty() )
76 for(
int j = 0; j < aPolyset.
HoleCount( i ); j++ )
83 bool aShowVertexNumbers )
90 if( aShowVertexNumbers )
103 if(
name.length() > 0 )
150 m_galPanel->GetView()->GetPainter()->GetSettings() );
157 double opacity = 0.5;
164 settings->LoadDisplayOptions( opts );
195 m_galPanel->GetViewControls()->EnableCursorWarping(
false);
198 m_galPanel->GetView()->SetLayerVisible( layer,
false );
239 switch( aShape->
Type() )
244 m_overlay->Circle( cir->GetCenter(), cir->GetRadius() );
251 m_overlay->Line( seg->GetSeg().A, seg->GetSeg().B );
257 auto rect =
static_cast<SHAPE_RECT*
>( aShape );
258 m_overlay->Rectangle( rect->GetPosition(), rect->GetPosition() + rect->GetSize() );
290 bool isEnabled = ent->IsVisible();
291 bool isSelected = ent->m_selected;
294 isEnabled = ent->m_filterMatch;
299 for(
auto& sh : ent->m_shapes )
302 int lineWidth = ent->m_width;
321 for(
auto subshape : cmpnd->Shapes() )
346 std::unique_ptr<PNS_LOG_FILE> logFile(
new PNS_LOG_FILE );
348 wxFileName logFn( aFile );
349 logFn.MakeAbsolute();
351 if( logFile->Load( logFn,
m_reporter.get() ) )
376 int n_stages = dbgd->GetStageCount();
381 auto extents =
m_board->GetBoundingBox();
403 auto extents =
m_board->GetBoundingBox();
417 wxFileDialog dlg(
this,
"Select Log File",
m_mruPath, wxEmptyString,
419 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
423 if( dlg.ShowModal() != wxID_CANCEL )
425 wxString logPath = dlg.GetPath();
427 m_mruPath = wxFileName( logPath ).GetPath();
440 wxFileDialog dlg(
this,
"New log file",
m_mruPath, wxEmptyString,
442 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
446 if( dlg.ShowModal() != wxID_CANCEL )
451 wxASSERT_MSG( create_me.IsAbsolute(), wxS(
"wxFileDialog returned non-absolute path" ) );
453 int option =
SelectSingleOption(
this,
_(
"Select test case type" ),
_(
"Select test case type" ),
454 {
_(
"Testcase (strict geometry)" ),
_(
"Testcase (connectivity only)" ),
455 _(
"Testcase (expected failure)" ),
_(
"Known bug" ) } );
530 int count = dbgd->GetStageCount();
558 int count = dbgd->GetStageCount();
578 for( wxTreeListItem item =
m_itemList->GetFirstItem(); item.IsOk();
586 bool checked =
m_itemList->GetCheckedState( item ) == wxCHK_CHECKED;
587 bool selected =
m_itemList->IsSelected( item );
600 wxExecute( aCommand );
632 if( ent->m_selected )
634 for(
auto sh : ent->m_shapes )
636 s +=
"// " + ent->m_name +
"\n " + sh->Format() +
"; \n";
645 if( wxTheClipboard->Open() )
649 wxTheClipboard->SetData(
new wxTextDataObject( s ) );
650 wxTheClipboard->Flush();
651 wxTheClipboard->Close();
658 wxVector<wxTreeListItem> selectedItems;
660 if(
m_itemList->GetSelections( selectedItems ) == 1 )
662 wxString filename =
m_itemList->GetItemText(selectedItems.back(), 2);
663 wxString line =
m_itemList->GetItemText(selectedItems.back(), 4);
666 if( !filename.empty() && !line.empty() )
672 case 0:
runCommand( wxString::Format(
"code --goto %s:%s", filepath, line ) );
return;
673 case 1:
runCommand( wxString::Format(
"start devenv /edit %s /command \"Gotoln %s\"", filepath, line ) );
return;
674 case 2:
runCommand( wxString::Format(
"clion --line %s %s", line, filepath ) );
return;
675 case 3:
runCommand( wxString::Format(
"emacsclient +%s %s", line, filepath ) );
return;
707 double angle = 180.0 /
M_PI *
708 atan2( (
double) s.
B.
y - (
double) s.
A.
y,
709 (
double) s.
B.
x - (
double) s.
A.
x );
714 double angle_a = fabs( fmod( angle, 45.0 ) );
716 if( angle_a > 1.0 && angle_a < 44.0 )
727 std::set<PNS_DEBUG_SHAPE*> processed;
728 std::deque<PNS_DEBUG_SHAPE*> q;
732 while ( q.size() > 0 )
738 for (
auto chld :
top->m_children )
742 chld->m_filterMatch =
false;
751 cur->m_filterMatch = match;
754 if( processed.find(chld) == processed.end() )
757 processed.insert( chld );
763 printf(
"total: %d\n", total );
773 for(
int i = 0; i < depth * 2; i++ )
776 if( ent->
m_msg.length() )
777 printf(
"MSG: %s\n", ent->
m_msg.c_str() );
782 wxTreeListItem ritem;
787 if( ent->
m_msg.length() )
789 ritem =
m_itemList->AppendItem( item,
"Child" );
790 m_itemList->SetItemText( ritem, 0,
"Message" );
795 ritem =
m_itemList->AppendItem( item,
"Child" );
804 m_itemList->SetItemText( ritem, 0, wxString::Format(
"Shapes [%d verts]", n_verts ) );
809 wxString filename = wxFileNameFromPath( fullfilepath );
811 if( !filename.empty() )
814 m_itemList->SetItemText( ritem, 2, filename );
818 int totalVC = 0, totalVCSimplified = 0;
819 bool is45Degree =
true;
841 m_itemList->SetItemText( ritem, 5, wxString::Format(
"%d [%d]", totalVC, totalVCSimplified ) );
860 wxTreeListItem child = tree->GetFirstItem ();
862 while( child.IsOk() )
867 if( maxLevel < 0 || idata->m_level <= maxLevel )
868 tree->Expand ( child );
870 tree->Collapse ( child );
871 child = tree->GetNextItem( child );
877 wxTreeListItem child = tree->GetFirstItem ();
879 while( child.IsOk() )
881 tree->Collapse ( child );
882 child = tree->GetNextItem( child );
889 printf(
"UpdateDUmp %d\n", iter );
894 int count = dbgd->GetStageCount();
896 wxArrayString dumpStrings;
907 auto st = dbgd->GetStage( iter );
925 m_itemList->CheckItemRecursively( rootItem, wxCHK_UNCHECKED );
937 printf(
"DBG updatePnsPreviewItems: %zu items\n", entries.size() );
947 for(
auto& ent : entries )
949 if ( ent.m_isHideOp )
952 auto parent = ent.m_item->Parent();
956 view->Hide( parent );
962 pitem->
Update( ent.m_item );
985static BOARD* loadBoard(
const std::string& filename )
988 BOARD* brd =
nullptr;
992 brd = pi->LoadBoard( wxString( filename.c_str() ),
nullptr,
nullptr );
1006int render_perftest_main_func(
int argc,
char* argv[] )
1013 if( argc >= 2 && std::string( argv[1] ) ==
"-h" )
1015 printf(
"PCB render performance test. Just renders a board without UI update overhead.\n" );
1021 printf(
"Expected parameters: board_file\n" );
1026 std::shared_ptr<BOARD> brd ( loadBoard( argv[1] ) );
1031 frame->SetBoard2( brd );
1039 "Renderer performance test",
1040 render_perftest_main_func,
1049 if( l_squared == 0 )
1056 else if( t > l_squared )
1069 double l_squared = d.
Dot(d);
1071 if( l_squared == 0 )
1078 else if( t > l_squared )
1081 double xp = t * d.
x / l_squared;
1082 double yp = t * d.
y / l_squared;
1087int ttt_main_func(
int argc,
char* argv[] )
1090 std::vector<VECTOR2I> pts;
1091 std::vector<SEG> segs;
1092 std::vector<VECTOR2D> rv;
1093 std::vector<VECTOR2I> rvi;
1099 for (
int i = 0; i < n ;i++)
1101 pts.push_back(
VECTOR2I(random()%100000000, random()%100000000));
1102 segs.push_back(
SEG(
VECTOR2I(random()%100000000, random()%100000000),
VECTOR2I(random()%100000000, random()%100000000) ) );
1106 for(
int i = 0; i < n ; i++)
1108 rvi[i] = NearestPointFixpt( segs[i], pts[i]);
1113 for(
int i = 0; i < n ; i++)
1115 rv[i] = NearestPointDbl( segs[i], pts[i]);
1125 "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.
COLOR4D & Brighten(double aFactor)
Makes the color brighter by a given factor.
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.
int SelectSingleOption(wxWindow *aParent, const wxString &aTitle, const wxString &aMessage, const wxArrayString &aOptions)
Display a dialog with radioboxes asking the user to select an option.
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
KIBIS top(path, &reporter)
wxLogTrace helper definitions.
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.