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 if( logFile->Load( wxFileName( aFile ),
m_reporter.get() ) )
372 int n_stages = dbgd->GetStageCount();
377 auto extents =
m_board->GetBoundingBox();
399 auto extents =
m_board->GetBoundingBox();
413 wxFileDialog dlg(
this,
"Select Log File",
m_mruPath, wxEmptyString,
415 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
417 if( dlg.ShowModal() != wxID_CANCEL )
419 wxString logPath = dlg.GetPath();
421 m_mruPath = wxFileName( logPath ).GetPath();
434 wxFileDialog dlg(
this,
"New log file",
m_mruPath, wxEmptyString,
436 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
438 if( dlg.ShowModal() != wxID_CANCEL )
443 wxASSERT_MSG( create_me.IsAbsolute(), wxS(
"wxFileDialog returned non-absolute path" ) );
514 int count = dbgd->GetStageCount();
542 int count = dbgd->GetStageCount();
562 for( wxTreeListItem item =
m_itemList->GetFirstItem(); item.IsOk();
570 bool checked =
m_itemList->GetCheckedState( item ) == wxCHK_CHECKED;
571 bool selected =
m_itemList->IsSelected( item );
584 wxExecute( aCommand );
616 if( ent->m_selected )
618 for(
auto sh : ent->m_shapes )
620 s +=
"// " + ent->m_name +
"\n " + sh->Format() +
"; \n";
629 if( wxTheClipboard->Open() )
633 wxTheClipboard->SetData(
new wxTextDataObject( s ) );
634 wxTheClipboard->Flush();
635 wxTheClipboard->Close();
642 wxVector<wxTreeListItem> selectedItems;
644 if(
m_itemList->GetSelections( selectedItems ) == 1 )
646 wxString filename =
m_itemList->GetItemText(selectedItems.back(), 2);
647 wxString line =
m_itemList->GetItemText(selectedItems.back(), 4);
650 if( !filename.empty() && !line.empty() )
656 case 0:
runCommand( wxString::Format(
"code --goto %s:%s", filepath, line ) );
return;
657 case 1:
runCommand( wxString::Format(
"start devenv /edit %s /command \"Gotoln %s\"", filepath, line ) );
return;
658 case 2:
runCommand( wxString::Format(
"clion --line %s %s", line, filepath ) );
return;
659 case 3:
runCommand( wxString::Format(
"emacsclient +%s %s", line, filepath ) );
return;
691 double angle = 180.0 / M_PI *
692 atan2( (
double) s.
B.
y - (
double) s.
A.
y,
693 (
double) s.
B.
x - (
double) s.
A.
x );
698 double angle_a = fabs( fmod( angle, 45.0 ) );
700 if( angle_a > 1.0 && angle_a < 44.0 )
711 std::set<PNS_DEBUG_SHAPE*> processed;
712 std::deque<PNS_DEBUG_SHAPE*> q;
716 while ( q.size() > 0 )
726 chld->m_filterMatch =
false;
735 cur->m_filterMatch = match;
738 if( processed.find(chld) == processed.end() )
741 processed.insert( chld );
747 printf(
"total: %d\n", total );
757 for(
int i = 0; i < depth * 2; i++ )
760 if( ent->
m_msg.length() )
761 printf(
"MSG: %s\n", ent->
m_msg.c_str() );
766 wxTreeListItem ritem;
771 if( ent->
m_msg.length() )
773 ritem =
m_itemList->AppendItem( item,
"Child" );
774 m_itemList->SetItemText( ritem, 0,
"Message" );
779 ritem =
m_itemList->AppendItem( item,
"Child" );
788 m_itemList->SetItemText( ritem, 0, wxString::Format(
"Shapes [%d verts]", n_verts ) );
793 wxString filename = wxFileNameFromPath( fullfilepath );
795 if( !filename.empty() )
798 m_itemList->SetItemText( ritem, 2, filename );
802 int totalVC = 0, totalVCSimplified = 0;
803 bool is45Degree =
true;
825 m_itemList->SetItemText( ritem, 5, wxString::Format(
"%d [%d]", totalVC, totalVCSimplified ) );
844 wxTreeListItem child = tree->GetFirstItem ();
846 while( child.IsOk() )
851 if( maxLevel < 0 || idata->m_level <= maxLevel )
852 tree->Expand ( child );
854 tree->Collapse ( child );
855 child = tree->GetNextItem( child );
861 wxTreeListItem child = tree->GetFirstItem ();
863 while( child.IsOk() )
865 tree->Collapse ( child );
866 child = tree->GetNextItem( child );
873 printf(
"UpdateDUmp %d\n", iter );
878 int count = dbgd->GetStageCount();
880 wxArrayString dumpStrings;
891 auto st = dbgd->GetStage( iter );
909 m_itemList->CheckItemRecursively( rootItem, wxCHK_UNCHECKED );
921 printf(
"DBG updatePnsPreviewItems: %zu items\n", entries.size() );
931 for(
auto& ent : entries )
933 if ( ent.m_isHideOp )
936 auto parent = ent.m_item->Parent();
940 view->Hide( parent );
946 pitem->
Update( ent.m_item );
969static BOARD* loadBoard(
const std::string& filename )
972 BOARD* brd =
nullptr;
976 brd = pi->LoadBoard( wxString( filename.c_str() ),
nullptr,
nullptr );
990int render_perftest_main_func(
int argc,
char* argv[] )
997 if( argc >= 2 && std::string( argv[1] ) ==
"-h" )
999 printf(
"PCB render performance test. Just renders a board without UI update overhead.\n" );
1005 printf(
"Expected parameters: board_file\n" );
1010 std::shared_ptr<BOARD> brd ( loadBoard( argv[1] ) );
1015 frame->SetBoard2( brd );
1023 "Renderer performance test",
1024 render_perftest_main_func,
1033 if( l_squared == 0 )
1040 else if( t > l_squared )
1053 double l_squared = d.
Dot(d);
1055 if( l_squared == 0 )
1062 else if( t > l_squared )
1065 double xp = t * d.
x / l_squared;
1066 double yp = t * d.
y / l_squared;
1071int ttt_main_func(
int argc,
char* argv[] )
1074 std::vector<VECTOR2I> pts;
1075 std::vector<SEG> segs;
1076 std::vector<VECTOR2D> rv;
1077 std::vector<VECTOR2I> rvi;
1083 for (
int i = 0; i < n ;i++)
1085 pts.push_back(
VECTOR2I(random()%100000000, random()%100000000));
1086 segs.push_back(
SEG(
VECTOR2I(random()%100000000, random()%100000000),
VECTOR2I(random()%100000000, random()%100000000) ) );
1090 for(
int i = 0; i < n ; i++)
1092 rvi[i] = NearestPointFixpt( segs[i], pts[i]);
1097 for(
int i = 0; i < n ; i++)
1099 rv[i] = NearestPointDbl( segs[i], pts[i]);
1109 "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
Class PNS_LOG_VIEWER_FRAME_BASE.
wxTreeListCtrl * m_itemList
wxSplitterWindow * m_mainSplitter
wxStaticText * m_algoStatus
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
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...
void Simplify(int aMaxError=0)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
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.
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
currently 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.