From b562cfb8bbb76cc130e886c2ae53712117e4e66d Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Tue, 16 Jun 2015 14:20:42 +0200 Subject: [PATCH] WX_HTML_REPORT_PANEL: a REPORTER widget on steroids. --- 3d-viewer/3d_draw.cpp | 22 +- common/CMakeLists.txt | 2 + common/common.cpp | 10 +- common/dialogs/wx_html_report_panel.cpp | 232 +++++ common/dialogs/wx_html_report_panel.h | 95 ++ common/dialogs/wx_html_report_panel_base.cpp | 95 ++ common/dialogs/wx_html_report_panel_base.fbp | 823 ++++++++++++++++++ common/dialogs/wx_html_report_panel_base.h | 62 ++ common/reporter.cpp | 19 +- eeschema/dialogs/dialog_bom.cpp | 1 - eeschema/dialogs/dialog_plot_schematic.cpp | 9 +- eeschema/dialogs/dialog_plot_schematic.h | 4 +- .../dialogs/dialog_plot_schematic_base.cpp | 14 +- .../dialogs/dialog_plot_schematic_base.fbp | 25 +- eeschema/dialogs/dialog_plot_schematic_base.h | 6 +- eeschema/netform.cpp | 26 +- eeschema/plot_schematic_DXF.cpp | 18 +- eeschema/plot_schematic_HPGL.cpp | 22 +- eeschema/plot_schematic_PDF.cpp | 28 +- eeschema/plot_schematic_PS.cpp | 16 +- eeschema/plot_schematic_SVG.cpp | 31 +- include/reporter.h | 96 +- pcbnew/class_board.cpp | 77 +- pcbnew/dialogs/dialog_SVG_print.cpp | 15 +- pcbnew/dialogs/dialog_SVG_print_base.cpp | 18 +- pcbnew/dialogs/dialog_SVG_print_base.fbp | 257 ++---- pcbnew/dialogs/dialog_SVG_print_base.h | 7 +- .../dialog_gen_module_position_file_base.cpp | 19 +- .../dialog_gen_module_position_file_base.fbp | 42 +- .../dialog_gen_module_position_file_base.h | 9 +- pcbnew/dialogs/dialog_netlist.cpp | 29 +- pcbnew/dialogs/dialog_netlist_fbp.cpp | 12 +- pcbnew/dialogs/dialog_netlist_fbp.fbp | 104 +-- pcbnew/dialogs/dialog_netlist_fbp.h | 5 +- pcbnew/dialogs/dialog_plot.cpp | 51 +- pcbnew/dialogs/dialog_plot_base.cpp | 20 +- pcbnew/dialogs/dialog_plot_base.fbp | 53 +- pcbnew/dialogs/dialog_plot_base.h | 6 +- pcbnew/exporters/gen_drill_report_files.cpp | 6 +- pcbnew/exporters/gen_modules_placefile.cpp | 52 +- pcbnew/netlist.cpp | 14 +- 41 files changed, 1791 insertions(+), 661 deletions(-) create mode 100644 common/dialogs/wx_html_report_panel.cpp create mode 100644 common/dialogs/wx_html_report_panel.h create mode 100644 common/dialogs/wx_html_report_panel_base.cpp create mode 100644 common/dialogs/wx_html_report_panel_base.fbp create mode 100644 common/dialogs/wx_html_report_panel_base.h diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index f7a6642cc4..ebf1dac92c 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -86,13 +86,10 @@ public: REPORTER(), m_frame( aFrame ), m_position( aPosition ) { - SetReportAll( true ); - SetReportWarnings( true ); - SetReportErrors( true ); m_hasMessage = false; } - REPORTER& Report( const wxString& aText ) + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) { if( !aText.IsEmpty() ) m_hasMessage = true; @@ -298,8 +295,6 @@ void EDA_3D_CANVAS::Redraw() wxString err_messages; WX_STRING_REPORTER errorReporter( &err_messages ); STATUS_TEXT_REPORTER activityReporter( Parent(), 0 ); - errorReporter.SetReportAll( false ); - errorReporter.SetReportWarnings( m_reportWarnings ); // Display build time at the end of build unsigned strtime = GetRunningMicroSecs(); @@ -622,7 +617,6 @@ void EDA_3D_CANVAS::Redraw() if( !err_messages.IsEmpty() ) wxLogMessage( err_messages ); - ReportWarnings( false ); } @@ -730,11 +724,13 @@ void EDA_3D_CANVAS::buildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList, if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) ) { - if( aErrorMessages && aErrorMessages->ReportWarnings() ) + if( aErrorMessages ) { - *aErrorMessages << msg << wxT("\n") << + msg << wxT("\n") << _("Unable to calculate the board outlines.\n" "Therefore use the board boundary box.") << wxT("\n\n"); + + aErrorMessages->Report( msg, REPORTER::RPT_WARNING ); } } @@ -1082,11 +1078,12 @@ void EDA_3D_CANVAS::buildTechLayers3DView( REPORTER* aErrorMessages, REPORTER* a if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) ) { - if( aErrorMessages && aErrorMessages->ReportWarnings() ) + if( aErrorMessages ) { - *aErrorMessages << msg << wxT("\n") << + msg << wxT("\n") << _("Unable to calculate the board outlines.\n" "Therefore use the board boundary box.") << wxT("\n\n"); + aErrorMessages->Report( msg, REPORTER::RPT_WARNING ); } } @@ -1432,10 +1429,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List( REPORTER* aErrorMessages, REPORTER* aActi glNewList( m_glLists[GL_ID_TECH_LAYERS], GL_COMPILE ); // when calling BuildTechLayers3DView, // do not show warnings, which are the same as buildBoard3DView - bool report_warn = aErrorMessages->ReportWarnings(); - aErrorMessages->SetReportWarnings( false ); buildTechLayers3DView( aErrorMessages, aActivity ); - aErrorMessages->SetReportWarnings( report_warn ); glEndList(); CheckGLError( __FILE__, __LINE__ ); diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index d0378b87dc..0f58626603 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -130,6 +130,8 @@ set( COMMON_ABOUT_DLG_SRCS dialogs/dialog_page_settings_base.cpp dialogs/dialog_env_var_config_base.cpp dialogs/dialog_env_var_config.cpp + dialogs/wx_html_report_panel_base.cpp + dialogs/wx_html_report_panel.cpp ) set( COMMON_PAGE_LAYOUT_SRCS diff --git a/common/common.cpp b/common/common.cpp index 3ba5ab4cef..6018e71f8c 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -415,10 +415,10 @@ bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, { if( aReporter ) { - msg.Printf( _( "*** Error: cannot make path '%s' absolute with respect to '%s'! ***" ), + msg.Printf( _( "Cannot make path '%s' absolute with respect to '%s'." ), GetChars( aTargetFullFileName->GetPath() ), GetChars( baseFilePath ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ERROR ); } return false; @@ -434,7 +434,7 @@ bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, if( aReporter ) { msg.Printf( _( "Output directory '%s' created.\n" ), GetChars( outputPath ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_INFO ); return true; } } @@ -442,9 +442,9 @@ bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, { if( aReporter ) { - msg.Printf( _( "*** Error: cannot create output directory '%s'! ***\n" ), + msg.Printf( _( "Cannot create output directory '%s'.\n" ), GetChars( outputPath ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ERROR ); } return false; diff --git a/common/dialogs/wx_html_report_panel.cpp b/common/dialogs/wx_html_report_panel.cpp new file mode 100644 index 0000000000..a13fb8b42f --- /dev/null +++ b/common/dialogs/wx_html_report_panel.cpp @@ -0,0 +1,232 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2015 CERN + * Copyright (C) 2015 KiCad Developers, see change_log.txt for contributors. + * Author: Tomasz Wlostowski + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "wx_html_report_panel.h" + +#include +#include + +WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style ) : + WX_HTML_REPORT_PANEL_BASE( parent, id, pos, size, style ), + m_reporter( this ), + m_severities( -1 ), + m_showAll( true ) +{ + syncCheckboxes(); +} + + +WX_HTML_REPORT_PANEL::~WX_HTML_REPORT_PANEL() +{ +} + + +REPORTER& WX_HTML_REPORT_PANEL::Reporter() +{ + return m_reporter; +} + + +void WX_HTML_REPORT_PANEL::Report( const wxString& aText, REPORTER::SEVERITY aSeverity ) +{ + REPORT_LINE line; + line.message = aText; + line.severity = aSeverity; + + m_report.push_back( line ); + m_htmlView->AppendToPage( generateHtml( line ) ); + scrollToBottom(); +} + + +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 ); +} + + +void WX_HTML_REPORT_PANEL::refreshView() +{ + wxString html; + + BOOST_FOREACH( REPORT_LINE l, m_report ) + { + html += generateHtml( l ); + } + + m_htmlView->SetPage( html ); + scrollToBottom(); +} + + +wxString WX_HTML_REPORT_PANEL::generateHtml( const REPORT_LINE& aLine ) +{ + if( !m_showAll && ! ( m_severities & aLine.severity ) ) + return wxEmptyString; + + switch( aLine.severity ) + { + case REPORTER::RPT_ERROR: + return wxString( "" ) + _( "Error: " ) + aLine.message + wxString( "
" ); + case REPORTER::RPT_WARNING: + return wxString( "" ) + _( "Warning: " ) + aLine.message + wxString( "
" ); + case REPORTER::RPT_INFO: + return wxString( "" ) + _( "Info: " ) + aLine.message + wxString( "
" ); + case REPORTER::RPT_ACTION: + return wxString( "" ) + aLine.message + wxString( "
" ); + default: + return wxString( "" ) + aLine.message + wxString( "
" ); + } +} + + +wxString WX_HTML_REPORT_PANEL::generatePlainText( const REPORT_LINE& aLine ) +{ + switch( aLine.severity ) + { + case REPORTER::RPT_ERROR: + return _( "Error: " ) + aLine.message + wxT( "\n" ); + case REPORTER::RPT_WARNING: + return _( "Warning: " ) + aLine.message + wxT( "\n" ); + case REPORTER::RPT_INFO: + return _( "Info: " ) + aLine.message + wxT( "\n" ); + default: + return aLine.message + wxT( "\n" ); + } +} + + +void WX_HTML_REPORT_PANEL::onCheckBoxShowAll( wxCommandEvent& event ) +{ + if ( event.IsChecked() ) + m_showAll = true; + else + m_showAll = false; + + syncCheckboxes(); + refreshView(); +} + + +void WX_HTML_REPORT_PANEL::syncCheckboxes() +{ + m_checkBoxShowWarnings->Enable( !m_showAll ); + m_checkBoxShowWarnings->SetValue( m_severities & REPORTER::RPT_WARNING ); + m_checkBoxShowErrors->Enable( !m_showAll ); + m_checkBoxShowErrors->SetValue( m_severities & REPORTER::RPT_ERROR ); + m_checkBoxShowInfos->Enable( !m_showAll ); + m_checkBoxShowInfos->SetValue( m_severities & REPORTER::RPT_INFO ); + m_checkBoxShowActions->Enable( !m_showAll ); + m_checkBoxShowActions->SetValue( m_severities & REPORTER::RPT_ACTION ); +} + + +void WX_HTML_REPORT_PANEL::onCheckBoxShowWarnings( wxCommandEvent& event ) +{ + if ( event.IsChecked() ) + m_severities |= REPORTER::RPT_WARNING; + else + m_severities &= ~REPORTER::RPT_WARNING; + + refreshView(); +} + + +void WX_HTML_REPORT_PANEL::onCheckBoxShowErrors( wxCommandEvent& event ) +{ + if ( event.IsChecked() ) + m_severities |= REPORTER::RPT_ERROR; + else + m_severities &= ~REPORTER::RPT_ERROR; + + refreshView(); +} + + +void WX_HTML_REPORT_PANEL::onCheckBoxShowInfos( wxCommandEvent& event ) +{ + if ( event.IsChecked() ) + m_severities |= REPORTER::RPT_INFO; + else + m_severities &= ~REPORTER::RPT_INFO; + + refreshView(); +} + + +void WX_HTML_REPORT_PANEL::onCheckBoxShowActions( wxCommandEvent& event ) +{ + if ( event.IsChecked() ) + m_severities |= REPORTER::RPT_ACTION; + else + m_severities &= ~REPORTER::RPT_ACTION; + + refreshView(); +} + + +void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event ) +{ + wxFileName fn( "./report.txt" ); + + wxFileDialog dlg( this, _( "Save report to file" ), fn.GetPath(), fn.GetName(), + TextWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() != wxID_OK ) + return; + + fn = dlg.GetPath(); + + if( fn.GetExt().IsEmpty() ) + fn.SetExt( wxT( "txt" ) ); + + wxFile f( fn.GetFullPath(), wxFile::write ); + + if( !f.IsOpened() ) + { + wxString msg; + + msg.Printf( _( "Cannot write report to file '%s'." ), + (const char *)( fn.GetFullPath() ) ); + wxMessageBox( msg, _( "File save error" ), wxOK | wxICON_ERROR, this ); + return; + } + + BOOST_FOREACH( REPORT_LINE l, m_report ) + { + f.Write( generatePlainText( l ) ); + } + + f.Close(); +} + + +void WX_HTML_REPORT_PANEL::Clear() +{ + m_report.clear(); +} diff --git a/common/dialogs/wx_html_report_panel.h b/common/dialogs/wx_html_report_panel.h new file mode 100644 index 0000000000..9fe23fb000 --- /dev/null +++ b/common/dialogs/wx_html_report_panel.h @@ -0,0 +1,95 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2015 CERN + * Copyright (C) 2015 KiCad Developers, see change_log.txt for contributors. + * Author: Tomasz Wlostowski + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef __WX_HTML_REPORT_PANEL_H__ +#define __WX_HTML_REPORT_PANEL_H__ + +#include +#include +#include + +#include "wx_html_report_panel_base.h" + + +/** + * Class WX_HTML_REPORT_PANEL + * + * A widget for browsing a rich text error/status report. Used in numerous + * dialogs in eeschema and pcbnew. Provides error filtering functionality + * and saving report files. + * + * The messages are reported throuth a REPORTER object + */ +class WX_HTML_REPORT_PANEL : public WX_HTML_REPORT_PANEL_BASE +{ +public: + WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL ); + ~WX_HTML_REPORT_PANEL(); + + ///> returns the reporter object that reports to this panel + REPORTER& Reporter(); + + ///> reports a string directly. + void Report( const wxString& aText, REPORTER::SEVERITY aSeverity ); + + ///> clears the report panel + void Clear(); + +private: + struct REPORT_LINE + { + REPORTER::SEVERITY severity; + wxString message; + }; + + typedef std::vector REPORT_LINES; + + wxString generateHtml( const REPORT_LINE& aLine ); + wxString generatePlainText( const REPORT_LINE& aLine ); + + void refreshView(); + void scrollToBottom(); + void syncCheckboxes(); + + void onCheckBoxShowAll( wxCommandEvent& event ); + void onCheckBoxShowWarnings( wxCommandEvent& event ); + void onCheckBoxShowErrors( wxCommandEvent& event ); + void onCheckBoxShowInfos( wxCommandEvent& event ); + void onCheckBoxShowActions( wxCommandEvent& event ); + + void onBtnSaveToFile( wxCommandEvent& event ); + + ///> copy of the report, stored for filtering + REPORT_LINES m_report; + + ///> the reporter + WX_HTML_PANEL_REPORTER m_reporter; + + ///> message severities to display (mask) + int m_severities; + + ///> show all messages flag (overrides m_severities) + bool m_showAll; +}; + +#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 new file mode 100644 index 0000000000..fc47a8d0b4 --- /dev/null +++ b/common/dialogs/wx_html_report_panel_base.cpp @@ -0,0 +1,95 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Mar 9 2015) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "wx_html_report_panel_base.h" + +/////////////////////////////////////////////////////////////////////////// + +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 ); + + wxFlexGridSizer* fgSizer4; + fgSizer4 = new wxFlexGridSizer( 2, 1, 0, 0 ); + fgSizer4->AddGrowableCol( 0 ); + fgSizer4->AddGrowableRow( 0 ); + fgSizer4->SetFlexibleDirection( wxBOTH ); + fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_htmlView = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO ); + m_htmlView->SetFont( wxFont( 10, 70, 90, 90, false, wxEmptyString ) ); + + fgSizer4->Add( m_htmlView, 1, wxEXPAND, 5 ); + + wxFlexGridSizer* fgSizer3; + fgSizer3 = new wxFlexGridSizer( 1, 7, 0, 0 ); + fgSizer3->AddGrowableCol( 6 ); + fgSizer3->SetFlexibleDirection( wxBOTH ); + fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticText3 = new wxStaticText( this, wxID_ANY, wxT("Filter:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText3->Wrap( -1 ); + fgSizer3->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 ); + + m_checkBoxShowAll = new wxCheckBox( this, wxID_ANY, wxT("All"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkBoxShowAll->SetValue(true); + fgSizer3->Add( m_checkBoxShowAll, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_checkBoxShowWarnings = new wxCheckBox( this, wxID_ANY, wxT("Warnings"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkBoxShowWarnings->Enable( false ); + + fgSizer3->Add( m_checkBoxShowWarnings, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_checkBoxShowErrors = new wxCheckBox( this, wxID_ANY, wxT("Errors"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkBoxShowErrors->Enable( false ); + + fgSizer3->Add( m_checkBoxShowErrors, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_checkBoxShowInfos = new wxCheckBox( this, wxID_ANY, wxT("Infos"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkBoxShowInfos->Enable( false ); + + fgSizer3->Add( m_checkBoxShowInfos, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_checkBoxShowActions = new wxCheckBox( this, wxID_ANY, wxT("Actions"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkBoxShowActions->Enable( false ); + + fgSizer3->Add( m_checkBoxShowActions, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_btnSaveReportToFile = new wxButton( this, wxID_ANY, wxT("Save report to file..."), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer3->Add( m_btnSaveReportToFile, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxLEFT, 5 ); + + + fgSizer4->Add( fgSizer3, 1, wxEXPAND, 5 ); + + + sbSizer3->Add( fgSizer4, 1, wxEXPAND|wxALL, 5 ); + + + this->SetSizer( sbSizer3 ); + this->Layout(); + + // Connect Events + m_checkBoxShowAll->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowAll ), NULL, this ); + m_checkBoxShowWarnings->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowWarnings ), NULL, this ); + m_checkBoxShowErrors->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowErrors ), NULL, this ); + m_checkBoxShowInfos->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowInfos ), NULL, this ); + m_checkBoxShowActions->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowActions ), NULL, this ); + m_btnSaveReportToFile->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onBtnSaveToFile ), NULL, this ); +} + +WX_HTML_REPORT_PANEL_BASE::~WX_HTML_REPORT_PANEL_BASE() +{ + // Disconnect Events + m_checkBoxShowAll->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowAll ), NULL, this ); + m_checkBoxShowWarnings->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowWarnings ), NULL, this ); + m_checkBoxShowErrors->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowErrors ), NULL, this ); + m_checkBoxShowInfos->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowInfos ), NULL, this ); + m_checkBoxShowActions->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowActions ), NULL, this ); + m_btnSaveReportToFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onBtnSaveToFile ), NULL, this ); + +} diff --git a/common/dialogs/wx_html_report_panel_base.fbp b/common/dialogs/wx_html_report_panel_base.fbp new file mode 100644 index 0000000000..0dc2fc1ac3 --- /dev/null +++ b/common/dialogs/wx_html_report_panel_base.fbp @@ -0,0 +1,823 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + wx_html_report_panel_base + 1000 + none + 0 + WX_HTML_REPORT_PANEL_BASE + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + WX_HTML_REPORT_PANEL_BASE + + 500,300 + + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + wxID_ANY + Messages: + + sbSizer3 + wxVERTICAL + none + + + 5 + wxEXPAND|wxALL + 1 + + 1 + wxBOTH + 0 + 0 + 0 + + fgSizer4 + wxFLEX_GROWMODE_SPECIFIED + none + 2 + 0 + + 5 + wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 0 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,90,10,70,0 + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_htmlView + 1 + + + protected + 1 + + Resizable + 1 + + wxHW_SCROLLBAR_AUTO + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 7 + wxBOTH + 6 + + 0 + + fgSizer3 + wxFLEX_GROWMODE_SPECIFIED + none + 1 + 0 + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Filter: + + 0 + + + 0 + + 1 + m_staticText3 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + All + + 0 + + + 0 + + 1 + m_checkBoxShowAll + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + onCheckBoxShowAll + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + + 1 + + 0 + 0 + wxID_ANY + Warnings + + 0 + + + 0 + + 1 + m_checkBoxShowWarnings + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + onCheckBoxShowWarnings + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + + 1 + + 0 + 0 + wxID_ANY + Errors + + 0 + + + 0 + + 1 + m_checkBoxShowErrors + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + onCheckBoxShowErrors + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + + 1 + + 0 + 0 + wxID_ANY + Infos + + 0 + + + 0 + + 1 + m_checkBoxShowInfos + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + onCheckBoxShowInfos + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + + 1 + + 0 + 0 + wxID_ANY + Actions + + 0 + + + 0 + + 1 + m_checkBoxShowActions + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + onCheckBoxShowActions + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Save report to file... + + 0 + -1,-1 + + 0 + + 1 + m_btnSaveReportToFile + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onBtnSaveToFile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/dialogs/wx_html_report_panel_base.h b/common/dialogs/wx_html_report_panel_base.h new file mode 100644 index 0000000000..3db31f387d --- /dev/null +++ b/common/dialogs/wx_html_report_panel_base.h @@ -0,0 +1,62 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Mar 9 2015) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __WX_HTML_REPORT_PANEL_BASE_H__ +#define __WX_HTML_REPORT_PANEL_BASE_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class WX_HTML_REPORT_PANEL_BASE +/////////////////////////////////////////////////////////////////////////////// +class WX_HTML_REPORT_PANEL_BASE : public wxPanel +{ + private: + + protected: + wxHtmlWindow* m_htmlView; + wxStaticText* m_staticText3; + wxCheckBox* m_checkBoxShowAll; + wxCheckBox* m_checkBoxShowWarnings; + wxCheckBox* m_checkBoxShowErrors; + wxCheckBox* m_checkBoxShowInfos; + wxCheckBox* m_checkBoxShowActions; + wxButton* m_btnSaveReportToFile; + + // Virtual event handlers, overide them in your derived class + virtual void onCheckBoxShowAll( wxCommandEvent& event ) { event.Skip(); } + virtual void onCheckBoxShowWarnings( wxCommandEvent& event ) { event.Skip(); } + virtual void onCheckBoxShowErrors( wxCommandEvent& event ) { event.Skip(); } + virtual void onCheckBoxShowInfos( wxCommandEvent& event ) { event.Skip(); } + virtual void onCheckBoxShowActions( wxCommandEvent& event ) { event.Skip(); } + virtual void onBtnSaveToFile( wxCommandEvent& event ) { event.Skip(); } + + + public: + + WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL ); + ~WX_HTML_REPORT_PANEL_BASE(); + +}; + +#endif //__WX_HTML_REPORT_PANEL_BASE_H__ diff --git a/common/reporter.cpp b/common/reporter.cpp index be4372a3b9..fa641609a7 100644 --- a/common/reporter.cpp +++ b/common/reporter.cpp @@ -5,7 +5,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Wayne Stambaugh - * Copyright (C) 1992-2013 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,15 +27,16 @@ #include #include +#include -REPORTER& REPORTER::Report( const char* aText ) +REPORTER& REPORTER::Report( const char* aText, REPORTER::SEVERITY aSeverity ) { Report( FROM_UTF8( aText ) ); return *this; } -REPORTER& WX_TEXT_CTRL_REPORTER::Report( const wxString& aText ) +REPORTER& WX_TEXT_CTRL_REPORTER::Report( const wxString& aText, REPORTER::SEVERITY aSeverity ) { wxCHECK_MSG( m_textCtrl != NULL, *this, wxT( "No wxTextCtrl object defined in WX_TEXT_CTRL_REPORTER." ) ); @@ -44,8 +45,7 @@ REPORTER& WX_TEXT_CTRL_REPORTER::Report( const wxString& aText ) return *this; } - -REPORTER& WX_STRING_REPORTER::Report( const wxString& aText ) +REPORTER& WX_STRING_REPORTER::Report( const wxString& aText, REPORTER::SEVERITY aSeverity ) { wxCHECK_MSG( m_string != NULL, *this, wxT( "No wxString object defined in WX_STRING_REPORTER." ) ); @@ -53,3 +53,12 @@ REPORTER& WX_STRING_REPORTER::Report( const wxString& aText ) *m_string << aText; return *this; } + +REPORTER& WX_HTML_PANEL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity ) +{ + wxCHECK_MSG( m_panel != NULL, *this, + wxT( "No WX_HTML_REPORT_PANEL object defined in WX_HTML_PANEL_REPORTER." ) ); + + m_panel->Report( aText, aSeverity ); + return *this; +} diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index 9020564aaa..6d6723493e 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -391,7 +391,6 @@ void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event ) wxString reportmsg; WX_STRING_REPORTER reporter( &reportmsg ); - reporter.SetReportAll( true ); m_parent->SetNetListerCommand( m_textCtrlCommand->GetValue() ); m_parent->CreateNetlist( -1, fullfilename, 0, &reporter ); diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp index f6a11eadc9..dc40e56a0d 100644 --- a/eeschema/dialogs/dialog_plot_schematic.cpp +++ b/eeschema/dialogs/dialog_plot_schematic.cpp @@ -38,6 +38,7 @@ #include #include #include +#include // Keys for configuration #define PLOT_FORMAT_KEY wxT( "PlotFormat" ) @@ -329,8 +330,6 @@ void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll ) break; } - - m_MessagesBox->AppendText( wxT( "****\n" ) ); } wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxTextCtrl* aOutputDirectoryName, @@ -346,14 +345,12 @@ wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxTextCtrl* aOutputDirecto if( !EnsureFileDirectoryExists( &outputDir, plotFileName, aReporter ) ) { wxString msg; - msg.Printf( _( "Could not write plot files to folder \"%s\"." ), + msg.Printf( _( "Could not write plot files to folder '%s'." ), GetChars( outputDir.GetPath() ) ); - msg << wxT( "\n" ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ERROR ); } wxFileName fn( plotFileName ); fn.SetPath( outputDir.GetFullPath() ); return fn; - } diff --git a/eeschema/dialogs/dialog_plot_schematic.h b/eeschema/dialogs/dialog_plot_schematic.h index 86298b22d6..69cf6c050c 100644 --- a/eeschema/dialogs/dialog_plot_schematic.h +++ b/eeschema/dialogs/dialog_plot_schematic.h @@ -100,10 +100,8 @@ private: * Everything done, close the plot and restore the environment * @param aPlotter the plotter to close and destroy * @param aOldsheetpath the stored old sheet path for the current sheet before the plot started - * @param aMsg the message which is print to the message box */ - void restoreEnvironment( PDF_PLOTTER* aPlotter, SCH_SHEET_PATH& aOldsheetpath, - const wxString& aMsg ); + void restoreEnvironment( PDF_PLOTTER* aPlotter, SCH_SHEET_PATH& aOldsheetpath ); // DXF void CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ); diff --git a/eeschema/dialogs/dialog_plot_schematic_base.cpp b/eeschema/dialogs/dialog_plot_schematic_base.cpp index 89f40a9dbb..ca6467dd69 100644 --- a/eeschema/dialogs/dialog_plot_schematic_base.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_base.cpp @@ -1,10 +1,12 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Jun 6 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "wx_html_report_panel.h" + #include "dialog_plot_schematic_base.h" /////////////////////////////////////////////////////////////////////////// @@ -48,7 +50,7 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind wxString m_PaperSizeOptionChoices[] = { _("Schematic size"), _("Force size A4"), _("Force size A") }; int m_PaperSizeOptionNChoices = sizeof( m_PaperSizeOptionChoices ) / sizeof( wxString ); m_PaperSizeOption = new wxRadioBox( this, wxID_ANY, _("Page Size:"), wxDefaultPosition, wxDefaultSize, m_PaperSizeOptionNChoices, m_PaperSizeOptionChoices, 1, wxRA_SPECIFY_COLS ); - m_PaperSizeOption->SetSelection( 0 ); + m_PaperSizeOption->SetSelection( 1 ); m_paperOptionsSizer->Add( m_PaperSizeOption, 0, wxALL|wxEXPAND, 5 ); m_paperHPGLSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("HPGL Options") ), wxVERTICAL ); @@ -86,7 +88,7 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind wxString m_plotFormatOptChoices[] = { _("Postscript"), _("PDF"), _("SVG"), _("DXF"), _("HPGL") }; int m_plotFormatOptNChoices = sizeof( m_plotFormatOptChoices ) / sizeof( wxString ); m_plotFormatOpt = new wxRadioBox( this, wxID_ANY, _("Format"), wxDefaultPosition, wxDefaultSize, m_plotFormatOptNChoices, m_plotFormatOptChoices, 1, wxRA_SPECIFY_COLS ); - m_plotFormatOpt->SetSelection( 0 ); + m_plotFormatOpt->SetSelection( 1 ); m_optionsSizer->Add( m_plotFormatOpt, 0, wxEXPAND|wxLEFT, 5 ); wxStaticBoxSizer* sbSizerPlotFormat; @@ -145,10 +147,10 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind m_staticText2->Wrap( -1 ); bSizer4->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); - m_MessagesBox->SetMinSize( wxSize( -1,80 ) ); + m_MessagesBox = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_MessagesBox->SetMinSize( wxSize( 300,150 ) ); - bSizer4->Add( m_MessagesBox, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bSizer4->Add( m_MessagesBox, 1, wxEXPAND | wxALL, 5 ); bMainSizer->Add( bSizer4, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); diff --git a/eeschema/dialogs/dialog_plot_schematic_base.fbp b/eeschema/dialogs/dialog_plot_schematic_base.fbp index 83a21d3697..0018cb26cb 100644 --- a/eeschema/dialogs/dialog_plot_schematic_base.fbp +++ b/eeschema/dialogs/dialog_plot_schematic_base.fbp @@ -448,7 +448,7 @@ 1 Resizable - 0 + 1 1 wxRA_SPECIFY_COLS @@ -989,7 +989,7 @@ 1 Resizable - 0 + 1 1 wxRA_SPECIFY_COLS @@ -1766,9 +1766,9 @@ 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + wxEXPAND | wxALL 1 - + 1 1 1 @@ -1799,10 +1799,9 @@ 0 - 0 - -1,80 + 300,150 1 m_MessagesBox 1 @@ -1814,18 +1813,12 @@ Resizable 1 - wxTE_MULTILINE - + WX_HTML_REPORT_PANEL; wx_html_report_panel.h 0 - - wxFILTER_NONE - wxDefaultValidator - - - + wxTAB_TRAVERSAL @@ -1848,10 +1841,6 @@ - - - - diff --git a/eeschema/dialogs/dialog_plot_schematic_base.h b/eeschema/dialogs/dialog_plot_schematic_base.h index 39e15609b6..b983cca9ef 100644 --- a/eeschema/dialogs/dialog_plot_schematic_base.h +++ b/eeschema/dialogs/dialog_plot_schematic_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Jun 6 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -12,6 +12,7 @@ #include #include class DIALOG_SHIM; +class WX_HTML_REPORT_PANEL; #include "dialog_shim.h" #include @@ -27,6 +28,7 @@ class DIALOG_SHIM; #include #include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -67,7 +69,7 @@ class DIALOG_PLOT_SCHEMATIC_BASE : public DIALOG_SHIM wxButton* m_buttonPlotAll; wxButton* m_buttonQuit; wxStaticText* m_staticText2; - wxTextCtrl* m_MessagesBox; + WX_HTML_REPORT_PANEL* m_MessagesBox; // Virtual event handlers, overide them in your derived class virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); } diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 6abac5df0c..51845a542d 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -106,30 +106,36 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST* aConnectedItemsList, wxArrayString output, errors; int diag = wxExecute (commandLine, output, errors, wxEXEC_SYNC ); - aReporter->Report( _("Run command:") ); - *aReporter << wxT("\n") << commandLine << wxT("\n\n"); + wxString msg; + + msg << _("Run command:") << wxT("\n") << commandLine << wxT("\n\n"); + + aReporter->Report( msg, REPORTER::RPT_ACTION ); if( diag != 0 ) - aReporter->Report( wxString::Format( _("Command error. Return code %d"), diag ) ); + aReporter->Report( wxString::Format( _("Command error. Return code %d"), diag ), REPORTER::RPT_ERROR ); else - aReporter->Report( _("Success") ); + aReporter->Report( _("Success"), REPORTER::RPT_INFO ); *aReporter << wxT("\n"); - if( output.GetCount() && aReporter->ReportWarnings() ) + if( output.GetCount() ) { - *aReporter << wxT("\n") << _("Info messages:") << wxT("\n"); + msg << wxT("\n") << _("Info messages:") << wxT("\n"); + aReporter->Report( msg, REPORTER::RPT_INFO ); for( unsigned ii = 0; ii < output.GetCount(); ii++ ) - *aReporter << output[ii] << wxT("\n"); + aReporter->Report( output[ii], REPORTER::RPT_INFO ); } - if( errors.GetCount() && aReporter->ReportErrors() ) + if( errors.GetCount() ) { - *aReporter << wxT("\n") << _("Error messages:") << wxT("\n"); + msg << wxT("\n") << _("Error messages:") << wxT("\n"); + aReporter->Report( msg, REPORTER::RPT_INFO ); for( unsigned ii = 0; ii < errors.GetCount(); ii++ ) - *aReporter << errors[ii] << wxT("\n"); + aReporter->Report( errors[ii], REPORTER::RPT_ERROR ); + } } else diff --git a/eeschema/plot_schematic_DXF.cpp b/eeschema/plot_schematic_DXF.cpp index 523e224a84..e613893071 100644 --- a/eeschema/plot_schematic_DXF.cpp +++ b/eeschema/plot_schematic_DXF.cpp @@ -30,9 +30,11 @@ #include #include #include -#include #include +#include +#include + void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ) { @@ -51,7 +53,7 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ) sheetpath = SheetList.GetFirst(); SCH_SHEET_PATH list; - WX_TEXT_CTRL_REPORTER reporter(m_MessagesBox); + REPORTER& reporter = m_MessagesBox->Reporter(); while( true ) { @@ -89,19 +91,19 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ) if( PlotOneSheetDXF( plotFileName.GetFullPath(), screen, plot_offset, 1.0, aPlotFrameRef ) ) { - msg.Printf( _( "Plot: '%s' OK\n" ), GetChars( plotFileName.GetFullPath() ) ); + msg.Printf( _( "Plot: '%s' OK.\n" ), GetChars( plotFileName.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ACTION ); } else // Error { - msg.Printf( _( "Unable to create '%s'\n" ), GetChars( plotFileName.GetFullPath() ) ); + msg.Printf( _( "Unable to create file '%s'.\n" ), GetChars( plotFileName.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); } - m_MessagesBox->AppendText( msg ); - } catch( IO_ERROR& e ) { - msg.Printf( wxT( "DXF Plotter Exception : '%s'"), GetChars( e.errorText ) ); - m_MessagesBox->AppendText( msg ); + msg.Printf( wxT( "DXF Plotter exception: %s"), GetChars( e.errorText ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); schframe->SetCurrentSheet( oldsheetpath ); schframe->GetCurrentSheet().UpdateAllScreenReferences(); schframe->SetSheetNumberAndCount(); diff --git a/eeschema/plot_schematic_HPGL.cpp b/eeschema/plot_schematic_HPGL.cpp index f700a3dfac..9b64ab021f 100644 --- a/eeschema/plot_schematic_HPGL.cpp +++ b/eeschema/plot_schematic_HPGL.cpp @@ -34,7 +34,7 @@ #include #include - +#include enum HPGL_PAGEZ_T { PAGE_DEFAULT = 0, @@ -124,7 +124,7 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef ) sheetpath = SheetList.GetFirst(); SCH_SHEET_PATH list; - WX_TEXT_CTRL_REPORTER reporter(m_MessagesBox); + REPORTER& reporter = m_MessagesBox->Reporter(); SetHPGLPenWidth(); @@ -186,19 +186,23 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef ) if( Plot_1_Page_HPGL( plotFileName.GetFullPath(), screen, plotPage, plotOffset, plot_scale, aPlotFrameRef ) ) - msg.Printf( _( "Plot: '%s' OK\n" ), GetChars( plotFileName.GetFullPath() ) ); - else // Error - msg.Printf( _( "Unable to create '%s'\n" ), GetChars( plotFileName.GetFullPath() ) ); - - m_MessagesBox->AppendText( msg ); + { + msg.Printf( _( "Plot: '%s' OK.\n" ), GetChars( plotFileName.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ACTION ); + } + else + { + msg.Printf( _( "Unable to create file '%s'.\n" ), GetChars( plotFileName.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); + } if( !aPlotAll ) break; } catch( IO_ERROR& e ) { - msg.Printf( wxT( "HPGL Plotter Exception : '%s'"), GetChars( e.errorText ) ); - m_MessagesBox->AppendText( msg ); + msg.Printf( wxT( "HPGL Plotter exception: %s"), GetChars( e.errorText ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); } } diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index 1ea9471a71..b549a6f293 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -31,9 +31,12 @@ #include #include #include -#include #include +#include + +#include +#include void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) { @@ -61,7 +64,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) wxString msg; wxFileName plotFileName; - WX_TEXT_CTRL_REPORTER reporter(m_MessagesBox); + REPORTER& reporter = m_MessagesBox->Reporter(); // First page handling is different bool first_page = true; @@ -97,8 +100,8 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) if( !plotter->OpenFile( plotFileName.GetFullPath() ) ) { - msg.Printf( _( "Unable to create '%s'\n" ), GetChars( plotFileName.GetFullPath() ) ); - m_MessagesBox->AppendText( msg ); + msg.Printf( _( "Unable to create file '%s'.\n" ), GetChars( plotFileName.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); delete plotter; return; } @@ -113,8 +116,10 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) catch( const IO_ERROR& e ) { // Cannot plot PDF file - msg.Printf( wxT( "PDF Plotter Exception : <%s>"), GetChars( e.errorText ) ); - restoreEnvironment(plotter, oldsheetpath, msg); + msg.Printf( wxT( "PDF Plotter exception: %s" ), GetChars( e.errorText ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); + + restoreEnvironment( plotter, oldsheetpath ); return; } @@ -132,14 +137,17 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) } while( aPlotAll && sheetpath ); // Everything done, close the plot and restore the environment - msg.Printf( _( "Plot: <%s> OK\n" ), GetChars( plotFileName.GetFullPath() ) ); - restoreEnvironment(plotter, oldsheetpath, msg); + msg.Printf( _( "Plot: '%s' OK.\n" ), GetChars( plotFileName.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ACTION ); + + + restoreEnvironment(plotter, oldsheetpath ); } void DIALOG_PLOT_SCHEMATIC::restoreEnvironment( PDF_PLOTTER* aPlotter, - SCH_SHEET_PATH& aOldsheetpath, const wxString& aMsg ) + SCH_SHEET_PATH& aOldsheetpath ) { aPlotter->EndPlot(); delete aPlotter; @@ -149,8 +157,6 @@ void DIALOG_PLOT_SCHEMATIC::restoreEnvironment( PDF_PLOTTER* aPlotter, m_parent->SetCurrentSheet( aOldsheetpath ); m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); - - m_MessagesBox->AppendText( aMsg ); } diff --git a/eeschema/plot_schematic_PS.cpp b/eeschema/plot_schematic_PS.cpp index 257c3b5c72..e7af7aaa4f 100644 --- a/eeschema/plot_schematic_PS.cpp +++ b/eeschema/plot_schematic_PS.cpp @@ -30,10 +30,11 @@ #include #include #include -#include #include #include +#include +#include void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef ) { @@ -107,7 +108,7 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef ) wxFileName outputDir = wxFileName::DirName( outputDirName ); wxString msg; - WX_TEXT_CTRL_REPORTER reporter(m_MessagesBox); + REPORTER& reporter = m_MessagesBox->Reporter(); try { @@ -119,20 +120,21 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef ) if( plotOneSheetPS( plotFileName.GetFullPath(), screen, plotPage, plot_offset, scale, aPlotFrameRef ) ) { - msg.Printf( _( "Plot: '%s' OK\n" ), GetChars( plotFileName.GetFullPath() ) ); + msg.Printf( _( "Plot: '%s' OK.\n" ), GetChars( plotFileName.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ACTION ); } else { // Error - msg.Printf( _( "Unable to create '%s'\n" ), GetChars( plotFileName.GetFullPath() ) ); + msg.Printf( _( "Unable to create file '%s'.\n" ), GetChars( plotFileName.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); } - m_MessagesBox->AppendText( msg ); } catch( IO_ERROR& e ) { - msg.Printf( wxT( "PS Plotter Exception : '%s'"), GetChars( e.errorText ) ); - m_MessagesBox->AppendText( msg ); + msg.Printf( wxT( "PS Plotter exception: %s"), GetChars( e.errorText ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); } if( !aPlotAll ) diff --git a/eeschema/plot_schematic_SVG.cpp b/eeschema/plot_schematic_SVG.cpp index fe22466daf..0cc81ed854 100644 --- a/eeschema/plot_schematic_SVG.cpp +++ b/eeschema/plot_schematic_SVG.cpp @@ -36,13 +36,15 @@ #include #include #include +#include #include - +#include void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) { wxString msg; + REPORTER& reporter = m_MessagesBox->Reporter(); if( aPrintAll ) { @@ -51,7 +53,6 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) SCH_SHEET_LIST SheetList( NULL ); sheetpath = SheetList.GetFirst(); SCH_SHEET_PATH list; - WX_TEXT_CTRL_REPORTER reporter(m_MessagesBox); for( ; ; ) { @@ -90,22 +91,22 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) if( !success ) { - msg.Printf( _( "Error creating file '%s'\n" ), + msg.Printf( _( "Cannot create file '%s'.\n" ), GetChars( plotFileName.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); } else { - msg.Printf( _( "File '%s' OK\n" ), - GetChars( plotFileName.GetFullPath() ) ); + msg.Printf( _( "Plot: '%s' OK.\n" ), + GetChars( plotFileName.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ACTION ); } - - m_MessagesBox->AppendText( msg ); } catch( const IO_ERROR& e ) { // Cannot plot SVG file - msg.Printf( wxT( "SVG Plotter Exception : '%s'" ), GetChars( e.errorText ) ); - m_MessagesBox->AppendText( msg ); + msg.Printf( wxT( "SVG Plotter exception: %s" ), GetChars( e.errorText ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); m_parent->SetCurrentSheet( oldsheetpath ); m_parent->GetCurrentSheet().UpdateAllScreenReferences(); @@ -133,21 +134,23 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) aPrintFrameRef ); if( success ) { - msg.Printf( _( "Plot: <%s> OK\n" ), + msg.Printf( _( "Plot: '%s' OK.\n" ), GetChars( fn.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ACTION ); + } else // Error { - msg.Printf( _( "Unable to create <%s>\n" ), + msg.Printf( _( "Unable to create file '%s'.\n" ), GetChars( fn.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); } - m_MessagesBox->AppendText( msg ); } catch( const IO_ERROR& e ) { // Cannot plot SVG file - msg.Printf( wxT( "SVG Plotter Exception : <%s>"), GetChars( e.errorText ) ); - m_MessagesBox->AppendText( msg ); + msg.Printf( wxT( "SVG Plotter exception: %s."), GetChars( e.errorText ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); return; } } diff --git a/include/reporter.h b/include/reporter.h index 50e7a293d0..117e56f6db 100644 --- a/include/reporter.h +++ b/include/reporter.h @@ -35,6 +35,8 @@ class wxString; class wxTextCtrl; +class wxHtmlListbox; +class WX_HTML_REPORT_PANEL; /** @@ -47,28 +49,37 @@ class wxTextCtrl; *
  • know too much about the caller's UI, i.e. wx.
  • *
  • stop after the first error
  • * - * the reporter has 3 levels (flags) for filtering: - * no filter - * report warning - * report errors - * They are indicators for the calling code, filtering is not made here + * the reporter has 4 severity levels (flags) tagging the messages: + * - information + * - warning + * - error + * - action (i.e. indication of changes - add component, change footprint, etc. ) + * They are indicators for the message formatting and displaying code, + * filtering is not made here. */ -class REPORTER -{ - bool m_reportAll; // Filter flag: set to true to report all messages - bool m_reportWarnings; // Filter flag: set to true to report warning - bool m_reportErrors; // Filter flag: set to true to report errors + +class REPORTER { public: + ///> Severity of the reported messages. + enum SEVERITY { + RPT_UNDEFINED = 0x0, + RPT_INFO = 0x1, + RPT_WARNING = 0x2, + RPT_ERROR = 0x4, + RPT_ACTION = 0x8 + }; + /** * Function Report * is a pure virtual function to override in the derived object. * * @param aText is the string to report. */ - virtual REPORTER& Report( const wxString& aText ) = 0; - REPORTER& Report( const char* aText ); + virtual REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) = 0; + + REPORTER& Report( const char* aText, SEVERITY aSeverity = RPT_UNDEFINED ); REPORTER& operator <<( const wxString& aText ) { return Report( aText ); } @@ -77,41 +88,6 @@ public: REPORTER& operator <<( wxChar aChar ) { return Report( wxString( aChar ) ); } REPORTER& operator <<( const char* aText ) { return Report( aText ); } - - /** - * Returns true if all messages should be reported - */ - bool ReportAll() { return m_reportAll; } - - /** - * Returns true if all messages or warning messages should be reported - */ - bool ReportWarnings() { return m_reportAll | m_reportWarnings; } - - /** - * Returns true if all messages or error messages should be reported - */ - bool ReportErrors() { return m_reportAll | m_reportErrors; } - - /** - * Set the report filter state, for all messages - * @param aEnable = filter state (true/false) - */ - void SetReportAll( bool aEnable) { m_reportAll = aEnable; } - - /** - * Set the report filter state, for warning messages - * note: report can be disable only if m_reportAll = false - * @param aEnable = filter state (true/false) - */ - void SetReportWarnings( bool aEnable) { m_reportWarnings = aEnable; } - - /** - * Set the report filter state, for error messages - * note: report can be disable only if m_reportAll = false - * @param aEnable = filter state (true/false) - */ - void SetReportErrors( bool aEnable) { m_reportErrors = aEnable; } }; @@ -128,12 +104,9 @@ public: REPORTER(), m_textCtrl( aTextCtrl ) { - SetReportAll( true ); - SetReportWarnings( true ); - SetReportErrors( true ); } - REPORTER& Report( const wxString& aText ); + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ); }; @@ -152,7 +125,26 @@ public: { } - REPORTER& Report( const wxString& aText ); + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ); +}; + + +/** + * Class WX_HTML_PANEL_REPORTER + * is a wrapper for reporting to a wx HTML window + */ +class WX_HTML_PANEL_REPORTER : public REPORTER +{ + WX_HTML_REPORT_PANEL* m_panel; + +public: + WX_HTML_PANEL_REPORTER( WX_HTML_REPORT_PANEL* aPanel ) : + REPORTER(), + m_panel( aPanel ) + { + } + + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ); }; #endif // _REPORTER_H_ diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index d137f68d44..cf572a5e2b 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -2231,21 +2231,14 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, { COMPONENT* component = aNetlist.GetComponent( i ); - if( aReporter && aReporter->ReportAll() ) + if( aReporter ) { -#if defined(DEBUG) - if( component->GetReference() == wxT( "D2" ) ) - { - int breakhere = 1; - (void) breakhere; - } -#endif msg.Printf( _( "Checking netlist component footprint \"%s:%s:%s\".\n" ), GetChars( component->GetReference() ), GetChars( component->GetTimeStamp() ), GetChars( component->GetFPID().Format() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_INFO ); } if( aNetlist.IsFindByTimeStamp() ) @@ -2264,8 +2257,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, GetChars( component->GetTimeStamp() ), GetChars( component->GetFPID().Format() ) ); - if( aReporter->ReportWarnings() ) - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ACTION ); } else { @@ -2275,8 +2267,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, GetChars( component->GetTimeStamp() ), GetChars( component->GetFPID().Format() ) ); - if( aReporter->ReportErrors() ) - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ERROR ); } } @@ -2298,7 +2289,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, { if( aNetlist.GetReplaceFootprints() ) { - if( aReporter ) + if( aReporter ) { if( component->GetModule() != NULL ) { @@ -2309,8 +2300,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, GetChars( footprint->GetFPID().Format() ), GetChars( component->GetFPID().Format() ) ); - if( aReporter->ReportWarnings() ) - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ACTION ); } else { @@ -2320,8 +2310,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, GetChars( footprint->GetPath() ), GetChars( component->GetFPID().Format() ) ); - if( aReporter->ReportErrors() ) - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ERROR ); } } @@ -2343,16 +2332,16 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, } } - // Test for reference designator field change. + // Test for reference designator field change. if( footprint->GetReference() != component->GetReference() ) { - if( aReporter && aReporter->ReportWarnings()) + if( aReporter ) { - msg.Printf( _( "Changing footprint \"%s:%s\" reference to \"%s\".\n" ), + msg.Printf( _( "Changing component \"%s:%s\" reference to \"%s\".\n" ), GetChars( footprint->GetReference() ), GetChars( footprint->GetPath() ), GetChars( component->GetReference() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ACTION ); } if( !aNetlist.IsDryRun() ) @@ -2362,30 +2351,30 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, // Test for value field change. if( footprint->GetValue() != component->GetValue() ) { - if( aReporter && aReporter->ReportAll() ) + if( aReporter ) { - msg.Printf( _( "Changing footprint \"%s:%s\" value from \"%s\" to \"%s\".\n" ), + msg.Printf( _( "Changing component \"%s:%s\" value from \"%s\" to \"%s\".\n" ), GetChars( footprint->GetReference() ), GetChars( footprint->GetPath() ), GetChars( footprint->GetValue() ), GetChars( component->GetValue() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ACTION ); } if( !aNetlist.IsDryRun() ) footprint->SetValue( component->GetValue() ); } - // Test for time stamp change. + // Test for time stamp change. if( footprint->GetPath() != component->GetTimeStamp() ) { - if( aReporter && aReporter->ReportWarnings() ) + if( aReporter ) { - msg.Printf( _( "Changing footprint path \"%s:%s\" to \"%s\".\n" ), + msg.Printf( _( "Changing component path \"%s:%s\" to \"%s\".\n" ), GetChars( footprint->GetReference() ), GetChars( footprint->GetPath() ), GetChars( component->GetTimeStamp() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_INFO ); } if( !aNetlist.IsDryRun() ) @@ -2396,20 +2385,20 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, if( footprint == NULL ) continue; - // At this point, the component footprint is updated. Now update the nets. + // At this point, the component footprint is updated. Now update the nets. for( pad = footprint->Pads(); pad; pad = pad->Next() ) { COMPONENT_NET net = component->GetNet( pad->GetPadName() ); if( !net.IsValid() ) // Footprint pad had no net. { - if( aReporter && aReporter->ReportAll() && !pad->GetNetname().IsEmpty() ) + if( aReporter && !pad->GetNetname().IsEmpty() ) { msg.Printf( _( "Clearing component \"%s:%s\" pin \"%s\" net name.\n" ), GetChars( footprint->GetReference() ), GetChars( footprint->GetPath() ), GetChars( pad->GetPadName() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ACTION ); } if( !aNetlist.IsDryRun() ) @@ -2419,7 +2408,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, { if( net.GetNetName() != pad->GetNetname() ) { - if( aReporter && aReporter->ReportAll() ) + if( aReporter ) { msg.Printf( _( "Changing component \"%s:%s\" pin \"%s\" net name from " "\"%s\" to \"%s\".\n" ), @@ -2428,7 +2417,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, GetChars( pad->GetPadName() ), GetChars( pad->GetNetname() ), GetChars( net.GetNetName() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ACTION ); } if( !aNetlist.IsDryRun() ) @@ -2468,12 +2457,12 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, if( component == NULL ) { - if( aReporter && aReporter->ReportWarnings() ) + if( aReporter ) { - msg.Printf( _( "Removing footprint \"%s:%s\".\n" ), + msg.Printf( _( "Removing unused component \"%s:%s\".\n" ), GetChars( module->GetReference() ), GetChars( module->GetPath() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ACTION ); } if( !aNetlist.IsDryRun() ) @@ -2528,13 +2517,13 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, if( count == 1 ) // Really one pad, and nothing else { - if( aReporter && aReporter->ReportAll() ) + if( aReporter ) { msg.Printf( _( "Remove single pad net \"%s\" on \"%s\" pad '%s'\n" ), GetChars( previouspad->GetNetname() ), GetChars( previouspad->GetParent()->GetReference() ), GetChars( previouspad->GetPadName() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ACTION ); } previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED ); @@ -2566,7 +2555,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, // Also verify if zones have acceptable nets, i.e. nets with pads. // Zone with no pad belongs to a "dead" net which happens after changes in schematic // when no more pad use this net name. - if( aReporter && aReporter->ReportErrors() ) + if( aReporter ) { wxString padname; for( i = 0; i < aNetlist.GetCount(); i++ ) @@ -2587,11 +2576,11 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, continue; // OK, pad found // not found: bad footprint, report error - msg.Printf( _( "*** Error: Component '%s' pad '%s' not found in footprint '%s' ***\n" ), + msg.Printf( _( "Component '%s' pad '%s' not found in footprint '%s'\n" ), GetChars( component->GetReference() ), GetChars( padname ), GetChars( footprint->GetFPID().Format() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ERROR ); } } @@ -2605,9 +2594,9 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, if( zone->GetNet()->GetNodesCount() == 0 ) { - msg.Printf( _( "* Warning: copper zone (net name '%s'): net has no pad*\n" ), + msg.Printf( _( "Copper zone (net name '%s'): net has no pads connected." ), GetChars( zone->GetNet()->GetNetname() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_WARNING ); } } } diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index 4317bbbfb0..e78fb133ee 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -46,6 +46,7 @@ #include #include #include +#include class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base @@ -266,7 +267,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) wxFileName outputDir = wxFileName::DirName( m_outputDirectory ); wxString boardFilename = m_board->GetFileName(); - WX_TEXT_CTRL_REPORTER reporter( m_messagesBox ); + REPORTER& reporter = m_messagesPanel->Reporter(); if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) ) { @@ -301,15 +302,15 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) if( CreateSVGFile( fn.GetFullPath(), aOnlyOneFile ) ) { - m_messagesBox->AppendText( - wxString::Format( _( "Plot: '%s' OK\n" ), GetChars( fn.GetFullPath() ) ) - ); + reporter.Report ( + wxString::Format( _( "Plot: '%s' OK." ), GetChars( fn.GetFullPath() ) ), + REPORTER::RPT_ACTION ); } else // Error { - m_messagesBox->AppendText( - wxString::Format( _( "** Unable to create '%s'**\n" ), GetChars( fn.GetFullPath() ) ) - ); + reporter.Report ( + wxString::Format( _( "Unable to create file '%s'." ), GetChars( fn.GetFullPath() ) ), + REPORTER::RPT_ERROR ); } if( aOnlyOneFile ) diff --git a/pcbnew/dialogs/dialog_SVG_print_base.cpp b/pcbnew/dialogs/dialog_SVG_print_base.cpp index d7c5b85a0d..cdde6630b4 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.cpp +++ b/pcbnew/dialogs/dialog_SVG_print_base.cpp @@ -1,10 +1,12 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 6 2013) +// C++ code generated with wxFormBuilder (version Jun 6 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "wx_html_report_panel.h" + #include "dialog_SVG_print_base.h" /////////////////////////////////////////////////////////////////////////// @@ -117,14 +119,16 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c bMainSizer->Add( bUpperSizer, 0, wxEXPAND, 5 ); - m_staticText2 = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText2->Wrap( -1 ); - bMainSizer->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + wxBoxSizer* bSizer5; + bSizer5 = new wxBoxSizer( wxVERTICAL ); - m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); - m_messagesBox->SetMinSize( wxSize( -1,150 ) ); + m_messagesPanel = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_messagesPanel->SetMinSize( wxSize( 300,150 ) ); - bMainSizer->Add( m_messagesBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + bSizer5->Add( m_messagesPanel, 1, wxEXPAND | wxALL, 5 ); + + + bMainSizer->Add( bSizer5, 1, wxEXPAND, 5 ); this->SetSizer( bMainSizer ); diff --git a/pcbnew/dialogs/dialog_SVG_print_base.fbp b/pcbnew/dialogs/dialog_SVG_print_base.fbp index d9d3c83a5a..852ecb9472 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.fbp +++ b/pcbnew/dialogs/dialog_SVG_print_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -1242,176 +1242,93 @@ 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Messages: - - 0 - - - 0 - - 1 - m_staticText2 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + wxEXPAND 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - -1,150 - 1 - m_messagesBox - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_MULTILINE|wxTE_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + bSizer5 + wxVERTICAL + none + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 300,150 + 1 + m_messagesPanel + 1 + + + protected + 1 + + Resizable + 1 + + WX_HTML_REPORT_PANEL; wx_html_report_panel.h + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_SVG_print_base.h b/pcbnew/dialogs/dialog_SVG_print_base.h index e3858e6d0b..a47a04daec 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.h +++ b/pcbnew/dialogs/dialog_SVG_print_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 6 2013) +// C++ code generated with wxFormBuilder (version Jun 6 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -12,6 +12,7 @@ #include #include class DIALOG_SHIM; +class WX_HTML_REPORT_PANEL; #include "dialog_shim.h" #include @@ -26,6 +27,7 @@ class DIALOG_SHIM; #include #include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -57,8 +59,7 @@ class DIALOG_SVG_PRINT_base : public DIALOG_SHIM wxRadioBox* m_rbFileOpt; wxButton* m_buttonCreateFile; wxButton* m_buttonQuit; - wxStaticText* m_staticText2; - wxTextCtrl* m_messagesBox; + WX_HTML_REPORT_PANEL* m_messagesPanel; // Virtual event handlers, overide them in your derived class virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); } diff --git a/pcbnew/dialogs/dialog_gen_module_position_file_base.cpp b/pcbnew/dialogs/dialog_gen_module_position_file_base.cpp index b9a7f29779..352459a90d 100644 --- a/pcbnew/dialogs/dialog_gen_module_position_file_base.cpp +++ b/pcbnew/dialogs/dialog_gen_module_position_file_base.cpp @@ -5,6 +5,8 @@ // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "wx_html_report_panel.h" + #include "dialog_gen_module_position_file_base.h" /////////////////////////////////////////////////////////////////////////// @@ -29,6 +31,7 @@ DIALOG_GEN_MODULE_POSITION_BASE::DIALOG_GEN_MODULE_POSITION_BASE( wxWindow* pare bSizerdirBrowse = new wxBoxSizer( wxHORIZONTAL ); m_outputDirectoryName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_outputDirectoryName->SetMaxLength( 0 ); m_outputDirectoryName->SetToolTip( _("Target directory for plot files. Can be absolute or relative to the board file location.") ); m_outputDirectoryName->SetMinSize( wxSize( 350,-1 ) ); @@ -74,16 +77,16 @@ DIALOG_GEN_MODULE_POSITION_BASE::DIALOG_GEN_MODULE_POSITION_BASE( wxWindow* pare m_MainSizer->Add( bSizerOptions, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - wxStaticBoxSizer* sbSizerMsg; - sbSizerMsg = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Messages:") ), wxVERTICAL ); + wxBoxSizer* bSizer7; + bSizer7 = new wxBoxSizer( wxVERTICAL ); - m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), wxTE_MULTILINE|wxTE_READONLY ); - m_messagesBox->SetMinSize( wxSize( -1,150 ) ); + m_messagesPanel = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_messagesPanel->SetMinSize( wxSize( 300,150 ) ); - sbSizerMsg->Add( m_messagesBox, 1, wxEXPAND, 5 ); + bSizer7->Add( m_messagesPanel, 1, wxEXPAND | wxALL, 5 ); - m_MainSizer->Add( sbSizerMsg, 1, wxEXPAND, 5 ); + m_MainSizer->Add( bSizer7, 1, wxEXPAND, 5 ); m_sdbSizerButtons = new wxStdDialogButtonSizer(); m_sdbSizerButtonsOK = new wxButton( this, wxID_OK ); @@ -101,6 +104,8 @@ DIALOG_GEN_MODULE_POSITION_BASE::DIALOG_GEN_MODULE_POSITION_BASE( wxWindow* pare this->Centre( wxBOTH ); // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GEN_MODULE_POSITION_BASE::OnClose ) ); + this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GEN_MODULE_POSITION_BASE::OnInitDialog ) ); m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_MODULE_POSITION_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); m_sdbSizerButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_MODULE_POSITION_BASE::OnOKButton ), NULL, this ); } @@ -108,6 +113,8 @@ DIALOG_GEN_MODULE_POSITION_BASE::DIALOG_GEN_MODULE_POSITION_BASE( wxWindow* pare DIALOG_GEN_MODULE_POSITION_BASE::~DIALOG_GEN_MODULE_POSITION_BASE() { // Disconnect Events + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GEN_MODULE_POSITION_BASE::OnClose ) ); + this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GEN_MODULE_POSITION_BASE::OnInitDialog ) ); m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_MODULE_POSITION_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); m_sdbSizerButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_MODULE_POSITION_BASE::OnOKButton ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_gen_module_position_file_base.fbp b/pcbnew/dialogs/dialog_gen_module_position_file_base.fbp index 603359af37..6b5131a5ab 100644 --- a/pcbnew/dialogs/dialog_gen_module_position_file_base.fbp +++ b/pcbnew/dialogs/dialog_gen_module_position_file_base.fbp @@ -47,7 +47,7 @@ 510,351 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h - Position Files: + Generate Component Position Files @@ -61,13 +61,13 @@ - + OnClose - + OnInitDialog @@ -238,7 +238,7 @@ 0 - + 0 0 350,-1 @@ -673,19 +673,16 @@ 5 wxEXPAND 1 - - wxID_ANY - Messages: + - sbSizerMsg + bSizer7 wxVERTICAL none - - + 5 - wxEXPAND + wxEXPAND | wxALL 1 - + 1 1 1 @@ -716,12 +713,11 @@ 0 - 0 - -1,150 + 300,150 1 - m_messagesBox + m_messagesPanel 1 @@ -730,19 +726,13 @@ Resizable 1 - -1,-1 - wxTE_MULTILINE|wxTE_READONLY - + + WX_HTML_REPORT_PANEL; wx_html_report_panel.h 0 - - wxFILTER_NONE - wxDefaultValidator - - - + wxTAB_TRAVERSAL @@ -765,10 +755,6 @@ - - - - diff --git a/pcbnew/dialogs/dialog_gen_module_position_file_base.h b/pcbnew/dialogs/dialog_gen_module_position_file_base.h index b00598c4bc..72a4bd9577 100644 --- a/pcbnew/dialogs/dialog_gen_module_position_file_base.h +++ b/pcbnew/dialogs/dialog_gen_module_position_file_base.h @@ -12,6 +12,7 @@ #include #include class DIALOG_SHIM; +class WX_HTML_REPORT_PANEL; #include "dialog_shim.h" #include @@ -24,7 +25,7 @@ class DIALOG_SHIM; #include #include #include -#include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -44,19 +45,21 @@ class DIALOG_GEN_MODULE_POSITION_BASE : public DIALOG_SHIM wxRadioBox* m_radioBoxUnits; wxRadioBox* m_radioBoxFilesCount; wxRadioBox* m_radioBoxForceSmd; - wxTextCtrl* m_messagesBox; + WX_HTML_REPORT_PANEL* m_messagesPanel; wxStdDialogButtonSizer* m_sdbSizerButtons; wxButton* m_sdbSizerButtonsOK; wxButton* m_sdbSizerButtonsCancel; // Virtual event handlers, overide them in your derived class + virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } + virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); } virtual void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); } virtual void OnOKButton( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_GEN_MODULE_POSITION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Position Files:"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 510,351 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_GEN_MODULE_POSITION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Generate Component Position Files"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 510,351 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_GEN_MODULE_POSITION_BASE(); }; diff --git a/pcbnew/dialogs/dialog_netlist.cpp b/pcbnew/dialogs/dialog_netlist.cpp index 92803a5279..5e1202e6e0 100644 --- a/pcbnew/dialogs/dialog_netlist.cpp +++ b/pcbnew/dialogs/dialog_netlist.cpp @@ -47,6 +47,7 @@ #include #include +#include #define NETLIST_SILENTMODE_KEY wxT("SilentMode") #define NETLIST_FULLMESSAGES_KEY wxT("NetlistReportAllMsg") @@ -158,21 +159,20 @@ void DIALOG_NETLIST::OnReadNetlistFileClick( wxCommandEvent& event ) "sure you want to read the netlist?" ) ) ) return; - wxBusyCursor busy; m_MessageWindow->Clear(); + REPORTER& reporter = m_MessageWindow->Reporter(); + + wxBusyCursor busy; msg.Printf( _( "Reading netlist file \"%s\".\n" ), GetChars( netlistFileName ) ); - m_MessageWindow->AppendText( msg ); + reporter.Report( msg, REPORTER::RPT_INFO ); if( m_Select_By_Timestamp->GetSelection() == 1 ) msg = _( "Using time stamps to match components and footprints.\n" ); else msg = _( "Using references to match components and footprints.\n" ); - m_MessageWindow->AppendText( msg ); - - WX_TEXT_CTRL_REPORTER reporter( m_MessageWindow ); - reporter.SetReportAll( m_reportAll ); + reporter.Report( msg, REPORTER::RPT_INFO ); m_parent->ReadPcbNetlist( netlistFileName, wxEmptyString, &reporter, m_ChangeExistingFootprintCtrl->GetSelection() == 1, @@ -357,13 +357,13 @@ void DIALOG_NETLIST::OnSaveMessagesToFile( wxCommandEvent& aEvent ) return; } - f.Write( m_MessageWindow->GetValue() ); + //f.Write( m_MessageWindow->GetValue() ); } void DIALOG_NETLIST::OnUpdateUISaveMessagesToFile( wxUpdateUIEvent& aEvent ) { - aEvent.Enable( !m_MessageWindow->IsEmpty() ); + //aEvent.Enable( !m_MessageWindow->IsEmpty() ); } @@ -409,19 +409,6 @@ bool DIALOG_NETLIST::verifyFootprints( const wxString& aNetlistFilename, return false; } -#if defined( DEBUG ) - { - m_MessageWindow->Clear(); - WX_TEXT_CTRL_REPORTER rpt( m_MessageWindow ); - - STRING_FORMATTER sf; - - netlist.Format( "netlist_stuff", &sf, 0 ); - - rpt.Report( FROM_UTF8( sf.GetString().c_str() ) ); - } -#endif - BOARD* pcb = m_parent->GetBoard(); // Search for duplicate footprints. diff --git a/pcbnew/dialogs/dialog_netlist_fbp.cpp b/pcbnew/dialogs/dialog_netlist_fbp.cpp index c4280f1280..af2b8fdacd 100644 --- a/pcbnew/dialogs/dialog_netlist_fbp.cpp +++ b/pcbnew/dialogs/dialog_netlist_fbp.cpp @@ -5,6 +5,8 @@ // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "wx_html_report_panel.h" + #include "dialog_netlist_fbp.h" /////////////////////////////////////////////////////////////////////////// @@ -159,14 +161,10 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w bLowerSizer->Add( bSizerNetlistFilename, 0, wxEXPAND, 5 ); - m_staticText1 = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText1->Wrap( -1 ); - bLowerSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + m_MessageWindow = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_MessageWindow->SetMinSize( wxSize( -300,150 ) ); - m_MessageWindow = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CHARWRAP|wxTE_MULTILINE|wxTE_READONLY|wxTE_WORDWRAP ); - m_MessageWindow->SetMinSize( wxSize( 300,150 ) ); - - bLowerSizer->Add( m_MessageWindow, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bLowerSizer->Add( m_MessageWindow, 1, wxEXPAND | wxALL, 5 ); bMainSizer->Add( bLowerSizer, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); diff --git a/pcbnew/dialogs/dialog_netlist_fbp.fbp b/pcbnew/dialogs/dialog_netlist_fbp.fbp index 046362c4e8..6d24370836 100644 --- a/pcbnew/dialogs/dialog_netlist_fbp.fbp +++ b/pcbnew/dialogs/dialog_netlist_fbp.fbp @@ -1770,92 +1770,9 @@ 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Messages: - - 0 - - - 0 - - 1 - m_staticText1 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + wxEXPAND | wxALL 1 - + 1 1 1 @@ -1886,10 +1803,9 @@ 0 - 0 - 300,150 + -300,150 1 m_MessageWindow 1 @@ -1901,18 +1817,12 @@ Resizable 1 - wxTE_CHARWRAP|wxTE_MULTILINE|wxTE_READONLY|wxTE_WORDWRAP - + WX_HTML_REPORT_PANEL; wx_html_report_panel.h 0 - - wxFILTER_NONE - wxDefaultValidator - - - + wxTAB_TRAVERSAL @@ -1935,10 +1845,6 @@ - - - - diff --git a/pcbnew/dialogs/dialog_netlist_fbp.h b/pcbnew/dialogs/dialog_netlist_fbp.h index c707516f67..d35e9fdd72 100644 --- a/pcbnew/dialogs/dialog_netlist_fbp.h +++ b/pcbnew/dialogs/dialog_netlist_fbp.h @@ -12,6 +12,7 @@ #include #include class DIALOG_SHIM; +class WX_HTML_REPORT_PANEL; #include "dialog_shim.h" #include @@ -26,6 +27,7 @@ class DIALOG_SHIM; #include #include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -64,8 +66,7 @@ class DIALOG_NETLIST_FBP : public DIALOG_SHIM wxStaticText* m_staticTextNetfilename; wxTextCtrl* m_NetlistFilenameCtrl; wxButton* m_buttonBrowse; - wxStaticText* m_staticText1; - wxTextCtrl* m_MessageWindow; + WX_HTML_REPORT_PANEL* m_MessageWindow; // Virtual event handlers, overide them in your derived class virtual void OnReadNetlistFileClick( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 2ade29e32b..76ef3042ce 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -38,7 +38,7 @@ #include #include #include - +#include DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) : DIALOG_PLOT_BASE( aParent ), m_parent( aParent ), @@ -107,7 +107,7 @@ void DIALOG_PLOT::Init_Dialog() // Set units and value for HPGL pen size (this param in in mils). AddUnitSymbol( *m_textPenSize, g_UserUnit ); msg = StringFromValue( g_UserUnit, - m_plotOpts.GetHPGLPenDiameter() * IU_PER_MILS ); + m_plotOpts.GetHPGLPenDiameter() * IU_PER_MILS ); m_HPGLPenSizeOpt->AppendText( msg ); // Set units and value for HPGL pen overlay (this param in in mils). @@ -562,6 +562,8 @@ static bool setInt( int* aResult, int aValue, int aMin, int aMax ) void DIALOG_PLOT::applyPlotSettings() { + REPORTER& reporter = m_messagesPanel->Reporter(); + PCB_PLOT_PARAMS tempOptions; tempOptions.SetExcludeEdgeLayer( m_excludeEdgeLayerOpt->GetValue() ); @@ -590,8 +592,8 @@ void DIALOG_PLOT::applyPlotSettings() { msg = StringFromValue( g_UserUnit, tempOptions.GetHPGLPenDiameter() * IU_PER_MILS ); m_HPGLPenSizeOpt->SetValue( msg ); - msg.Printf( _( "HPGL pen size constrained!\n" ) ); - m_messagesBox->AppendText( msg ); + msg.Printf( _( "HPGL pen size constrained." ) ); + reporter.Report( msg, REPORTER::RPT_INFO ); } // Read HPGL pen overlay (this param is stored in mils) @@ -603,8 +605,8 @@ void DIALOG_PLOT::applyPlotSettings() msg = StringFromValue( g_UserUnit, tempOptions.GetHPGLPenOverlay() * IU_PER_MILS ); m_HPGLPenOverlayOpt->SetValue( msg ); - msg.Printf( _( "HPGL pen overlay constrained!\n" ) ); - m_messagesBox->AppendText( msg ); + msg.Printf( _( "HPGL pen overlay constrained." ) ); + reporter.Report( msg, REPORTER::RPT_INFO ); } // Default linewidth @@ -615,8 +617,8 @@ void DIALOG_PLOT::applyPlotSettings() { msg = StringFromValue( g_UserUnit, tempOptions.GetLineWidth() ); m_linesWidth->SetValue( msg ); - msg.Printf( _( "Default line width constrained!\n" ) ); - m_messagesBox->AppendText( msg ); + msg.Printf( _( "Default line width constrained." ) ); + reporter.Report( msg, REPORTER::RPT_INFO ); } // X scale @@ -628,8 +630,8 @@ void DIALOG_PLOT::applyPlotSettings() { msg.Printf( wxT( "%f" ), m_XScaleAdjust ); m_fineAdjustXscaleOpt->SetValue( msg ); - msg.Printf( _( "X scale constrained!\n" ) ); - m_messagesBox->AppendText( msg ); + msg.Printf( _( "X scale constrained." ) ); + reporter.Report( msg, REPORTER::RPT_INFO ); } ConfigBaseWriteDouble( m_config, OPTKEY_PLOT_X_FINESCALE_ADJ, m_XScaleAdjust ); @@ -642,8 +644,8 @@ void DIALOG_PLOT::applyPlotSettings() { msg.Printf( wxT( "%f" ), m_YScaleAdjust ); m_fineAdjustYscaleOpt->SetValue( msg ); - msg.Printf( _( "Y scale constrained!\n" ) ); - m_messagesBox->AppendText( msg ); + msg.Printf( _( "Y scale constrained." ) ); + reporter.Report( msg, REPORTER::RPT_INFO ); } ConfigBaseWriteDouble( m_config, OPTKEY_PLOT_Y_FINESCALE_ADJ, m_YScaleAdjust ); @@ -656,13 +658,13 @@ void DIALOG_PLOT::applyPlotSettings() { msg = StringFromValue( g_UserUnit, m_PSWidthAdjust ); m_PSFineAdjustWidthOpt->SetValue( msg ); - msg.Printf( _( "Width correction constrained!\n" - "The reasonable width correction value must be in a range of\n" - " [%+f; %+f] (%s) for current design rules!\n" ), + msg.Printf( _( "Width correction constrained. " + "The reasonable width correction value must be in a range of " + " [%+f; %+f] (%s) for current design rules. " ), To_User_Unit( g_UserUnit, m_widthAdjustMinValue ), To_User_Unit( g_UserUnit, m_widthAdjustMaxValue ), ( g_UserUnit == INCHES ) ? wxT( "\"" ) : wxT( "mm" ) ); - m_messagesBox->AppendText( msg ); + reporter.Report( msg, REPORTER::RPT_WARNING ); } // Store m_PSWidthAdjust in mm in user config @@ -708,9 +710,9 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) // Create output directory if it does not exist (also transform it in // absolute form). Bail if it fails - wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() ); - wxString boardFilename = m_parent->GetBoard()->GetFileName(); - WX_TEXT_CTRL_REPORTER reporter( m_messagesBox ); + wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() ); + wxString boardFilename = m_parent->GetBoard()->GetFileName(); + REPORTER& reporter = m_messagesPanel->Reporter(); if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) ) { @@ -809,13 +811,14 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) plotter->EndPlot(); delete plotter; - msg.Printf( _( "Plot file <%s> created" ), GetChars( fn.GetFullPath() ) ); + msg.Printf( _( "Plot file '%s' created." ), GetChars( fn.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ACTION ); } else - msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) ); - - msg << wxT( "\n" ); - m_messagesBox->AppendText( msg ); + { + msg.Printf( _( "Unable to create file '%s'." ), GetChars( fn.GetFullPath() ) ); + reporter.Report( msg, REPORTER::RPT_ERROR ); + } } // If no layer selected, we have nothing plotted. diff --git a/pcbnew/dialogs/dialog_plot_base.cpp b/pcbnew/dialogs/dialog_plot_base.cpp index 84f078bf0a..6031ac3c68 100644 --- a/pcbnew/dialogs/dialog_plot_base.cpp +++ b/pcbnew/dialogs/dialog_plot_base.cpp @@ -1,10 +1,12 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Jun 6 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "wx_html_report_panel.h" + #include "dialog_plot_base.h" /////////////////////////////////////////////////////////////////////////// @@ -363,13 +365,13 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr bSizer12->Add( bUpperSizer, 0, wxEXPAND, 5 ); - wxStaticBoxSizer* sbSizerMsg; - sbSizerMsg = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Messages:") ), wxVERTICAL ); + wxBoxSizer* sbSizerMsg; + sbSizerMsg = new wxBoxSizer( wxVERTICAL ); - m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); - m_messagesBox->SetMinSize( wxSize( -1,150 ) ); + m_messagesPanel = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_messagesPanel->SetMinSize( wxSize( -300,150 ) ); - sbSizerMsg->Add( m_messagesBox, 1, wxEXPAND, 5 ); + sbSizerMsg->Add( m_messagesPanel, 1, wxEXPAND | wxALL, 5 ); bSizer12->Add( sbSizerMsg, 1, wxEXPAND, 5 ); @@ -390,6 +392,12 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr bSizer12->Add( bSizerButtons, 0, wxALIGN_RIGHT|wxRIGHT|wxLEFT, 5 ); + wxBoxSizer* bSizer221; + bSizer221 = new wxBoxSizer( wxVERTICAL ); + + + bSizer12->Add( bSizer221, 1, wxEXPAND, 5 ); + m_MainSizer->Add( bSizer12, 1, wxALL|wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_plot_base.fbp b/pcbnew/dialogs/dialog_plot_base.fbp index 3a0c9933aa..bf86d06ddc 100644 --- a/pcbnew/dialogs/dialog_plot_base.fbp +++ b/pcbnew/dialogs/dialog_plot_base.fbp @@ -88,16 +88,16 @@ - + m_MainSizer wxHORIZONTAL protected - + 5 wxALL|wxEXPAND 1 - + bSizer12 wxVERTICAL @@ -4124,23 +4124,20 @@ - + 5 wxEXPAND 1 - - wxID_ANY - Messages: + sbSizerMsg wxVERTICAL none - - + 5 - wxEXPAND + wxEXPAND | wxALL 1 - + 1 1 1 @@ -4171,12 +4168,11 @@ 0 - 0 - -1,150 + -300,150 1 - m_messagesBox + m_messagesPanel 1 @@ -4186,18 +4182,12 @@ Resizable 1 - wxTE_MULTILINE|wxTE_READONLY - + WX_HTML_REPORT_PANEL; wx_html_report_panel.h 0 - - wxFILTER_NONE - wxDefaultValidator - - - + wxTAB_TRAVERSAL @@ -4220,20 +4210,16 @@ - - - - - + 5 wxALIGN_RIGHT|wxRIGHT|wxLEFT 0 - + bSizerButtons wxHORIZONTAL @@ -4504,6 +4490,17 @@ + + 5 + wxEXPAND + 1 + + + bSizer221 + wxVERTICAL + none + + diff --git a/pcbnew/dialogs/dialog_plot_base.h b/pcbnew/dialogs/dialog_plot_base.h index 13c4972a29..0926602940 100644 --- a/pcbnew/dialogs/dialog_plot_base.h +++ b/pcbnew/dialogs/dialog_plot_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Jun 6 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -12,6 +12,7 @@ #include #include class DIALOG_SHIM; +class WX_HTML_REPORT_PANEL; #include "dialog_shim.h" #include @@ -28,6 +29,7 @@ class DIALOG_SHIM; #include #include #include +#include #include #include #include @@ -106,7 +108,7 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM wxStaticText* m_textPSFineAdjustWidth; wxTextCtrl* m_PSFineAdjustWidthOpt; wxCheckBox* m_forcePSA4OutputOpt; - wxTextCtrl* m_messagesBox; + WX_HTML_REPORT_PANEL* m_messagesPanel; wxButton* m_plotButton; wxButton* m_buttonDrill; wxButton* m_buttonQuit; diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index 1e62bc29b5..17ef1cfc27 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -269,10 +269,10 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, TextWidth, false, false ); - intervalle = KiROUND( (( charSize * charScale ) + TextWidth) * 1.2); + intervalle = KiROUND( ( ( charSize * charScale ) + TextWidth ) * 1.2 ); - if( intervalle < (plot_diam + (1 * IU_PER_MM / scale) + TextWidth) ) - intervalle = plot_diam + (1 * IU_PER_MM / scale) + TextWidth; + if( intervalle < ( plot_diam + ( 1 * IU_PER_MM / scale ) + TextWidth ) ) + intervalle = plot_diam + ( 1 * IU_PER_MM / scale ) + TextWidth; } plotter->EndPlot(); diff --git a/pcbnew/exporters/gen_modules_placefile.cpp b/pcbnew/exporters/gen_modules_placefile.cpp index 51f2202dbb..4976796455 100644 --- a/pcbnew/exporters/gen_modules_placefile.cpp +++ b/pcbnew/exporters/gen_modules_placefile.cpp @@ -50,6 +50,8 @@ #include #include #include +#include + #include /* @@ -107,11 +109,12 @@ private: PCB_EDIT_FRAME* m_parent; PCB_PLOT_PARAMS m_plotOpts; wxConfigBase* m_config; + REPORTER* m_reporter; static int m_unitsOpt; static int m_fileOpt; - void initDialog(); + void initDialog(); void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ); void OnOKButton( wxCommandEvent& event ); @@ -137,11 +140,6 @@ private: { return m_radioBoxForceSmd->GetSelection() == 1; } - - void AddMessage( const wxString & aMessage ) - { - m_messagesBox->AppendText( aMessage ); - } }; @@ -241,9 +239,10 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles() // absolute form). Bail if it fails wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() ); wxString boardFilename = m_parent->GetBoard()->GetFileName(); - WX_TEXT_CTRL_REPORTER reporter( m_messagesBox ); - if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) ) + m_reporter = &m_messagesPanel->Reporter(); + + if( !EnsureFileDirectoryExists( &outputDir, boardFilename, m_reporter ) ) { msg.Printf( _( "Could not write plot files to folder \"%s\"." ), GetChars( outputDir.GetPath() ) ); @@ -272,24 +271,27 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles() ForceAllSmd(), side ); if( fpcount < 0 ) { - msg.Printf( _( "Unable to create '%s'" ), GetChars( fn.GetFullPath() ) ); + msg.Printf( _( "Unable to create '%s'." ), GetChars( fn.GetFullPath() ) ); wxMessageBox( msg ); - AddMessage( msg + wxT("\n") ); + m_reporter->Report( msg, REPORTER::RPT_ERROR ); return false; } if( singleFile ) - msg.Printf( _( "Place file: '%s'\n" ), GetChars( fn.GetFullPath() ) ); + msg.Printf( _( "Place file: '%s'." ), GetChars( fn.GetFullPath() ) ); else - msg.Printf( _( "Front side (top side) place file: '%s'\n" ), + msg.Printf( _( "Front side (top side) place file: '%s'." ), GetChars( fn.GetFullPath() ) ); + m_reporter->Report( msg, REPORTER::RPT_INFO ); - AddMessage( msg ); - msg.Printf( _( "Footprint count %d\n" ), fpcount ); - AddMessage( msg ); + msg.Printf( _( "Component count: %d." ), fpcount ); + m_reporter->Report( msg, REPORTER::RPT_INFO ); if( singleFile ) + { + m_reporter->Report( _( "Componment Placement File generation OK." ), REPORTER::RPT_ACTION ); return true; + } // Create the Back or Bottom side placement file fullcount = fpcount; @@ -304,8 +306,8 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles() if( fpcount < 0 ) { - msg.Printf( _( "Unable to create '%s'" ), GetChars( fn.GetFullPath() ) ); - AddMessage( msg + wxT("\n") ); + msg.Printf( _( "Unable to create file '%s'." ), GetChars( fn.GetFullPath() ) ); + m_reporter->Report( msg, REPORTER::RPT_ERROR ); wxMessageBox( msg ); return false; } @@ -313,19 +315,23 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles() // Display results if( !singleFile ) { - msg.Printf( _( "Back side (bottom side) place file: '%s'\n" ), GetChars( fn.GetFullPath() ) ); - AddMessage( msg ); - msg.Printf( _( "Footprint count %d\n" ), fpcount ); - AddMessage( msg ); + msg.Printf( _( "Back side (bottom side) place file: '%s'." ), GetChars( fn.GetFullPath() ) ); + m_reporter->Report( msg, REPORTER::RPT_INFO ); + + msg.Printf( _( "Component count: %d." ), fpcount ); + + m_reporter->Report( msg, REPORTER::RPT_INFO ); } if( !singleFile ) { fullcount += fpcount; - msg.Printf( _( "Full footprint count %d\n" ), fullcount ); - AddMessage( msg ); + msg.Printf( _( "Full component count: %d\n" ), fullcount ); + m_reporter->Report( msg, REPORTER::RPT_INFO ); } + m_reporter->Report( _( "Componment Placement File generation OK." ), REPORTER::RPT_ACTION ); + return true; } diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index a8d1bb21de..bdba316c2c 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -224,7 +224,7 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter ) { msg.Printf( _( "No footprint defined for component '%s'.\n" ), GetChars( component->GetReference() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ERROR ); } continue; @@ -273,11 +273,11 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter ) { if( aReporter ) { - msg.Printf( _( "*** Warning: Component '%s' footprint ID '%s' is not " - "valid. ***\n" ), + msg.Printf( _( "Component '%s' footprint ID '%s' is not " + "valid.\n" ), GetChars( component->GetReference() ), GetChars( component->GetFPID().Format() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ERROR ); } continue; @@ -295,11 +295,11 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter ) if( aReporter ) { wxString msg; - msg.Printf( _( "*** Warning: component '%s' footprint '%s' was not found in " - "any libraries in the footprint library table. ***\n" ), + msg.Printf( _( "Component '%s' footprint '%s' was not found in " + "any libraries in the footprint library table.\n" ), GetChars( component->GetReference() ), GetChars( component->GetFPID().GetFootprintName() ) ); - aReporter->Report( msg ); + aReporter->Report( msg, REPORTER::RPT_ERROR ); } continue;