29#include <wx/clipbrd.h>
66 bool aShowVertexNumbers )
73 if( aShowVertexNumbers )
86 if(
name.length() > 0 )
130 m_galPanel->GetView()->GetPainter()->GetSettings() );
137 double opacity = 0.5;
144 settings->LoadDisplayOptions( opts );
174 m_galPanel->GetViewControls()->EnableCursorWarping(
false);
212 switch( aShape->
Type() )
217 m_overlay->Circle( cir->GetCenter(), cir->GetRadius() );
224 m_overlay->Line( seg->GetSeg().A, seg->GetSeg().B );
230 auto rect =
static_cast<SHAPE_RECT*
>( aShape );
231 m_overlay->Rectangle( rect->GetPosition(), rect->GetPosition() + rect->GetSize() );
262 bool isEnabled = ent->IsVisible();
263 bool isSelected = ent->m_selected;
266 isEnabled = ent->m_filterMatch;
271 for(
auto& sh : ent->m_shapes )
274 int lineWidth = ent->m_width;
281 color.Brighten( 0.5 );
293 for(
auto subshape : cmpnd->Shapes() )
326 int n_stages = dbgd->GetStageCount();
331 auto extents =
m_board->GetBoundingBox();
353 auto extents =
m_board->GetBoundingBox();
430 int count = dbgd->GetStageCount();
457 int count = dbgd->GetStageCount();
477 for( wxTreeListItem item =
m_itemList->GetFirstItem(); item.IsOk();
485 bool checked =
m_itemList->GetCheckedState( item ) == wxCHK_CHECKED;
486 bool selected =
m_itemList->IsSelected( item );
521 if( ent->m_selected )
523 for(
auto sh : ent->m_shapes )
525 s +=
"// " + ent->m_name +
"\n " + sh->Format() +
"; \n";
534 if( wxTheClipboard->Open() )
538 wxTheClipboard->SetData(
new wxTextDataObject( s ) );
539 wxTheClipboard->Flush();
540 wxTheClipboard->Close();
569 double angle = 180.0 / M_PI *
570 atan2( (
double) s.
B.
y - (
double) s.
A.
y,
571 (
double) s.
B.
x - (
double) s.
A.
x );
576 double angle_a = fabs( fmod( angle, 45.0 ) );
578 if( angle_a > 1.0 && angle_a < 44.0 )
589 std::set<PNS_DEBUG_SHAPE*> processed;
590 std::deque<PNS_DEBUG_SHAPE*> q;
594 while ( q.size() > 0 )
604 chld->m_filterMatch =
false;
613 cur->m_filterMatch = match;
616 if( processed.find(chld) == processed.end() )
619 processed.insert( chld );
625 printf(
"total: %d\n", total );
635 for(
int i = 0; i < depth * 2; i++ )
638 if( ent->
m_msg.length() )
639 printf(
"MSG: %s\n", ent->
m_msg.c_str() );
644 wxTreeListItem ritem;
649 if( ent->
m_msg.length() )
651 ritem =
m_itemList->AppendItem( item,
"Child" );
652 m_itemList->SetItemText( ritem, 0,
"Message" );
657 ritem =
m_itemList->AppendItem( item,
"Child" );
666 m_itemList->SetItemText( ritem, 0, wxString::Format(
"Shapes [%d verts]", n_verts ) );
674 int totalVC = 0, totalVCSimplified = 0;
675 bool is45Degree =
true;
697 m_itemList->SetItemText( ritem, 5, wxString::Format(
"%d [%d]", totalVC, totalVCSimplified ) );
716 wxTreeListItem child = tree->GetFirstItem ();
718 while( child.IsOk() )
723 if( maxLevel < 0 || idata->m_level <= maxLevel )
724 tree->Expand ( child );
726 tree->Collapse ( child );
727 child = tree->GetNextItem( child );
733 wxTreeListItem child = tree->GetFirstItem ();
735 while( child.IsOk() )
737 tree->Collapse ( child );
738 child = tree->GetNextItem( child );
745 printf(
"UpdateDUmp %d\n", iter );
750 int count = dbgd->GetStageCount();
752 wxArrayString dumpStrings;
763 auto st = dbgd->GetStage( iter );
781 m_itemList->CheckItemRecursively( rootItem, wxCHK_UNCHECKED );
793 printf(
"DBG updatePnsPreviewItems: %zu items\n", entries.size() );
803 for(
auto& ent : entries )
808 auto parent = ent.item->Parent();
812 view->Hide( parent );
818 pitem->
Update( ent.item );
835static BOARD* loadBoard(
const std::string& filename )
838 BOARD* brd =
nullptr;
842 brd = pi->Load( wxString( filename.c_str() ),
nullptr,
nullptr );
856int render_perftest_main_func(
int argc,
char* argv[] )
863 if( argc >= 2 && std::string( argv[1] ) ==
"-h" )
865 printf(
"PCB render performance test. Just renders a board without UI update overhead.\n" );
871 printf(
"Expected parameters: board_file\n" );
876 std::shared_ptr<BOARD> brd ( loadBoard( argv[1] ) );
881 frame->SetBoard2( brd );
889 "Renderer performance test",
890 render_perftest_main_func,
906 else if( t > l_squared )
919 double l_squared = d.
Dot(d);
928 else if( t > l_squared )
931 double xp = t * d.
x / l_squared;
932 double yp = t * d.
y / l_squared;
937int ttt_main_func(
int argc,
char* argv[] )
940 std::vector<VECTOR2I> pts;
941 std::vector<SEG> segs;
942 std::vector<VECTOR2D> rv;
943 std::vector<VECTOR2I> rvi;
949 for (
int i = 0; i < n ;i++)
951 pts.push_back(
VECTOR2I(random()%100000000, random()%100000000));
952 segs.push_back(
SEG(
VECTOR2I(random()%100000000, random()%100000000),
VECTOR2I(random()%100000000, random()%100000000) ) );
956 for(
int i = 0; i < n ; i++)
958 rvi[i] = NearestPointFixpt( segs[i], pts[i]);
963 for(
int i = 0; i < n ; i++)
965 rv[i] = NearestPointDbl( segs[i], pts[i]);
975 "Renderer performance test",
Information pertinent to a Pcbnew printed circuit board.
void SetOrigin(const Vec &pos)
coord_type GetHeight() const
coord_type GetWidth() const
void SetWidth(coord_type val)
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
void SetHeight(coord_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)
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)
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
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
wxStaticText * m_algoStatus
wxTextCtrl * m_filterString
wxSlider * m_rewindSlider
virtual void onReload(wxCommandEvent &event) override
std::shared_ptr< PNS_LOG_FILE > m_logFile
virtual void onListRightClick(wxMouseEvent &event)
std::shared_ptr< PNS_LOG_PLAYER > m_logPlayer
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
virtual void onListChecked(wxCommandEvent &event)
virtual void onListSelect(wxCommandEvent &event)
virtual void onRewindScroll(wxScrollEvent &event) override
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 onBtnRewindLeft(wxCommandEvent &event) override
virtual void onExit(wxCommandEvent &event) override
void AnnotatedPoint(const VECTOR2I p, int size, 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.
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
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...
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
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
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.
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)
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
@ LAYER_SELECT_OVERLAY
currently selected items overlay
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)
#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< double > VECTOR2D