31#include <wx/clipbrd.h>
71 bool aShowVertexNumbers )
75 if( i == 0 && !aName.empty() )
80 for(
int j = 0; j < aPolyset.
HoleCount( i ); j++ )
87 bool aShowVertexNumbers )
94 if( aShowVertexNumbers )
107 if(
name.length() > 0 )
154 m_galPanel->GetView()->GetPainter()->GetSettings() );
161 double opacity = 0.5;
168 settings->LoadDisplayOptions( opts );
199 m_galPanel->GetViewControls()->EnableCursorWarping(
false);
202 m_galPanel->GetView()->SetLayerVisible( layer,
false );
243 switch( aShape->
Type() )
248 m_overlay->Circle( cir->GetCenter(), cir->GetRadius() );
255 m_overlay->Line( seg->GetSeg().A, seg->GetSeg().B );
261 auto rect =
static_cast<SHAPE_RECT*
>( aShape );
262 m_overlay->Rectangle( rect->GetPosition(), rect->GetPosition() + rect->GetSize() );
294 bool isEnabled = ent->IsVisible();
295 bool isSelected = ent->m_selected;
298 isEnabled = ent->m_filterMatch;
303 for(
auto& sh : ent->m_shapes )
306 int lineWidth = ent->m_width;
325 for(
auto subshape : cmpnd->Shapes() )
350 std::unique_ptr<PNS_LOG_FILE> logFile(
new PNS_LOG_FILE );
352 wxFileName logFn( aFile );
353 logFn.MakeAbsolute();
355 if( logFile->Load( logFn,
m_reporter.get() ) )
377 int n_stages = dbgd->GetStageCount();
382 auto extents =
m_board->GetBoundingBox();
404 auto extents =
m_board->GetBoundingBox();
418 wxFileDialog dlg(
this,
"Select Log File",
m_mruPath, wxEmptyString,
420 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
424 if( dlg.ShowModal() != wxID_CANCEL )
426 wxString logPath = dlg.GetPath();
428 m_mruPath = wxFileName( logPath ).GetPath();
441 wxFileDialog dlg(
this,
"New log file",
m_mruPath, wxEmptyString,
443 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
447 if( dlg.ShowModal() != wxID_CANCEL )
452 wxASSERT_MSG( create_me.IsAbsolute(), wxS(
"wxFileDialog returned non-absolute path" ) );
523 int count = dbgd->GetStageCount();
551 int count = dbgd->GetStageCount();
571 for( wxTreeListItem item =
m_itemList->GetFirstItem(); item.IsOk();
579 bool checked =
m_itemList->GetCheckedState( item ) == wxCHK_CHECKED;
580 bool selected =
m_itemList->IsSelected( item );
593 wxExecute( aCommand );
625 if( ent->m_selected )
627 for(
auto sh : ent->m_shapes )
629 s +=
"// " + ent->m_name +
"\n " + sh->Format() +
"; \n";
638 if( wxTheClipboard->Open() )
642 wxTheClipboard->SetData(
new wxTextDataObject( s ) );
643 wxTheClipboard->Flush();
644 wxTheClipboard->Close();
651 wxVector<wxTreeListItem> selectedItems;
653 if(
m_itemList->GetSelections( selectedItems ) == 1 )
655 wxString filename =
m_itemList->GetItemText(selectedItems.back(), 2);
656 wxString line =
m_itemList->GetItemText(selectedItems.back(), 4);
659 if( !filename.empty() && !line.empty() )
665 case 0:
runCommand( wxString::Format(
"code --goto %s:%s", filepath, line ) );
return;
666 case 1:
runCommand( wxString::Format(
"start devenv /edit %s /command \"Gotoln %s\"", filepath, line ) );
return;
667 case 2:
runCommand( wxString::Format(
"clion --line %s %s", line, filepath ) );
return;
668 case 3:
runCommand( wxString::Format(
"emacsclient +%s %s", line, filepath ) );
return;
700 double angle = 180.0 /
M_PI *
701 atan2( (
double) s.
B.
y - (
double) s.
A.
y,
702 (
double) s.
B.
x - (
double) s.
A.
x );
707 double angle_a = fabs( fmod( angle, 45.0 ) );
709 if( angle_a > 1.0 && angle_a < 44.0 )
720 std::set<PNS_DEBUG_SHAPE*> processed;
721 std::deque<PNS_DEBUG_SHAPE*> q;
725 while ( q.size() > 0 )
731 for (
auto chld :
top->m_children )
735 chld->m_filterMatch =
false;
744 cur->m_filterMatch = match;
747 if( processed.find(chld) == processed.end() )
750 processed.insert( chld );
756 printf(
"total: %d\n", total );
766 for(
int i = 0; i < depth * 2; i++ )
769 if( ent->
m_msg.length() )
770 printf(
"MSG: %s\n", ent->
m_msg.c_str() );
775 wxTreeListItem ritem;
780 if( ent->
m_msg.length() )
782 ritem =
m_itemList->AppendItem( item,
"Child" );
783 m_itemList->SetItemText( ritem, 0,
"Message" );
788 ritem =
m_itemList->AppendItem( item,
"Child" );
797 m_itemList->SetItemText( ritem, 0, wxString::Format(
"Shapes [%d verts]", n_verts ) );
802 wxString filename = wxFileNameFromPath( fullfilepath );
804 if( !filename.empty() )
807 m_itemList->SetItemText( ritem, 2, filename );
811 int totalVC = 0, totalVCSimplified = 0;
812 bool is45Degree =
true;
834 m_itemList->SetItemText( ritem, 5, wxString::Format(
"%d [%d]", totalVC, totalVCSimplified ) );
853 wxTreeListItem child = tree->GetFirstItem ();
855 while( child.IsOk() )
860 if( maxLevel < 0 || idata->m_level <= maxLevel )
861 tree->Expand ( child );
863 tree->Collapse ( child );
864 child = tree->GetNextItem( child );
870 wxTreeListItem child = tree->GetFirstItem ();
872 while( child.IsOk() )
874 tree->Collapse ( child );
875 child = tree->GetNextItem( child );
882 printf(
"UpdateDUmp %d\n", iter );
887 int count = dbgd->GetStageCount();
889 wxArrayString dumpStrings;
900 auto st = dbgd->GetStage( iter );
918 m_itemList->CheckItemRecursively( rootItem, wxCHK_UNCHECKED );
930 printf(
"DBG updatePnsPreviewItems: %zu items\n", entries.size() );
940 for(
auto& ent : entries )
942 if ( ent.m_isHideOp )
945 auto parent = ent.m_item->Parent();
949 view->Hide( parent );
955 pitem->
Update( ent.m_item );
978static BOARD* loadBoard(
const std::string& filename )
981 BOARD* brd =
nullptr;
985 brd = pi->LoadBoard( wxString( filename.c_str() ),
nullptr,
nullptr );
999int render_perftest_main_func(
int argc,
char* argv[] )
1006 if( argc >= 2 && std::string( argv[1] ) ==
"-h" )
1008 printf(
"PCB render performance test. Just renders a board without UI update overhead.\n" );
1014 printf(
"Expected parameters: board_file\n" );
1019 std::shared_ptr<BOARD> brd ( loadBoard( argv[1] ) );
1024 frame->SetBoard2( brd );
1032 "Renderer performance test",
1033 render_perftest_main_func,
1042 if( l_squared == 0 )
1049 else if( t > l_squared )
1062 double l_squared = d.
Dot(d);
1064 if( l_squared == 0 )
1071 else if( t > l_squared )
1074 double xp = t * d.
x / l_squared;
1075 double yp = t * d.
y / l_squared;
1080int ttt_main_func(
int argc,
char* argv[] )
1083 std::vector<VECTOR2I> pts;
1084 std::vector<SEG> segs;
1085 std::vector<VECTOR2D> rv;
1086 std::vector<VECTOR2I> rvi;
1092 for (
int i = 0; i < n ;i++)
1094 pts.push_back(
VECTOR2I(random()%100000000, random()%100000000));
1095 segs.push_back(
SEG(
VECTOR2I(random()%100000000, random()%100000000),
VECTOR2I(random()%100000000, random()%100000000) ) );
1099 for(
int i = 0; i < n ; i++)
1101 rvi[i] = NearestPointFixpt( segs[i], pts[i]);
1106 for(
int i = 0; i < n ; i++)
1108 rv[i] = NearestPointDbl( segs[i], pts[i]);
1118 "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.
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.
#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.