Proper error reporting for Annotate dialog.

Also fixes:
- forcing the annotation scope to "full schematic" when run
  as a prerequisite to Generate Netlist.

- a long-standing bug where displaying extra items in a dialog
  would mess up the height of the HTML_REPORT_PANEL (becasue
  we were setting the html window's height rather than its
  parent flexgrid.

- initializing the annotation radio buttons to safe values
  (full schematic and keep existing)

Fixes: lp:1750062
* https://bugs.launchpad.net/kicad/+bug/1750062
This commit is contained in:
Jeff Young 2018-02-17 11:43:56 +00:00 committed by Wayne Stambaugh
parent cf5d93857f
commit b3884669cf
23 changed files with 1299 additions and 2454 deletions

View File

@ -61,7 +61,7 @@ public:
return *this;
}
bool HasMessage() const { return m_hasMessage; }
bool HasMessage() const override { return m_hasMessage; }
};

View File

@ -47,7 +47,7 @@ WX_HTML_REPORT_PANEL::~WX_HTML_REPORT_PANEL()
void WX_HTML_REPORT_PANEL::MsgPanelSetMinSize( const wxSize& aMinSize )
{
m_htmlView->SetMinSize( aMinSize );
m_fgSizer->SetMinSize( aMinSize );
GetSizer()->SetSizeHints( this );
}
@ -126,6 +126,18 @@ wxString WX_HTML_REPORT_PANEL::addHeader( const wxString& aBody )
}
int WX_HTML_REPORT_PANEL::Count( int severityMask )
{
int count = 0;
for( const REPORT_LINE& reportLine : m_report )
if( severityMask & reportLine.severity )
count++;
return count;
}
wxString WX_HTML_REPORT_PANEL::generateHtml( const REPORT_LINE& aLine )
{
wxString retv;

View File

@ -58,6 +58,9 @@ public:
///> clears the report panel
void Clear();
///> return the number of messages matching the given severity mask.
int Count( int severityMask );
///> sets the frame label
void SetLabel( const wxString& aLabel ) override;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -13,18 +13,17 @@ WX_HTML_REPORT_PANEL_BASE::WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindow
{
m_box = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Output 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_fgSizer = new wxFlexGridSizer( 2, 1, 0, 0 );
m_fgSizer->AddGrowableCol( 0 );
m_fgSizer->AddGrowableRow( 0 );
m_fgSizer->SetFlexibleDirection( wxBOTH );
m_fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_htmlView = new wxHtmlWindow( m_box->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
m_htmlView->SetFont( wxFont( 10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
m_htmlView->SetMinSize( wxSize( -1,200 ) );
m_htmlView->SetMinSize( wxSize( -1,100 ) );
fgSizer4->Add( m_htmlView, 1, wxEXPAND, 5 );
m_fgSizer->Add( m_htmlView, 1, wxEXPAND, 5 );
wxFlexGridSizer* fgSizer3;
fgSizer3 = new wxFlexGridSizer( 1, 7, 0, 0 );
@ -60,14 +59,14 @@ WX_HTML_REPORT_PANEL_BASE::WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindow
fgSizer3->Add( m_checkBoxShowActions, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_btnSaveReportToFile = new wxButton( m_box->GetStaticBox(), wxID_ANY, _("Save Report File..."), wxDefaultPosition, wxDefaultSize, 0 );
m_btnSaveReportToFile = new wxButton( m_box->GetStaticBox(), wxID_ANY, _("Save Report File"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer3->Add( m_btnSaveReportToFile, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxLEFT, 5 );
fgSizer4->Add( fgSizer3, 1, wxEXPAND, 5 );
m_fgSizer->Add( fgSizer3, 1, wxEXPAND, 5 );
m_box->Add( fgSizer4, 1, wxEXPAND|wxALL, 5 );
m_box->Add( m_fgSizer, 1, wxEXPAND|wxALL, 5 );
this->SetSizer( m_box );

View File

@ -98,9 +98,9 @@
<property name="growablerows">0</property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizer4</property>
<property name="name">m_fgSizer</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<property name="rows">2</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">
@ -140,7 +140,7 @@
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">-1,200</property>
<property name="minimum_size">-1,100</property>
<property name="moveable">1</property>
<property name="name">m_htmlView</property>
<property name="pane_border">1</property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -36,6 +36,7 @@ class WX_HTML_REPORT_PANEL_BASE : public wxPanel
protected:
wxStaticBoxSizer* m_box;
wxFlexGridSizer* m_fgSizer;
wxHtmlWindow* m_htmlView;
wxStaticText* m_staticText3;
wxCheckBox* m_checkBoxShowAll;

View File

@ -45,6 +45,11 @@ REPORTER& WX_TEXT_CTRL_REPORTER::Report( const wxString& aText, REPORTER::SEVERI
return *this;
}
bool WX_TEXT_CTRL_REPORTER::HasMessage() const
{
return !m_textCtrl->IsEmpty();
}
REPORTER& WX_STRING_REPORTER::Report( const wxString& aText, REPORTER::SEVERITY aSeverity )
{
wxCHECK_MSG( m_string != NULL, *this,
@ -54,6 +59,11 @@ REPORTER& WX_STRING_REPORTER::Report( const wxString& aText, REPORTER::SEVERITY
return *this;
}
bool WX_STRING_REPORTER::HasMessage() const
{
return !m_string->IsEmpty();
}
REPORTER& WX_HTML_PANEL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{
wxCHECK_MSG( m_panel != NULL, *this,
@ -63,6 +73,11 @@ REPORTER& WX_HTML_PANEL_REPORTER::Report( const wxString& aText, SEVERITY aSever
return *this;
}
bool WX_HTML_PANEL_REPORTER::HasMessage() const
{
return m_panel->Count( REPORTER::RPT_ERROR | REPORTER::RPT_WARNING ) > 0;
}
REPORTER& NULL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{
return *this;

View File

@ -31,11 +31,31 @@
#include <fctsys.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <reporter.h>
#include <sch_edit_frame.h>
#include <sch_reference_list.h>
#include <class_library.h>
void mapExistingAnnotation( std::map<timestamp_t, wxString>& aMap )
{
SCH_SHEET_LIST sheets( g_RootSheet );
SCH_REFERENCE_LIST references;
sheets.GetComponents( references );
for( size_t i = 0; i < references.GetCount(); i++ )
{
SCH_COMPONENT* comp = references[ i ].GetComp();
wxString ref = comp->GetField( REFERENCE )->GetFullyQualifiedText();
if( !ref.Contains( wxT( "?" ) ) )
aMap[ comp->GetTimeStamp() ] = ref;
}
}
void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly )
{
if( aCurrentSheetOnly )
@ -62,7 +82,8 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
ANNOTATE_OPTION_T aAlgoOption,
bool aResetAnnotation,
bool aRepairTimestamps,
bool aLockUnits )
bool aLockUnits,
REPORTER& aReporter )
{
SCH_REFERENCE_LIST references;
@ -74,6 +95,9 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
// Map of locked components
SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;
// Map of previous annotation for building info messages
std::map<timestamp_t, wxString> previousAnnotation;
// Test for and replace duplicate time stamps in components and sheets. Duplicate
// time stamps can happen with old schematics, schematic conversions, or manual
// editing of files.
@ -85,7 +109,7 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
{
wxString msg;
msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
DisplayInfoMessage( NULL, msg );
aReporter.Report( msg, REPORTER::RPT_INFO );
}
}
@ -102,6 +126,9 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
}
}
// Store previous annotations for building info messages
mapExistingAnnotation( previousAnnotation );
// If it is an annotation for all the components, reset previous annotation.
if( aResetAnnotation )
DeleteAnnotation( !aAnnotateSchematic );
@ -158,21 +185,49 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
references.Annotate( useSheetNum, idStep, lockedComponents );
references.UpdateAnnotation();
wxArrayString errors;
for( size_t i = 0; i < references.GetCount(); i++ )
{
SCH_COMPONENT* comp = references[ i ].GetComp();
wxString prevRef = previousAnnotation[ comp->GetTimeStamp() ];
wxString newRef = comp->GetField( REFERENCE )->GetFullyQualifiedText();
wxString msg;
if( prevRef.Length() )
{
if( newRef == prevRef )
continue;
if( comp->GetUnitCount() > 1 )
msg.Printf( _( "Updated %s (unit %d) from %s to %s" ),
GetChars( comp->GetField( VALUE )->GetShownText() ),
comp->GetUnit(),
GetChars( prevRef ),
GetChars( newRef ) );
else
msg.Printf( _( "Updated %s from %s to %s" ),
GetChars( comp->GetField( VALUE )->GetShownText() ),
GetChars( prevRef ),
GetChars( newRef ) );
}
else
{
if( comp->GetUnitCount() > 1 )
msg.Printf( _( "Annotated %s (unit %d) as %s" ),
GetChars( comp->GetField( VALUE )->GetShownText() ),
comp->GetUnit(),
GetChars( newRef ) );
else
msg.Printf( _( "Annotated %s as %s" ),
GetChars( comp->GetField( VALUE )->GetShownText() ),
GetChars( newRef ) );
}
aReporter.Report( msg, REPORTER::RPT_INFO );
}
// Final control (just in case ... ).
if( CheckAnnotate( &errors, !aAnnotateSchematic ) )
{
wxString msg;
for( size_t i = 0; i < errors.GetCount(); i++ )
msg += errors[i];
// wxLogWarning is a cheap and dirty way to dump a potentially long list of
// strings to a dialog that can be saved to a file. This should be replaced
// by a more elegant solution.
wxLogWarning( msg );
}
if( !CheckAnnotate( aReporter, !aAnnotateSchematic ) )
aReporter.Report( _( "Annotation complete." ), REPORTER::RPT_INFO );
OnModify();
@ -184,7 +239,7 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
}
int SCH_EDIT_FRAME::CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly )
int SCH_EDIT_FRAME::CheckAnnotate( REPORTER& aReporter, bool aOneSheetOnly )
{
// build the screen list
SCH_SHEET_LIST sheetList( g_RootSheet );
@ -196,5 +251,5 @@ int SCH_EDIT_FRAME::CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOn
else
m_CurrentSheet->GetComponents( componentsList );
return componentsList.CheckAnnotation( aMessageList );
return componentsList.CheckAnnotation( aReporter );
}

View File

@ -38,6 +38,7 @@
#include <sch_edit_frame.h>
#include <sch_reference_list.h>
#include <sch_component.h>
#include <reporter.h>
//#define USE_OLD_ALGO
@ -472,7 +473,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
}
int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
int SCH_REFERENCE_LIST::CheckAnnotation( REPORTER& aReporter )
{
int error = 0;
wxString tmp;
@ -512,9 +513,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
GetChars( tmp ) );
}
if( aMessageList )
aMessageList->Add( msg + wxT( "\n" ) );
aReporter.Report( msg, REPORTER::RPT_WARNING );
error++;
break;
}
@ -536,9 +535,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
componentFlatList[ii].m_Unit,
componentFlatList[ii].GetLibPart()->GetUnitCount() );
if( aMessageList )
aMessageList->Add( msg );
aReporter.Report( msg, REPORTER::RPT_ERROR );
error++;
break;
}
@ -582,9 +579,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
GetChars( tmp ) );
}
if( aMessageList )
aMessageList->Add( msg );
aReporter.Report( msg, REPORTER::RPT_ERROR );
error++;
continue;
}
@ -614,9 +609,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
GetChars( tmp ) );
}
if( aMessageList )
aMessageList->Add( msg );
aReporter.Report( msg, REPORTER::RPT_ERROR );
error++;
}
@ -637,9 +630,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
componentFlatList[next].m_Unit ) ),
GetChars( componentFlatList[next].m_Value->GetText() ) );
if( aMessageList )
aMessageList->Add( msg + wxT( "\n" ));
aReporter.Report( msg, REPORTER::RPT_ERROR );
error++;
}
}
@ -666,9 +657,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
GetChars( componentFlatList[ii + 1].GetRef() ),
componentFlatList[ii + 1].m_NumRef );
if( aMessageList )
aMessageList->Add( msg + wxT( "\n" ));
aReporter.Report( msg, REPORTER::RPT_WARNING );
error++;
}

View File

@ -36,11 +36,13 @@
#include <invoke_sch_dialog.h>
#include <dialog_annotate_base.h>
#include <kiface_i.h>
#include <wx_html_report_panel.h>
#define KEY_ANNOTATE_SORT_OPTION wxT( "AnnotateSortOption" )
#define KEY_ANNOTATE_ALGO_OPTION wxT( "AnnotateAlgoOption" )
#define KEY_ANNOTATE_KEEP_OPEN_OPTION wxT( "AnnotateKeepOpenOption" )
#define KEY_ANNOTATE_ASK_FOR_CONFIRMATION wxT( "AnnotateRequestConfirmation" )
#define KEY_ANNOTATE_MESSAGES_FILTER wxT( "AnnotateFilterMsg" )
class wxConfigBase;
@ -53,7 +55,7 @@ class DIALOG_ANNOTATE: public DIALOG_ANNOTATE_BASE
{
public:
DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, const wxString& message );
~DIALOG_ANNOTATE();
private:
SCH_EDIT_FRAME* m_Parent;
@ -61,7 +63,6 @@ private:
/// Initialises member variables
void InitValues();
void OnCancelClick( wxCommandEvent& event ) override;
void OnClearAnnotationCmpClick( wxCommandEvent& event ) override;
void OnApplyClick( wxCommandEvent& event ) override;
@ -74,15 +75,14 @@ private:
* Function GetSortOrder
* @return 0 if annotation by X position,
* 1 if annotation by Y position,
* 2 if annotation by value
*/
int GetSortOrder();
/**
* Function GetAnnotateAlgo
* @return 0 if annotation using first not used Id value
* 1 if annotation using first not used Id value inside sheet num * 100 to sheet num * 100 + 99
* 2 if annotation using first nhot used Id value inside sheet num * 1000 to sheet num * 1000 + 999
* @return 0 if annotation using first free Id value
* 1 for first free Id value inside sheet num * 100 to sheet num * 100 + 99
* 2 for first free Id value inside sheet num * 1000 to sheet num * 1000 + 999
*/
int GetAnnotateAlgo();
@ -102,8 +102,16 @@ DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, const wxString& messag
: DIALOG_ANNOTATE_BASE( parent )
{
m_Parent = parent;
m_userMessage->SetLabelText( message );
m_userMessage->Show( !message.empty() );
if( !message.IsEmpty() )
{
m_userMessage->SetLabelText( message );
m_userMessage->Show( true );
m_rbScope->Enable( false );
}
m_MessageWindow->SetLabel( _( "Annotation Messages:" ) );
InitValues();
Layout();
@ -113,60 +121,57 @@ DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, const wxString& messag
}
DIALOG_ANNOTATE::~DIALOG_ANNOTATE()
{
m_Config->Write( KEY_ANNOTATE_SORT_OPTION, GetSortOrder() );
m_Config->Write( KEY_ANNOTATE_ALGO_OPTION, m_rbNumbering->GetSelection() );
m_Config->Write( KEY_ANNOTATE_KEEP_OPEN_OPTION, GetAnnotateKeepOpen() );
m_Config->Write( KEY_ANNOTATE_ASK_FOR_CONFIRMATION, GetAnnotateAskForConfirmation() );
m_Config->Write( KEY_ANNOTATE_MESSAGES_FILTER,
(long) m_MessageWindow->GetVisibleSeverities() );
}
void DIALOG_ANNOTATE::InitValues()
{
m_Config = Kiface().KifaceSettings();
long option;
if( m_Config )
// These are always reset to attempt to keep the user out of trouble...
m_rbScope->SetSelection( 0 );
m_rbOptions->SetSelection( 0 );
m_Config->Read( KEY_ANNOTATE_SORT_OPTION, &option, 0L );
switch( option )
{
long option;
default:
case 0:
m_rbSortBy_X_Position->SetValue( 1 );
break;
m_Config->Read( KEY_ANNOTATE_SORT_OPTION, &option, 0L );
switch( option )
{
default:
case 0:
m_rbSortBy_X_Position->SetValue( 1 );
break;
case 1:
m_rbSortBy_Y_Position->SetValue( 1 );
break;
case 2:
m_rbUseIncremental->SetValue( 1 );
break;
}
m_Config->Read( KEY_ANNOTATE_ALGO_OPTION, &option, 0L );
switch( option )
{
default:
case 0:
m_rbUseIncremental->SetValue( 1 );
break;
case 1:
m_rbUseSheetNum->SetValue( 1 );
break;
case 2:
m_rbStartSheetNumLarge->SetValue( 1 );
break;
}
m_Config->Read( KEY_ANNOTATE_KEEP_OPEN_OPTION, &option, 0L );
m_cbKeepDlgOpen->SetValue( option );
m_Config->Read( KEY_ANNOTATE_ASK_FOR_CONFIRMATION, &option, 1L );
m_cbAskForConfirmation->SetValue( option );
case 1:
m_rbSortBy_Y_Position->SetValue( 1 );
break;
}
m_Config->Read( KEY_ANNOTATE_ALGO_OPTION, &option, 0L );
m_rbNumbering->SetSelection( option );
m_Config->Read( KEY_ANNOTATE_KEEP_OPEN_OPTION, &option, 0L );
m_cbKeepDlgOpen->SetValue( option );
m_Config->Read( KEY_ANNOTATE_ASK_FOR_CONFIRMATION, &option, 1L );
m_cbAskForConfirmation->SetValue( option );
annotate_down_right_bitmap->SetBitmap( KiBitmap( annotate_down_right_xpm ) );
annotate_right_down_bitmap->SetBitmap( KiBitmap( annotate_right_down_xpm ) );
int severities = m_Config->Read( KEY_ANNOTATE_MESSAGES_FILTER, -1l );
m_MessageWindow->SetVisibleSeverities( severities );
m_MessageWindow->MsgPanelSetMinSize( wxSize( -1, 160 ) );
m_btnApply->SetDefault();
}
@ -176,14 +181,6 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
int response;
wxString message;
if( m_Config )
{
m_Config->Write( KEY_ANNOTATE_SORT_OPTION, GetSortOrder() );
m_Config->Write( KEY_ANNOTATE_ALGO_OPTION, GetAnnotateAlgo() );
m_Config->Write( KEY_ANNOTATE_KEEP_OPEN_OPTION, GetAnnotateKeepOpen() );
m_Config->Write( KEY_ANNOTATE_ASK_FOR_CONFIRMATION, GetAnnotateAskForConfirmation() );
}
// Display a message info if we always ask for confirmation
// or if a reset of the previous annotation is asked.
bool promptUser = GetAnnotateAskForConfirmation();
@ -218,22 +215,25 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
return;
}
m_MessageWindow->Clear();
REPORTER& reporter = m_MessageWindow->Reporter();
m_MessageWindow->SetLazyUpdate( true ); // Don't update after each message
m_Parent->AnnotateComponents( GetLevel(), (ANNOTATE_ORDER_T) GetSortOrder(),
(ANNOTATE_OPTION_T) GetAnnotateAlgo(),
GetResetItems() , true, GetLockUnits() );
GetResetItems() , true, GetLockUnits(), reporter );
m_MessageWindow->Flush(); // Now update to show all messages
m_Parent->GetCanvas()->Refresh();
m_btnClear->Enable();
if( !GetAnnotateKeepOpen() )
if( !GetAnnotateKeepOpen() && !reporter.HasMessage() )
{
if( IsModal() )
EndModal( wxID_OK );
else
{
SetReturnCode( wxID_OK );
this->Show( false );
}
// Close the dialog by calling the default dialog handler for a wxID_OK event
event.SetId( wxID_OK );
event.Skip();
}
}
@ -259,61 +259,50 @@ void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event )
}
void DIALOG_ANNOTATE::OnCancelClick( wxCommandEvent& event )
{
if( IsModal() )
EndModal( wxID_CANCEL );
else
{
SetReturnCode( wxID_CANCEL );
this->Show( false );
}
}
bool DIALOG_ANNOTATE::GetLevel()
{
return m_rbEntireSchematic->GetValue();
return m_rbScope->GetSelection() == 0;
}
bool DIALOG_ANNOTATE::GetResetItems()
{
return m_rbResetAnnotation->GetValue() || m_rbResetButLock->GetValue();
return m_rbOptions->GetSelection() >= 1;
}
bool DIALOG_ANNOTATE::GetLockUnits()
{
return m_rbResetButLock->GetValue();
return m_rbOptions->GetSelection() == 2;
}
int DIALOG_ANNOTATE::GetSortOrder()
{
if( m_rbSortBy_X_Position->GetValue() )
return 0;
if( m_rbSortBy_Y_Position->GetValue() )
return 1;
return 2;
else
return 0;
}
int DIALOG_ANNOTATE::GetAnnotateAlgo()
{
if( m_rbUseIncremental->GetValue() )
return 0;
if( m_rbUseSheetNum->GetValue() )
return 1;
return 2;
return m_rbNumbering->GetSelection();
}
int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller, const wxString& message )
void InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller )
{
DIALOG_ANNOTATE dlg( aCaller, message );
DIALOG_ANNOTATE dlg( aCaller, wxT( "" ) );
dlg.ShowModal();
}
int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller, const wxString& aMessage )
{
DIALOG_ANNOTATE dlg( aCaller, aMessage );
return dlg.ShowModal();
}

View File

@ -1,10 +1,12 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version May 6 2016)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "wx_html_report_panel.h"
#include "dialog_annotate_base.h"
///////////////////////////////////////////////////////////////////////////
@ -22,47 +24,25 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con
m_userMessage = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_userMessage->Wrap( 1 );
m_userMessage->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
m_userMessage->Hide();
bupperSizer->Add( m_userMessage, 0, wxALL, 5 );
bupperSizer->Add( m_userMessage, 0, wxALL|wxEXPAND, 5 );
m_staticTextScope = new wxStaticText( this, wxID_ANY, _("Scope"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextScope->Wrap( -1 );
m_staticTextScope->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 2, 2, 0, 0 );
fgSizer1->AddGrowableCol( 0 );
fgSizer1->AddGrowableCol( 1 );
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
bupperSizer->Add( m_staticTextScope, 0, wxALL, 6 );
wxString m_rbScopeChoices[] = { _("Use the entire schematic"), _("Use the current page only") };
int m_rbScopeNChoices = sizeof( m_rbScopeChoices ) / sizeof( wxString );
m_rbScope = new wxRadioBox( this, wxID_ANY, _("Scope"), wxDefaultPosition, wxDefaultSize, m_rbScopeNChoices, m_rbScopeChoices, 1, wxRA_SPECIFY_COLS );
m_rbScope->SetSelection( 0 );
fgSizer1->Add( m_rbScope, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bscopeOptSizer;
bscopeOptSizer = new wxBoxSizer( wxVERTICAL );
m_rbEntireSchematic = new wxRadioButton( this, ID_ENTIRE_SCHEMATIC, _("Use the &entire schematic"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
bscopeOptSizer->Add( m_rbEntireSchematic, 0, wxALL, 3 );
m_rbCurrPage = new wxRadioButton( this, ID_CURRENT_PAGE, _("Use the current &page only"), wxDefaultPosition, wxDefaultSize, 0 );
bscopeOptSizer->Add( m_rbCurrPage, 0, wxALL, 3 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bscopeOptSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
m_rbKeepAnnotation = new wxRadioButton( this, ID_KEEP_ANNOTATION, _("&Keep existing annotation"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
bscopeOptSizer->Add( m_rbKeepAnnotation, 0, wxALL, 3 );
m_rbResetAnnotation = new wxRadioButton( this, ID_RESET_ANNOTATION, _("&Reset existing annotation"), wxDefaultPosition, wxDefaultSize, 0 );
bscopeOptSizer->Add( m_rbResetAnnotation, 0, wxALL, 3 );
m_rbResetButLock = new wxRadioButton( this, ID_RESET_BUT_LOCK, _("R&eset, but do not swap any annotated multi-unit parts"), wxDefaultPosition, wxDefaultSize, 0 );
bscopeOptSizer->Add( m_rbResetButLock, 0, wxALL, 3 );
bupperSizer->Add( bscopeOptSizer, 0, wxEXPAND|wxLEFT, 25 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bupperSizer->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 );
m_staticTextOrder = new wxStaticText( this, wxID_ANY, _("Annotation Order"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextOrder->Wrap( -1 );
m_staticTextOrder->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
bupperSizer->Add( m_staticTextOrder, 0, wxALL, 6 );
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Order") ), wxVERTICAL );
wxBoxSizer* b_orderOptSizer;
b_orderOptSizer = new wxBoxSizer( wxVERTICAL );
@ -70,104 +50,56 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con
wxBoxSizer* bSizerXpos;
bSizerXpos = new wxBoxSizer( wxHORIZONTAL );
m_rbSortBy_X_Position = new wxRadioButton( this, ID_SORT_BY_X_POSITION, _("Sort components by &X position"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
bSizerXpos->Add( m_rbSortBy_X_Position, 0, wxALL, 3 );
m_rbSortBy_X_Position = new wxRadioButton( sbSizer1->GetStaticBox(), ID_SORT_BY_X_POSITION, _("Sort components by &X position"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
bSizerXpos->Add( m_rbSortBy_X_Position, 0, wxBOTTOM|wxTOP, 3 );
bSizerXpos->Add( 0, 0, 1, wxEXPAND, 5 );
bSizerXpos->Add( 0, 0, 1, 0, 5 );
annotate_down_right_bitmap = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
bSizerXpos->Add( annotate_down_right_bitmap, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 12 );
annotate_down_right_bitmap = new wxStaticBitmap( sbSizer1->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
bSizerXpos->Add( annotate_down_right_bitmap, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
b_orderOptSizer->Add( bSizerXpos, 0, wxEXPAND|wxRIGHT, 5 );
b_orderOptSizer->Add( bSizerXpos, 0, wxEXPAND, 5 );
wxBoxSizer* bSizerYpos;
bSizerYpos = new wxBoxSizer( wxHORIZONTAL );
m_rbSortBy_Y_Position = new wxRadioButton( this, ID_SORT_BY_Y_POSITION, _("Sort components by &Y position"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerYpos->Add( m_rbSortBy_Y_Position, 0, wxALL, 3 );
m_rbSortBy_Y_Position = new wxRadioButton( sbSizer1->GetStaticBox(), ID_SORT_BY_Y_POSITION, _("Sort components by &Y position"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerYpos->Add( m_rbSortBy_Y_Position, 0, wxBOTTOM|wxTOP, 3 );
bSizerYpos->Add( 0, 0, 1, wxEXPAND, 5 );
bSizerYpos->Add( 0, 0, 1, 0, 5 );
annotate_right_down_bitmap = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
bSizerYpos->Add( annotate_right_down_bitmap, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 12 );
annotate_right_down_bitmap = new wxStaticBitmap( sbSizer1->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
bSizerYpos->Add( annotate_right_down_bitmap, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
b_orderOptSizer->Add( bSizerYpos, 0, wxEXPAND|wxRIGHT, 5 );
b_orderOptSizer->Add( bSizerYpos, 0, wxEXPAND, 5 );
bupperSizer->Add( b_orderOptSizer, 0, wxEXPAND|wxLEFT, 25 );
m_staticline5 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bupperSizer->Add( m_staticline5, 0, wxEXPAND | wxALL, 5 );
wxBoxSizer* bSizerAnnotAlgo;
bSizerAnnotAlgo = new wxBoxSizer( wxVERTICAL );
m_staticTextAnnotateAlgo = new wxStaticText( this, wxID_ANY, _("Annotation Choice"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextAnnotateAlgo->Wrap( -1 );
m_staticTextAnnotateAlgo->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
bSizerAnnotAlgo->Add( m_staticTextAnnotateAlgo, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizer1AlgoChoice;
bSizer1AlgoChoice = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerChoiceInc;
bSizerChoiceInc = new wxBoxSizer( wxHORIZONTAL );
m_rbUseIncremental = new wxRadioButton( this, ID_SORT_BY_X_POSITION, _("Use first free number in schematic"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
bSizerChoiceInc->Add( m_rbUseIncremental, 0, wxALL, 3 );
sbSizer1->Add( b_orderOptSizer, 0, wxEXPAND|wxLEFT, 5 );
bSizerChoiceInc->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer1->Add( sbSizer1, 0, wxALL|wxEXPAND, 5 );
wxString m_rbOptionsChoices[] = { _("Keep existing annotations"), _("Reset existing annotations"), _("Reset, but keep order of multi-unit parts") };
int m_rbOptionsNChoices = sizeof( m_rbOptionsChoices ) / sizeof( wxString );
m_rbOptions = new wxRadioBox( this, wxID_ANY, _("Options"), wxDefaultPosition, wxDefaultSize, m_rbOptionsNChoices, m_rbOptionsChoices, 1, wxRA_SPECIFY_COLS );
m_rbOptions->SetSelection( 0 );
fgSizer1->Add( m_rbOptions, 0, wxALL|wxEXPAND, 5 );
wxString m_rbNumberingChoices[] = { _("Use first free number in schematic"), _("First free above sheet number * 100"), _("First free above sheet number * 1000") };
int m_rbNumberingNChoices = sizeof( m_rbNumberingChoices ) / sizeof( wxString );
m_rbNumbering = new wxRadioBox( this, wxID_ANY, _("Numbering"), wxDefaultPosition, wxDefaultSize, m_rbNumberingNChoices, m_rbNumberingChoices, 1, wxRA_SPECIFY_COLS );
m_rbNumbering->SetSelection( 1 );
fgSizer1->Add( m_rbNumbering, 0, wxALL|wxEXPAND, 5 );
bSizer1AlgoChoice->Add( bSizerChoiceInc, 0, wxEXPAND|wxRIGHT, 5 );
wxBoxSizer* bSizerChoiceIncBySheet;
bSizerChoiceIncBySheet = new wxBoxSizer( wxHORIZONTAL );
m_rbUseSheetNum = new wxRadioButton( this, wxID_ANY, _("Start to sheet number*100 and use first free number"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerChoiceIncBySheet->Add( m_rbUseSheetNum, 0, wxALL, 3 );
bSizerChoiceIncBySheet->Add( 0, 0, 1, wxEXPAND, 5 );
bSizer1AlgoChoice->Add( bSizerChoiceIncBySheet, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerChoiceIncBySheetLarge;
bSizerChoiceIncBySheetLarge = new wxBoxSizer( wxHORIZONTAL );
m_rbStartSheetNumLarge = new wxRadioButton( this, wxID_ANY, _("Start to sheet number*1000 and use first free number"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerChoiceIncBySheetLarge->Add( m_rbStartSheetNumLarge, 0, wxALL, 3 );
bSizerChoiceIncBySheetLarge->Add( 0, 0, 1, wxEXPAND, 5 );
bSizer1AlgoChoice->Add( bSizerChoiceIncBySheetLarge, 1, wxEXPAND, 5 );
bSizerAnnotAlgo->Add( bSizer1AlgoChoice, 1, wxEXPAND|wxLEFT, 25 );
bupperSizer->Add( bSizerAnnotAlgo, 0, wxEXPAND|wxRIGHT, 5 );
m_staticline4 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bupperSizer->Add( m_staticline4, 0, wxEXPAND | wxALL, 5 );
bupperSizer->Add( fgSizer1, 0, wxBOTTOM|wxEXPAND, 5 );
wxBoxSizer* bSizerDldOptions;
bSizerDldOptions = new wxBoxSizer( wxVERTICAL );
m_staticTextDlgOpts = new wxStaticText( this, wxID_ANY, _("Dialog"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextDlgOpts->Wrap( -1 );
m_staticTextDlgOpts->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
bSizerDldOptions->Add( m_staticTextDlgOpts, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
bSizerDldOptions = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerDlgChoices;
bSizerDlgChoices = new wxBoxSizer( wxVERTICAL );
@ -198,28 +130,31 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con
bSizerDlgChoices->Add( bSizerChoiceSilentMode, 1, wxEXPAND, 5 );
bSizerDldOptions->Add( bSizerDlgChoices, 1, wxEXPAND|wxLEFT, 25 );
m_staticline41 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerDldOptions->Add( m_staticline41, 0, wxEXPAND | wxALL, 5 );
bupperSizer->Add( bSizerDldOptions, 0, wxEXPAND|wxRIGHT, 5 );
bSizerDldOptions->Add( bSizerDlgChoices, 1, wxLEFT, 5 );
wxBoxSizer* bButtonsSizer;
bButtonsSizer = new wxBoxSizer( wxHORIZONTAL );
bButtonsSizer = new wxBoxSizer( wxVERTICAL );
m_btnClose = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
bButtonsSizer->Add( m_btnClose, 0, wxALL|wxEXPAND, 5 );
bButtonsSizer->SetMinSize( wxSize( 160,-1 ) );
m_btnApply = new wxButton( this, wxID_APPLY, _("Annotate"), wxDefaultPosition, wxDefaultSize, 0 );
bButtonsSizer->Add( m_btnApply, 0, wxALL|wxEXPAND, 5 );
m_btnClear = new wxButton( this, ID_CLEAR_ANNOTATION_CMP, _("Clear Annotation"), wxDefaultPosition, wxDefaultSize, 0 );
bButtonsSizer->Add( m_btnClear, 0, wxALL|wxEXPAND, 5 );
m_btnApply = new wxButton( this, wxID_APPLY, _("Annotate"), wxDefaultPosition, wxDefaultSize, 0 );
bButtonsSizer->Add( m_btnApply, 0, wxALL|wxEXPAND, 5 );
m_btnClose = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
bButtonsSizer->Add( m_btnClose, 0, wxALL|wxEXPAND, 5 );
bupperSizer->Add( bButtonsSizer, 0, wxALIGN_CENTER_HORIZONTAL, 6 );
bSizerDldOptions->Add( bButtonsSizer, 0, wxALIGN_RIGHT, 5 );
bupperSizer->Add( bSizerDldOptions, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
m_MessageWindow = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_MessageWindow->SetMinSize( wxSize( -1,120 ) );
bupperSizer->Add( m_MessageWindow, 5, wxEXPAND | wxALL, 5 );
bmainSizer->Add( bupperSizer, 1, wxALL|wxEXPAND, 6 );
@ -230,16 +165,14 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con
bmainSizer->Fit( this );
// Connect Events
m_btnClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ANNOTATE_BASE::OnCancelClick ), NULL, this );
m_btnClear->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ANNOTATE_BASE::OnClearAnnotationCmpClick ), NULL, this );
m_btnApply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ANNOTATE_BASE::OnApplyClick ), NULL, this );
m_btnClear->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ANNOTATE_BASE::OnClearAnnotationCmpClick ), NULL, this );
}
DIALOG_ANNOTATE_BASE::~DIALOG_ANNOTATE_BASE()
{
// Disconnect Events
m_btnClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ANNOTATE_BASE::OnCancelClick ), NULL, this );
m_btnClear->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ANNOTATE_BASE::OnClearAnnotationCmpClick ), NULL, this );
m_btnApply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ANNOTATE_BASE::OnApplyClick ), NULL, this );
m_btnClear->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ANNOTATE_BASE::OnClearAnnotationCmpClick ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version May 6 2016)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_ANNOTATE_BASE_H__
@ -11,7 +11,7 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
class WX_HTML_REPORT_PANEL;
#include "dialog_shim.h"
#include <wx/string.h>
@ -20,27 +20,24 @@ class DIALOG_SHIM;
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/radiobox.h>
#include <wx/radiobut.h>
#include <wx/statline.h>
#include <wx/sizer.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/statbmp.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/panel.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
#define ID_ENTIRE_SCHEMATIC 1000
#define ID_CURRENT_PAGE 1001
#define ID_KEEP_ANNOTATION 1002
#define ID_RESET_ANNOTATION 1003
#define ID_RESET_BUT_LOCK 1004
#define ID_SORT_BY_X_POSITION 1005
#define ID_SORT_BY_Y_POSITION 1006
#define ID_CLEAR_ANNOTATION_CMP 1007
#define ID_SORT_BY_X_POSITION 1000
#define ID_SORT_BY_Y_POSITION 1001
#define ID_CLEAR_ANNOTATION_CMP 1002
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_ANNOTATE_BASE
@ -51,37 +48,23 @@ class DIALOG_ANNOTATE_BASE : public DIALOG_SHIM
protected:
wxStaticText* m_userMessage;
wxStaticText* m_staticTextScope;
wxRadioButton* m_rbEntireSchematic;
wxRadioButton* m_rbCurrPage;
wxStaticLine* m_staticline1;
wxRadioButton* m_rbKeepAnnotation;
wxRadioButton* m_rbResetAnnotation;
wxRadioButton* m_rbResetButLock;
wxStaticLine* m_staticline2;
wxStaticText* m_staticTextOrder;
wxRadioBox* m_rbScope;
wxRadioButton* m_rbSortBy_X_Position;
wxStaticBitmap* annotate_down_right_bitmap;
wxRadioButton* m_rbSortBy_Y_Position;
wxStaticBitmap* annotate_right_down_bitmap;
wxStaticLine* m_staticline5;
wxStaticText* m_staticTextAnnotateAlgo;
wxRadioButton* m_rbUseIncremental;
wxRadioButton* m_rbUseSheetNum;
wxRadioButton* m_rbStartSheetNumLarge;
wxStaticLine* m_staticline4;
wxStaticText* m_staticTextDlgOpts;
wxRadioBox* m_rbOptions;
wxRadioBox* m_rbNumbering;
wxCheckBox* m_cbKeepDlgOpen;
wxCheckBox* m_cbAskForConfirmation;
wxStaticLine* m_staticline41;
wxButton* m_btnClose;
wxButton* m_btnClear;
wxButton* m_btnApply;
wxButton* m_btnClear;
wxButton* m_btnClose;
WX_HTML_REPORT_PANEL* m_MessageWindow;
// Virtual event handlers, overide them in your derived class
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnClearAnnotationCmpClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnApplyClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnClearAnnotationCmpClick( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -39,6 +39,7 @@
#include <project.h>
#include <kiface_i.h>
#include <bitmaps.h>
#include <reporter.h>
#include <wildcards_and_files_ext.h>
#include <netlist.h>
@ -181,11 +182,9 @@ void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event )
m_MessagesList->Clear();
wxSafeYield(); // m_MarkersList must be redraw
wxArrayString messageList;
TestErc( &messageList );
for( unsigned ii = 0; ii < messageList.GetCount(); ii++ )
m_MessagesList->AppendText( messageList[ii] );
WX_TEXT_CTRL_REPORTER reporter( m_MessagesList );
TestErc( reporter );
}
@ -449,7 +448,7 @@ void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
}
void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
void DIALOG_ERC::TestErc( REPORTER& aReporter )
{
wxFileName fn;
@ -461,14 +460,10 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
SCH_SHEET_LIST sheets( g_RootSheet );
sheets.AnnotatePowerSymbols();
if( m_parent->CheckAnnotate( aMessagesList, false ) )
if( m_parent->CheckAnnotate( aReporter, false ) )
{
if( aMessagesList )
{
wxString msg = _( "Annotation required!" );
msg += wxT( "\n" );
aMessagesList->Add( msg );
}
if( aReporter.HasMessage() )
aReporter.Report( _( "Annotation required!" ), REPORTER::RPT_ERROR );
return;
}
@ -584,9 +579,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
m_parent->GetCanvas()->Refresh();
// Display message
wxString msg = _( "Finished" );
msg += wxT( "\n" );
aMessagesList->Add( msg );
aReporter.Report( _( "Finished" ), REPORTER::RPT_INFO );
if( m_writeErcFile )
{

View File

@ -70,7 +70,7 @@ private:
// Double click on a marker info:
void OnLeftDblClickMarkersList( wxMouseEvent& event ) override;
void TestErc( wxArrayString* aMessagesList );
void TestErc( REPORTER& aReporter );
void DisplayERC_MarkersList();
void SelLocal( wxCommandEvent& event );
void SelNewCmp( wxCommandEvent& event );

View File

@ -65,9 +65,14 @@ class SCH_EDIT_FRAME;
*/
int InvokeDialogRescueEach( SCH_EDIT_FRAME* aCaller, RESCUER& aRescuer, bool aAskShowAgain );
/// Create and show DIALOG_ANNOTATE and return whatever
/// DIALOG_ANNOTATE::ShowModal() returns.
int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller, const wxString& message = "" );
/// Create and show DIALOG_ANNOTATE.
void InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller );
/// Create and show a modal DIALOG_ANNOTATE for a particular purpose. This version
/// forces scope to Full Schematic.
/// @param aMessage - indicates the purpose
/// @return the ShowModal() result
int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller, const wxString& aMessage );
/// Create the modeless DIALOG_ERC and show it, return something to
/// destroy or close it. The dialog will have ID_DIALOG_ERC from id.h

View File

@ -171,14 +171,14 @@ bool SCH_EDIT_FRAME::prepareForNetlist()
sheets.AnnotatePowerSymbols();
// Performs some controls:
if( CheckAnnotate( NULL, 0 ) )
if( CheckAnnotate( NULL_REPORTER::GetInstance(), 0 ) )
{
// Schematic must be annotated: call Annotate dialog and tell
// the user why that is.
InvokeDialogAnnotate( this, _( "Exporting the netlist requires a "
"completely\nannotated schematic." ) );
InvokeDialogAnnotate( this,
_( "Exporting the netlist requires a completely annotated schematic." ) );
if( CheckAnnotate( NULL, 0 ) )
if( CheckAnnotate( NULL_REPORTER::GetInstance(), 0 ) )
return false;
}

View File

@ -48,6 +48,7 @@
#include <symbol_lib_table.h>
#include <dialog_helpers.h>
#include <reporter.h>
#include <lib_edit_frame.h>
#include <viewlib_frame.h>
#include <hotkeys.h>
@ -891,7 +892,8 @@ void SCH_EDIT_FRAME::doUpdatePcb( const wxString& aUpdateOptions )
schematic.UpdateSymbolLinks();
SCH_SHEET_LIST sheets( g_RootSheet );
sheets.AnnotatePowerSymbols();
AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, false, false, true );
AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, false, false, true,
NULL_REPORTER::GetInstance() );
}
if( !aUpdateOptions.Contains( "no-annotate" ) )

View File

@ -604,6 +604,7 @@ public:
* usual behavior of annotating each part individually is
* performed.
* When aResetAnnotation is false, this option has no effect.
* @param aReporter A sink for error messages. Use NULL_REPORTER if you don't need errors.
*
* When the sheet number is used in annotation, each sheet annotation starts from sheet
* number * 100. In other words the first sheet uses 100 to 199, the second sheet uses
@ -611,7 +612,7 @@ public:
*/
void AnnotateComponents( bool aAnnotateSchematic, ANNOTATE_ORDER_T aSortOption,
ANNOTATE_OPTION_T aAlgoOption, bool aResetAnnotation,
bool aRepairTimestamps, bool aLockUnits );
bool aRepairTimestamps, bool aLockUnits, REPORTER& aReporter );
/**
* Check for annotation errors.
@ -625,11 +626,11 @@ public:
* between parts.
*
* @return Number of annotation errors found.
* @param aMessageList A wxArrayString to store error messages.
* @param aReporter A sink for error messages. Use NULL_REPORTER if you don't need errors.
* @param aOneSheetOnly Check the current sheet only if true. Otherwise check
* the entire schematic.
*/
int CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly );
int CheckAnnotate( REPORTER& aReporter, bool aOneSheetOnly );
// Functions used for hierarchy handling
SCH_SHEET_PATH& GetCurrentSheet();

View File

@ -311,10 +311,10 @@ public:
* <li>Components with multiple parts per package with invalid part count.</li>
* </ul>
* </p>
* @param aMessageList A wxArrayString to store error messages.
* @param aReporter A sink for error messages. Use NULL_REPORTER if you don't need errors.
* @return The number of errors found.
*/
int CheckAnnotation( wxArrayString* aMessageList );
int CheckAnnotation( REPORTER& aReporter );
/**
* Function sortByXCoordinate

View File

@ -67,6 +67,11 @@ public:
return *this;
}
bool HasMessage() const
{
return false; // Technically "indeterminate" rather than false.
}
void OnSimStateChange( SPICE_SIMULATOR* aObject, SIM_STATE aNewState ) override
{
wxCommandEvent* event = NULL;

View File

@ -87,6 +87,12 @@ public:
REPORTER& operator <<( const wxChar* aText ) { return Report( wxString( aText ) ); }
REPORTER& operator <<( wxChar aChar ) { return Report( wxString( aChar ) ); }
REPORTER& operator <<( const char* aText ) { return Report( aText ); }
/**
* Function HasMessage
* Returns true if the reporter client is non-empty.
*/
virtual bool HasMessage() const = 0;
};
@ -106,6 +112,8 @@ public:
}
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
bool HasMessage() const override;
};
@ -125,6 +133,8 @@ public:
}
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
bool HasMessage() const override;
};
@ -144,6 +154,8 @@ public:
}
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
bool HasMessage() const override;
};
/**
@ -154,14 +166,16 @@ public:
*/
class NULL_REPORTER : public REPORTER
{
public:
NULL_REPORTER()
{
};
public:
NULL_REPORTER()
{
}
static REPORTER& GetInstance();
static REPORTER& GetInstance();
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
bool HasMessage() const override { return false; }
};
#endif // _REPORTER_H_

View File

@ -114,7 +114,7 @@ DIALOG_NETLIST::DIALOG_NETLIST( PCB_EDIT_FRAME* aParent, wxDC * aDC,
m_MessageWindow->SetVisibleSeverities( severities );
// Update sizes and sizers:
m_MessageWindow->MsgPanelSetMinSize( wxSize( -1, 150 ) );
m_MessageWindow->MsgPanelSetMinSize( wxSize( -1, 160 ) );
GetSizer()->SetSizeHints( this );
}