Add a start number to annotate.

This also makes the dialog modeless so that one switch between
sheets while annotating to choose the base numbers for each
sheet (assuming they don't like the base number we pick because
of the order of the sheets).

Fixes: lp:1154131
* https://bugs.launchpad.net/kicad/+bug/1154131
This commit is contained in:
Jeff Young 2018-02-18 20:44:33 +00:00 committed by Wayne Stambaugh
parent 9241a399a7
commit 447fd1bf02
12 changed files with 874 additions and 515 deletions

View File

@ -80,6 +80,7 @@ void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly )
void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
ANNOTATE_ORDER_T aSortOption,
ANNOTATE_OPTION_T aAlgoOption,
int aStartNumber,
bool aResetAnnotation,
bool aRepairTimestamps,
bool aLockUnits,
@ -109,7 +110,7 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
{
wxString msg;
msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
aReporter.Report( msg, REPORTER::RPT_INFO );
aReporter.Report( msg, REPORTER::RPT_WARNING );
}
}
@ -182,7 +183,7 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
}
// Recalculate and update reference numbers in schematic
references.Annotate( useSheetNum, idStep, lockedComponents );
references.Annotate( useSheetNum, idStep, aStartNumber, lockedComponents );
references.UpdateAnnotation();
for( size_t i = 0; i < references.GetCount(); i++ )
@ -222,12 +223,12 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
GetChars( newRef ) );
}
aReporter.Report( msg, REPORTER::RPT_INFO );
aReporter.Report( msg, REPORTER::RPT_ACTION );
}
// Final control (just in case ... ).
if( !CheckAnnotate( aReporter, !aAnnotateSchematic ) )
aReporter.Report( _( "Annotation complete." ), REPORTER::RPT_INFO );
aReporter.Report( _( "Annotation complete." ), REPORTER::RPT_ACTION );
OnModify();

View File

@ -271,7 +271,7 @@ int SCH_REFERENCE_LIST::CreateFirstFreeRefId( std::vector<int>& aIdList, int aFi
}
void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int aStartNumber,
SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap )
{
if ( componentFlatList.size() == 0 )
@ -297,11 +297,13 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
LastReferenceNumber = GetLastReference( first, minRefId );
#else
int minRefId = 1;
int minRefId;
// when using sheet number, ensure ref number >= sheet number* aSheetIntervalId
if( aUseSheetNum )
minRefId = componentFlatList[first].m_SheetNum * aSheetIntervalId + 1;
else
minRefId = aStartNumber + 1;
// This is the list of all Id already in use for a given reference prefix.
// Will be refilled for each new reference prefix.
@ -345,11 +347,11 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
LastReferenceNumber = componentFlatList.GetLastReference( ii, minRefId );
#else
minRefId = 1;
// when using sheet number, ensure ref number >= sheet number* aSheetIntervalId
if( aUseSheetNum )
minRefId = componentFlatList[ii].m_SheetNum * aSheetIntervalId + 1;
else
minRefId = aStartNumber + 1;
GetRefsInUse( first, idList, minRefId );
#endif

View File

@ -86,6 +86,8 @@ private:
*/
int GetAnnotateAlgo();
int GetStartNumber();
bool GetAnnotateKeepOpen()
{
return m_cbKeepDlgOpen->GetValue();
@ -109,6 +111,7 @@ DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, const wxString& messag
m_userMessage->Show( true );
m_rbScope->Enable( false );
m_cbKeepDlgOpen->Show( false );
}
m_MessageWindow->SetLabel( _( "Annotation Messages:" ) );
@ -124,7 +127,7 @@ 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_ALGO_OPTION, GetAnnotateAlgo() );
m_Config->Write( KEY_ANNOTATE_KEEP_OPEN_OPTION, GetAnnotateKeepOpen() );
m_Config->Write( KEY_ANNOTATE_ASK_FOR_CONFIRMATION, GetAnnotateAskForConfirmation() );
@ -156,7 +159,22 @@ void DIALOG_ANNOTATE::InitValues()
}
m_Config->Read( KEY_ANNOTATE_ALGO_OPTION, &option, 0L );
m_rbNumbering->SetSelection( option );
switch( option )
{
default:
case 0:
m_rbFirstFree->SetValue( 1 );
break;
case 1:
m_rbSheetX100->SetValue( 100 );
break;
case 2:
m_rbSheetX1000->SetValue( 1000 );
break;
}
m_textNumberAfter->SetValue( wxT( "0" ) );
m_Config->Read( KEY_ANNOTATE_KEEP_OPEN_OPTION, &option, 0L );
m_cbKeepDlgOpen->SetValue( option );
@ -220,7 +238,7 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
m_MessageWindow->SetLazyUpdate( true ); // Don't update after each message
m_Parent->AnnotateComponents( GetLevel(), (ANNOTATE_ORDER_T) GetSortOrder(),
(ANNOTATE_OPTION_T) GetAnnotateAlgo(),
(ANNOTATE_OPTION_T) GetAnnotateAlgo(), GetStartNumber(),
GetResetItems() , true, GetLockUnits(), reporter );
m_MessageWindow->Flush(); // Now update to show all messages
@ -229,9 +247,13 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
m_btnClear->Enable();
if( !GetAnnotateKeepOpen() && !reporter.HasMessage() )
// Don't close dialog if there are things the user needs to address
if( reporter.HasMessage() )
return;
if( m_userMessage->IsShown() || !GetAnnotateKeepOpen() )
{
// Close the dialog by calling the default dialog handler for a wxID_OK event
// Close the dialog by calling the default handler for a wxID_OK event
event.SetId( wxID_OK );
event.Skip();
}
@ -288,21 +310,38 @@ int DIALOG_ANNOTATE::GetSortOrder()
int DIALOG_ANNOTATE::GetAnnotateAlgo()
{
return m_rbNumbering->GetSelection();
if( m_rbSheetX100->GetValue() )
return 1;
else if( m_rbSheetX1000->GetValue() )
return 2;
else
return 0;
}
void InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller )
int DIALOG_ANNOTATE::GetStartNumber()
{
DIALOG_ANNOTATE dlg( aCaller, wxT( "" ) );
dlg.ShowModal();
return ValueFromString( EDA_UNITS_T::UNSCALED_UNITS, m_textNumberAfter->GetValue() );
}
int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller, const wxString& aMessage )
void SCH_EDIT_FRAME::OnAnnotate( wxCommandEvent& event )
{
DIALOG_ANNOTATE dlg( aCaller, aMessage );
if( !m_annotateDialog )
{
m_annotateDialog = new DIALOG_ANNOTATE( this, wxEmptyString );
m_annotateDialog->Show( true );
}
else // The dialog is just not visible
{
m_annotateDialog->Show( true );
}
}
int SCH_EDIT_FRAME::ModalAnnotate( const wxString& aMessage )
{
DIALOG_ANNOTATE dlg( this, aMessage );
return dlg.ShowModal();
}

View File

@ -44,9 +44,6 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Order") ), wxVERTICAL );
wxBoxSizer* b_orderOptSizer;
b_orderOptSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerXpos;
bSizerXpos = new wxBoxSizer( wxHORIZONTAL );
@ -60,7 +57,7 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con
bSizerXpos->Add( annotate_down_right_bitmap, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
b_orderOptSizer->Add( bSizerXpos, 0, wxEXPAND, 5 );
sbSizer1->Add( bSizerXpos, 0, wxEXPAND, 5 );
wxBoxSizer* bSizerYpos;
bSizerYpos = new wxBoxSizer( wxHORIZONTAL );
@ -75,10 +72,7 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con
bSizerYpos->Add( annotate_right_down_bitmap, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
b_orderOptSizer->Add( bSizerYpos, 0, wxEXPAND, 5 );
sbSizer1->Add( b_orderOptSizer, 0, wxEXPAND|wxLEFT, 5 );
sbSizer1->Add( bSizerYpos, 0, wxEXPAND, 5 );
fgSizer1->Add( sbSizer1, 0, wxALL|wxEXPAND, 5 );
@ -89,11 +83,31 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con
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 );
wxStaticBoxSizer* sbSizer2;
sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Numbering") ), wxVERTICAL );
wxGridBagSizer* gbSizer1;
gbSizer1 = new wxGridBagSizer( 0, 0 );
gbSizer1->SetFlexibleDirection( wxBOTH );
gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_rbFirstFree = new wxRadioButton( sbSizer2->GetStaticBox(), wxID_FIRST_FREE, _("Use first free number after:"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
gbSizer1->Add( m_rbFirstFree, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxTOP, 2 );
m_textNumberAfter = new wxTextCtrl( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 60,-1 ), 0 );
gbSizer1->Add( m_textNumberAfter, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxLEFT, 2 );
m_rbSheetX100 = new wxRadioButton( sbSizer2->GetStaticBox(), wxID_SHEET_X_100, _("First free after sheet number X 100"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer1->Add( m_rbSheetX100, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxBOTTOM|wxTOP, 4 );
m_rbSheetX1000 = new wxRadioButton( sbSizer2->GetStaticBox(), wxID_SHEET_X_1000, _("First free after sheet number X 1000"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer1->Add( m_rbSheetX1000, wxGBPosition( 2, 0 ), wxGBSpan( 1, 2 ), wxBOTTOM|wxTOP, 2 );
sbSizer2->Add( gbSizer1, 1, wxEXPAND, 5 );
fgSizer1->Add( sbSizer2, 1, wxALL|wxEXPAND, 5 );
bupperSizer->Add( fgSizer1, 0, wxBOTTOM|wxEXPAND, 5 );

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,8 @@ class WX_HTML_REPORT_PANEL;
#include <wx/statbmp.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/textctrl.h>
#include <wx/gbsizer.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/panel.h>
@ -37,7 +39,10 @@ class WX_HTML_REPORT_PANEL;
#define ID_SORT_BY_X_POSITION 1000
#define ID_SORT_BY_Y_POSITION 1001
#define ID_CLEAR_ANNOTATION_CMP 1002
#define wxID_FIRST_FREE 1002
#define wxID_SHEET_X_100 1003
#define wxID_SHEET_X_1000 1004
#define ID_CLEAR_ANNOTATION_CMP 1005
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_ANNOTATE_BASE
@ -54,7 +59,10 @@ class DIALOG_ANNOTATE_BASE : public DIALOG_SHIM
wxRadioButton* m_rbSortBy_Y_Position;
wxStaticBitmap* annotate_right_down_bitmap;
wxRadioBox* m_rbOptions;
wxRadioBox* m_rbNumbering;
wxRadioButton* m_rbFirstFree;
wxTextCtrl* m_textNumberAfter;
wxRadioButton* m_rbSheetX100;
wxRadioButton* m_rbSheetX1000;
wxCheckBox* m_cbKeepDlgOpen;
wxCheckBox* m_cbAskForConfirmation;
wxButton* m_btnApply;

View File

@ -65,15 +65,6 @@ class SCH_EDIT_FRAME;
*/
int InvokeDialogRescueEach( SCH_EDIT_FRAME* aCaller, RESCUER& aRescuer, bool aAskShowAgain );
/// 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
wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller );

View File

@ -173,10 +173,8 @@ bool SCH_EDIT_FRAME::prepareForNetlist()
// Performs some controls:
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 annotated schematic." ) );
// Schematic must be annotated: call Annotate dialog and tell the user why.
ModalAnnotate( _( "Exporting the netlist requires a completely annotated schematic." ) );
if( CheckAnnotate( NULL_REPORTER::GetInstance(), 0 ) )
return false;

View File

@ -363,6 +363,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_printMonochrome = true;
m_printSheetReference = true;
SetShowPageLimits( true );
m_annotateDialog = nullptr;
m_hotkeysDescrList = g_Schematic_Hokeys_Descr;
m_dlgFindReplace = NULL;
m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
@ -829,12 +830,6 @@ void SCH_EDIT_FRAME::OnUpdateHierarchySheet( wxUpdateUIEvent& aEvent )
}
void SCH_EDIT_FRAME::OnAnnotate( wxCommandEvent& event )
{
InvokeDialogAnnotate( this );
}
void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event )
{
// See if it's already open...
@ -894,7 +889,7 @@ 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, 0, false, false, true,
NULL_REPORTER::GetInstance() );
}

View File

@ -60,6 +60,7 @@ class SCH_FIELD;
class LIB_PIN;
class SCH_JUNCTION;
class DIALOG_SCH_FIND;
class DIALOG_ANNOTATE;
class wxFindDialogEvent;
class wxFindReplaceData;
class SCHLIB_FILTER;
@ -131,6 +132,7 @@ private:
wxSize m_printDialogSize;
bool m_printMonochrome; ///< Print monochrome instead of grey scale.
bool m_printSheetReference;
DIALOG_ANNOTATE* m_annotateDialog;
DIALOG_SCH_FIND* m_dlgFindReplace;
wxPoint m_findDialogPosition;
wxSize m_findDialogSize;
@ -590,6 +592,7 @@ public:
* the current sheet only.
* @param aSortOption Define the annotation order. See #ANNOTATE_ORDER_T.
* @param aAlgoOption Define the annotation style. See #ANNOTATE_OPTION_T.
* @param aStartNumber The start number for non-sheet-based annotation styles.
* @param aResetAnnotation Clear any previous annotation if true. Otherwise, keep the
* existing component annotation.
* @param aRepairTimestamps Test for and repair any duplicate time stamps if true.
@ -611,8 +614,9 @@ public:
* 200 to 299, and so on.
*/
void AnnotateComponents( bool aAnnotateSchematic, ANNOTATE_ORDER_T aSortOption,
ANNOTATE_OPTION_T aAlgoOption, bool aResetAnnotation,
bool aRepairTimestamps, bool aLockUnits, REPORTER& aReporter );
ANNOTATE_OPTION_T aAlgoOption, int aStartNumber,
bool aResetAnnotation, bool aRepairTimestamps, bool aLockUnits,
REPORTER& aReporter );
/**
* Check for annotation errors.
@ -632,6 +636,13 @@ public:
*/
int CheckAnnotate( REPORTER& aReporter, bool aOneSheetOnly );
/**
* Run a modal version of the Annotate dialog for a specific purpose.
* @param aMessage A user message indicating the purpose.
* @return the result of ShowModal()
*/
int ModalAnnotate( const wxString& aMessage );
// Functions used for hierarchy handling
SCH_SHEET_PATH& GetCurrentSheet();

View File

@ -287,6 +287,7 @@ public:
* @param aUseSheetNum Set to true to start annotation for each sheet at the sheet number
* times \a aSheetIntervalId. Otherwise annotate incrementally.
* @param aSheetIntervalId The per sheet reference designator multiplier.
* @param aStartNumber The number to start with if NOT numbering based on sheet number.
* @param aLockedUnitMap A SCH_MULTI_UNIT_REFERENCE_MAP of reference designator wxStrings
* to SCH_REFERENCE_LISTs. May be an empty map. If not empty, any multi-unit parts
* found in this map will be annotated as a group rather than individually.
@ -297,7 +298,8 @@ public:
* referenced U201 to U351, and items in sheet 3 start from U352
* </p>
*/
void Annotate( bool aUseSheetNum, int aSheetIntervalId, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap );
void Annotate( bool aUseSheetNum, int aSheetIntervalId, int aStartNumber,
SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap );
/**
* Function CheckAnnotation

View File

@ -583,7 +583,7 @@ void SCH_SHEET_LIST::AnnotatePowerSymbols()
}
// Recalculate and update reference numbers in schematic
references.Annotate( false, 100, lockedComponents );
references.Annotate( false, 0, 100, lockedComponents );
references.UpdateAnnotation();
}