← Back to team overview

kicad-developers team mailing list archive

Re: PCB reading Net list formace

 

On 24.07.2015 16:20, jp charras wrote:
> I'll have a look at this dialog.

In a recent commit (the one for single-click update) I've fixed this
problem - now the HTML panel is built in "lazy" mode. Patch attached.

Tom
>From 7c021220fe1e4501befd645df35ab315a21878dd Mon Sep 17 00:00:00 2001
From: Tomasz Wlostowski <tomasz.wlostowski@xxxxxxx>
Date: Fri, 10 Jul 2015 13:47:46 +0200
Subject: [PATCH 1/5] lazy rendering mode for HTML reporter widget (improves
 speed for large reports)

---
 common/dialogs/wx_html_report_panel.cpp      | 32 ++++++++++++++++++++++++++--
 common/dialogs/wx_html_report_panel.h        | 18 ++++++++++++++++
 common/dialogs/wx_html_report_panel_base.cpp |  7 +++---
 common/dialogs/wx_html_report_panel_base.fbp |  4 ++--
 common/dialogs/wx_html_report_panel_base.h   |  1 +
 common/reporter.cpp                          | 17 +++++++++++++++
 include/reporter.h                           | 18 ++++++++++++++++
 7 files changed, 89 insertions(+), 8 deletions(-)

diff --git a/common/dialogs/wx_html_report_panel.cpp b/common/dialogs/wx_html_report_panel.cpp
index 42d884f..3c7b4d1 100644
--- a/common/dialogs/wx_html_report_panel.cpp
+++ b/common/dialogs/wx_html_report_panel.cpp
@@ -32,7 +32,8 @@ WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow*      parent,
     WX_HTML_REPORT_PANEL_BASE( parent, id, pos, size, style ),
     m_reporter( this ),
     m_severities( -1 ),
-    m_showAll( true )
+    m_showAll( true ),
+    m_lazyUpdate( false )
 {
     syncCheckboxes();
     m_htmlView->SetPage( addHeader( "" ) );
@@ -57,7 +58,26 @@ void WX_HTML_REPORT_PANEL::Report( const wxString& aText, REPORTER::SEVERITY aSe
     line.severity = aSeverity;
 
     m_report.push_back( line );
-    m_htmlView->AppendToPage( generateHtml( line ) );
+
+    m_html += generateHtml( line );
+
+    if( !m_lazyUpdate )
+    {
+        m_htmlView->AppendToPage( generateHtml( line ) );
+        scrollToBottom();
+    }
+}
+
+
+void WX_HTML_REPORT_PANEL::SetLazyUpdate( bool aLazyUpdate )
+{
+    m_lazyUpdate = aLazyUpdate;
+}
+
+
+void WX_HTML_REPORT_PANEL::Flush()
+{
+    m_htmlView->SetPage( m_html );
     scrollToBottom();
 }
 
@@ -65,6 +85,7 @@ void WX_HTML_REPORT_PANEL::Report( const wxString& aText, REPORTER::SEVERITY aSe
 void WX_HTML_REPORT_PANEL::scrollToBottom()
 {
     int x, y, xUnit, yUnit;
+
     m_htmlView->GetVirtualSize( &x, &y );
     m_htmlView->GetScrollPixelsPerUnit( &xUnit, &yUnit );
     m_htmlView->Scroll( 0, y / yUnit );
@@ -242,5 +263,12 @@ void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event )
 
 void WX_HTML_REPORT_PANEL::Clear()
 {
+    m_html.clear();
     m_report.clear();
 }
+
+
+void WX_HTML_REPORT_PANEL::SetLabel( const wxString& aLabel )
+{
+    m_box->GetStaticBox()->SetLabel( aLabel );
+}
diff --git a/common/dialogs/wx_html_report_panel.h b/common/dialogs/wx_html_report_panel.h
index 953a49b..d0216c6 100644
--- a/common/dialogs/wx_html_report_panel.h
+++ b/common/dialogs/wx_html_report_panel.h
@@ -55,6 +55,20 @@ public:
     ///> clears the report panel
     void Clear();
 
+    ///> sets the frame label
+    void SetLabel( const wxString& aLabel );
+
+    void SetLazyUpdate( bool aLazyUpdate );
+
+    void Flush();
+
+    void SetVisibleSeverities( int aSeverities )
+    {
+        m_showAll = false;
+        m_severities = aSeverities;
+        syncCheckboxes();
+    }
+
 private:
     struct REPORT_LINE
     {
@@ -91,6 +105,10 @@ private:
 
     ///> show all messages flag (overrides m_severities)
     bool m_showAll;
+
+    wxString m_html;
+
+    bool m_lazyUpdate;
 };
 
 #endif //__WX_HTML_REPORT_PANEL_H__
diff --git a/common/dialogs/wx_html_report_panel_base.cpp b/common/dialogs/wx_html_report_panel_base.cpp
index fc47a8d..80be22c 100644
--- a/common/dialogs/wx_html_report_panel_base.cpp
+++ b/common/dialogs/wx_html_report_panel_base.cpp
@@ -11,8 +11,7 @@
 
 WX_HTML_REPORT_PANEL_BASE::WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )
 {
-	wxStaticBoxSizer* sbSizer3;
-	sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Messages:") ), wxVERTICAL );
+	m_box = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Messages:") ), wxVERTICAL );
 	
 	wxFlexGridSizer* fgSizer4;
 	fgSizer4 = new wxFlexGridSizer( 2, 1, 0, 0 );
@@ -67,10 +66,10 @@ WX_HTML_REPORT_PANEL_BASE::WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindow
 	fgSizer4->Add( fgSizer3, 1, wxEXPAND, 5 );
 	
 	
-	sbSizer3->Add( fgSizer4, 1, wxEXPAND|wxALL, 5 );
+	m_box->Add( fgSizer4, 1, wxEXPAND|wxALL, 5 );
 	
 	
-	this->SetSizer( sbSizer3 );
+	this->SetSizer( m_box );
 	this->Layout();
 	
 	// Connect Events
diff --git a/common/dialogs/wx_html_report_panel_base.fbp b/common/dialogs/wx_html_report_panel_base.fbp
index 0dc2fc1..f707d9d 100644
--- a/common/dialogs/wx_html_report_panel_base.fbp
+++ b/common/dialogs/wx_html_report_panel_base.fbp
@@ -82,9 +82,9 @@
                 <property name="id">wxID_ANY</property>
                 <property name="label">Messages:</property>
                 <property name="minimum_size"></property>
-                <property name="name">sbSizer3</property>
+                <property name="name">m_box</property>
                 <property name="orient">wxVERTICAL</property>
-                <property name="permission">none</property>
+                <property name="permission">protected</property>
                 <event name="OnUpdateUI"></event>
                 <object class="sizeritem" expanded="1">
                     <property name="border">5</property>
diff --git a/common/dialogs/wx_html_report_panel_base.h b/common/dialogs/wx_html_report_panel_base.h
index 3db31f3..240b08f 100644
--- a/common/dialogs/wx_html_report_panel_base.h
+++ b/common/dialogs/wx_html_report_panel_base.h
@@ -34,6 +34,7 @@ class WX_HTML_REPORT_PANEL_BASE : public wxPanel
 	private:
 	
 	protected:
+		wxStaticBoxSizer* m_box;
 		wxHtmlWindow* m_htmlView;
 		wxStaticText* m_staticText3;
 		wxCheckBox* m_checkBoxShowAll;
diff --git a/common/reporter.cpp b/common/reporter.cpp
index fa64160..2efc475 100644
--- a/common/reporter.cpp
+++ b/common/reporter.cpp
@@ -62,3 +62,20 @@ REPORTER& WX_HTML_PANEL_REPORTER::Report( const wxString& aText, SEVERITY aSever
     m_panel->Report( aText, aSeverity );
     return *this;
 }
+
+REPORTER& NULL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
+{
+    return *this;
+}
+
+REPORTER& NULL_REPORTER::GetInstance()
+{
+    static REPORTER* s_nullReporter = NULL;
+
+    if( !s_nullReporter )
+    {
+        s_nullReporter = new NULL_REPORTER();
+    }
+
+    return *s_nullReporter;
+}
diff --git a/include/reporter.h b/include/reporter.h
index 117e56f..47fc17f 100644
--- a/include/reporter.h
+++ b/include/reporter.h
@@ -147,4 +147,22 @@ public:
     REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED );
 };
 
+/**
+ * Class NULL_REPORTER
+ *
+ * A singleton reporter that reports to nowhere. Used as to simplify code by
+ * avoiding the reportee to check for a non-NULL reporter object.
+ */
+class NULL_REPORTER : public REPORTER
+{
+    public:
+        NULL_REPORTER()
+        {
+        };
+
+        static REPORTER& GetInstance();
+
+        REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED );
+};
+
 #endif     // _REPORTER_H_
-- 
2.4.3



Follow ups

References