28 #include <wx/clipbrd.h> 47 #define TOM_EXTRA_DEBUG 83 snprintf( msg,
sizeof( msg ),
"%d", i );
98 aOvl->
Rectangle( lbl.m_bbox.GetOrigin(), lbl.m_bbox.GetEnd() );
99 aOvl->
BitmapText( lbl.m_msg, lbl.m_bbox.Centre(), 0.0 );
101 aOvl->
Line( lbl.m_target, nearest );
112 int bestDist = INT_MAX;
115 for(
int i = 0; i < 4; i++ )
119 if( dist < bestDist )
140 int bestDist = INT_MAX;
146 for(
int i = 0; i < 4; i++ )
156 for(
int j = 0; j < 4; j++ )
165 if( dist < bestDist )
183 while( iterLimit > 0 )
185 printf(
"Iter %d\n", iterLimit );
186 bool collisionsFound =
false;
188 for(
int i = 0; i <
m_labels.size(); i++ )
190 for(
int j = 0; j <
m_labels.size(); j++ )
198 bb_i.Inflate( 100000 );
199 bb_j.Inflate( 100000 );
205 collisionsFound =
true;
210 if( !collisionsFound )
234 bool aShowVertexNumbers )
238 if( aShowVertexNumbers)
291 auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
292 m_galPanel->GetView()->GetPainter()->GetSettings() );
371 bool isEnabled = ent->IsVisible();
372 bool isSelected =
false;
377 for(
auto& sh : ent->m_shapes )
380 int lineWidth = ent->m_width;
387 color.Brighten( 0.5 );
397 auto cir = static_cast<SHAPE_CIRCLE*>( sh );
398 m_overlay->Circle( cir->GetCenter(), cir->GetRadius() );
404 auto rect = static_cast<SHAPE_RECT*>( sh );
405 m_overlay->Rectangle( rect->GetPosition(), rect->GetPosition() + rect->GetSize() );
411 auto lc = static_cast<SHAPE_LINE_CHAIN*>( sh );
412 m_overlay->AnnotatedPolyline( *lc, ent->m_name, ent->m_hasLabels && isSelected );
437 BOARD* brd =
nullptr;
441 brd = pi->Load( wxString( filename.c_str() ),
nullptr,
nullptr );
463 auto dbgd =
m_env->GetDebugDecorator();
464 int n_stages = dbgd->GetStageCount();
469 auto extents =
m_board->GetBoundingBox();
490 auto extents =
m_board->GetBoundingBox();
547 auto dbgd =
m_env->GetDebugDecorator();
548 int count = dbgd->GetStageCount();
569 auto dbgd =
m_env->GetDebugDecorator();
570 int count = dbgd->GetStageCount();
589 for( wxTreeListItem item =
m_itemList->GetFirstItem(); item.IsOk();
593 static_cast<WX_SHAPE_TREE_ITEM_DATA*>(
m_itemList->GetItemData( item ) );
597 bool checked =
m_itemList->GetCheckedState( item ) == wxCHK_CHECKED;
598 bool selected =
m_itemList->IsSelected( item );
633 if( ent->m_selected )
635 for(
auto sh : ent->m_shapes )
637 s +=
"// " + ent->m_name +
"\n " + sh->Format() +
"; \n";
646 if( wxTheClipboard->Open() )
650 wxTheClipboard->SetData(
new wxTextDataObject( s ) );
651 wxTheClipboard->Flush();
652 wxTheClipboard->Close();
672 for(
int i = 0; i < depth * 2; i++ )
675 if( ent->
m_msg.length() )
676 printf(
"MSG: %s\n", ent->
m_msg.c_str() );
681 wxTreeListItem ritem;
683 printf(
"depth %d\n", depth );
685 if( ent->
m_msg.length() )
687 ritem =
m_itemList->AppendItem( item,
"Child" );
688 m_itemList->SetItemText( ritem, 0,
"Message" );
693 ritem =
m_itemList->AppendItem( item,
"Child" );
694 m_itemList->SetItemText( ritem, 0,
"Shapes" );
716 wxTreeListItem child = tree->GetFirstItem ();
718 while( child.IsOk() )
720 tree->Expand ( child );
721 child = tree->GetNextItem( child );
731 auto dbgd =
m_env->GetDebugDecorator();
732 int count = dbgd->GetStageCount();
734 wxArrayString dumpStrings;
745 auto st = dbgd->GetStage( iter );
750 m_itemList->CheckItemRecursively( rootItem, wxCHK_UNCHECKED );
765 if( argc >= 2 && std::string( argv[1] ) ==
"-h" )
767 printf(
"PNS Log (Re)player. Allows to step through the log written by the ROUTER_TOOL " 768 "in debug KiCad builds. " );
769 printf(
"Requires a board file with UUIDs and a matching log file. Both are written to " 770 "/tmp when you press '0' during routing." );
776 printf(
"Expected parameters: log_file.log board_file.dump\n" );
781 logFile->
Load( argv[1], argv[2] );
783 frame->SetLogFile( logFile );
805 if( argc >= 2 && std::string( argv[1] ) ==
"-h" )
807 printf(
"PCB render performance test. Just renders a board without UI update overhead.\n" );
813 printf(
"Expected parameters: board_file\n" );
818 std::shared_ptr<BOARD> brd (
loadBoard( argv[1] ) );
823 frame->SetBoard2( brd );
831 "Renderer performance test",
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
bool Load(const std::string &logName, const std::string boardName)
void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
std::shared_ptr< PNS_LOG_FILE > m_logFile
void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
wxSlider * m_rewindSlider
STAGE * GetStage(int index)
Class PNS_LOG_VIEWER_FRAME_BASE.
virtual ~PNS_LOG_VIEWER_FRAME()
void buildListTree(wxTreeListItem item, PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT *ent, int depth=0)
void SetBoard2(std::shared_ptr< BOARD > aBoard)
virtual void onBtnRewindRight(wxCommandEvent &event) override
const COLOR4D & GetStrokeColor() const
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT * m_item
void SetSize(const Vec &size)
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
double GetStartAngle() const
void Add(VECTOR2I target, std::string msg, COLOR4D color)
void createView(wxWindow *aParent, PCB_DRAW_PANEL_GAL::GAL_TYPE aGalType=PCB_DRAW_PANEL_GAL::GAL_TYPE_OPENGL)
int PointCount() const
Return the number of points (vertices) in this line chain.
VECTOR2D GetTextLineSize(const UTF8 &aText) const
Compute the X and Y size of a given text.
void SetIsStroke(bool aIsStrokeEnabled)
void Redraw(KIGFX::VIEW_OVERLAY *aOvl)
int GetStageCount() const
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
void Polyline(const SHAPE_LINE_CHAIN &aPolyLine)
bool Intersects(const BOX2< Vec > &aRect) const
VECTOR2I nearestBoxCorner(BOX2I b, VECTOR2I p)
void Line(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
virtual void onExit(wxCommandEvent &event) override
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
PNS_TEST_DEBUG_DECORATOR::STAGE * getCurrentStage()
void Arc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
#define ID_LIST_SHOW_NONE
VECTOR2< double > VECTOR2D
LABEL_MANAGER(KIGFX::GAL *aGal)
virtual void onRewindCountText(wxCommandEvent &event) override
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
void updateDumpPanel(int iter)
coord_type GetWidth() const
BOX2< Vec > & Normalize()
Ensure that the height ant width are positive.
bool Contains(const Vec &aPoint) const
virtual void onBtnRewindLeft(wxCommandEvent &event) override
virtual void createUserTools() override
PNS_LOG_VIEWER_OVERLAY(KIGFX::GAL *aGal)
wxLogTrace helper definitions.
void Arc(const SHAPE_ARC &arc)
int drawShapes(int argc, char *argv[])
void SetStrokeColor(const COLOR4D &aColor)
PNS_LOG_VIEWER_FRAME(wxFrame *frame)
VECTOR2I boxMtv(BOX2I b1, BOX2I b2)
static void expandAllChildren(wxTreeListCtrl *tree)
virtual void onReload(wxCommandEvent &event) override
A small class to help profiling.
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
void SetIsFill(bool aIsFillEnabled)
std::unique_ptr< LABEL_MANAGER > m_labelMgr
std::vector< DEBUG_ENT * > m_children
const Vec & GetPosition() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
int render_perftest_main_func(int argc, char *argv[])
void IterateTree(std::function< bool(DEBUG_ENT *)> visitor, int depth=0)
std::shared_ptr< PCB_DRAW_PANEL_GAL > m_galPanel
std::shared_ptr< BOARD > m_board
PNS::DEBUG_DECORATOR::SRC_LOCATION_INFO m_srcLoc
void SetHeight(coord_type val)
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > m_overlay
void SetLineWidth(double aLineWidth)
double DEG2RAD(double deg)
Information pertinent to a Pcbnew printed circuit board.
void AnnotatedPoint(const VECTOR2I p, int size, std::string name="", bool aShowVertexNumbers=false)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual void onListRightClick(wxMouseEvent &event)
std::shared_ptr< PNS_TEST_ENVIRONMENT > m_env
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
virtual void SetBoard(std::shared_ptr< BOARD > b)
wxTreeListCtrl * m_itemList
void SetOrigin(const Vec &pos)
double GetCentralAngle() const
coord_type GetHeight() const
virtual void onListSelect(wxCommandEvent &event)
void drawLoggedItems(int iter)
virtual void onRewindScroll(wxScrollEvent &event) override
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
int replay_main_func(int argc, char *argv[])
void AnnotatedPolyline(const SHAPE_LINE_CHAIN &aL, std::string name, bool aShowVertexNumbers=false)
static BOARD * loadBoard(const std::string &filename)
virtual void onListChecked(wxCommandEvent &event)
std::vector< LABEL > m_labels
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
VECTOR2I GetCenter() const
WX_SHAPE_TREE_ITEM_DATA(PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT *item)
void SetLogFile(PNS_LOG_FILE *aLog)
void SetWidth(coord_type val)
void Rectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Abstract interface for drawing on a 2D-surface.
A color representation with 4 components: red, green, blue, alpha.