Eeschema: Save annotation starting value in project settings

CHANGED: Added support for saving the starting value for annotation

Fixes https://gitlab.com/kicad/code/kicad/issues/8364
This commit is contained in:
PJM 2021-06-20 18:41:15 -07:00 committed by Jeff Young
parent fb4343bc8f
commit 15d36456a9
3 changed files with 40 additions and 5 deletions

View File

@ -31,6 +31,7 @@
#include <kiface_i.h> #include <kiface_i.h>
#include <widgets/infobar.h> #include <widgets/infobar.h>
#include <wx_html_report_panel.h> #include <wx_html_report_panel.h>
#include <schematic.h>
// A window name for the annotate dialog to retrieve is if not destroyed // A window name for the annotate dialog to retrieve is if not destroyed
#define DLG_WINDOW_NAME "DialogAnnotateWindowName" #define DLG_WINDOW_NAME "DialogAnnotateWindowName"
@ -111,6 +112,24 @@ DIALOG_ANNOTATE::~DIALOG_ANNOTATE()
cfg->m_AnnotatePanel.options = m_rbOptions->GetSelection(); cfg->m_AnnotatePanel.options = m_rbOptions->GetSelection();
cfg->m_AnnotatePanel.scope = m_rbScope->GetSelection(); cfg->m_AnnotatePanel.scope = m_rbScope->GetSelection();
cfg->m_AnnotatePanel.messages_filter = m_MessageWindow->GetVisibleSeverities(); cfg->m_AnnotatePanel.messages_filter = m_MessageWindow->GetVisibleSeverities();
// Get the "start annotation after" value from dialog and update project settings if changed
int startNum = GetStartNumber();
SCH_EDIT_FRAME* schFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_parentFrame );
if( schFrame ) {
SCHEMATIC_SETTINGS& projSettings = schFrame->Schematic().Settings();
// If the user has updated the start annotation number then update the project file.
// We manually update the project file here in case the user has changed the value
// and just clicked the "Close" button on the annotation dialog.
if( projSettings.m_AnnotateStartNum != startNum )
{
projSettings.m_AnnotateStartNum = startNum;
schFrame->SaveProjectSettings();
}
}
} }
@ -141,7 +160,18 @@ void DIALOG_ANNOTATE::InitValues()
case 2: m_rbSheetX1000->SetValue( true ); break; case 2: m_rbSheetX1000->SetValue( true ); break;
} }
m_textNumberAfter->SetValue( wxT( "0" ) ); int annotateStartNum = 0; // Default "start after" value for annotation
// See if we can get a "start after" value from the project settings
SCH_EDIT_FRAME* schFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_parentFrame );
if( schFrame )
{
SCHEMATIC_SETTINGS& projSettings = schFrame->Schematic().Settings();
annotateStartNum = projSettings.m_AnnotateStartNum;
}
m_textNumberAfter->SetValue( wxString::Format( wxT( "%d" ), annotateStartNum ) );
annotate_down_right_bitmap->SetBitmap( KiBitmap( BITMAPS::annotate_down_right ) ); annotate_down_right_bitmap->SetBitmap( KiBitmap( BITMAPS::annotate_down_right ) );
annotate_right_down_bitmap->SetBitmap( KiBitmap( BITMAPS::annotate_right_down ) ); annotate_right_down_bitmap->SetBitmap( KiBitmap( BITMAPS::annotate_right_down ) );

View File

@ -52,7 +52,8 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
m_IntersheetRefsPrefix( DEFAULT_IREF_PREFIX ), m_IntersheetRefsPrefix( DEFAULT_IREF_PREFIX ),
m_IntersheetRefsSuffix( DEFAULT_IREF_SUFFIX ), m_IntersheetRefsSuffix( DEFAULT_IREF_SUFFIX ),
m_SpiceAdjustPassiveValues( false ), m_SpiceAdjustPassiveValues( false ),
m_NgspiceSimulatorSettings( nullptr ) m_NgspiceSimulatorSettings( nullptr ),
m_AnnotateStartNum( 0 )
{ {
EESCHEMA_SETTINGS* appSettings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ); EESCHEMA_SETTINGS* appSettings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
@ -127,9 +128,9 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
Mils2iu( defaultJunctionSize ), Mils2iu( 5 ), Mils2iu( 1000 ), 1 / IU_PER_MILS ) ); Mils2iu( defaultJunctionSize ), Mils2iu( 5 ), Mils2iu( 1000 ), 1 / IU_PER_MILS ) );
// User choice for junction dot size ( e.g. none = 0, smallest = 1, small = 2, etc ) // User choice for junction dot size ( e.g. none = 0, smallest = 1, small = 2, etc )
m_params.emplace_back(new PARAM<int>("drawing.junction_size_choice", m_params.emplace_back( new PARAM<int>( "drawing.junction_size_choice",
&m_JunctionSizeChoice, &m_JunctionSizeChoice,
defaultJunctionSizeChoice) ); defaultJunctionSizeChoice ) );
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "drawing.field_names", m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "drawing.field_names",
[&]() -> nlohmann::json [&]() -> nlohmann::json
@ -212,6 +213,9 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
m_params.emplace_back( new PARAM<int>( "subpart_first_id", m_params.emplace_back( new PARAM<int>( "subpart_first_id",
LIB_SYMBOL::SubpartFirstIdPtr(), 'A', '1', 'z' ) ); LIB_SYMBOL::SubpartFirstIdPtr(), 'A', '1', 'z' ) );
m_params.emplace_back( new PARAM<int>( "annotate_start_num",
&m_AnnotateStartNum, 0 ) );
m_NgspiceSimulatorSettings = m_NgspiceSimulatorSettings =
std::make_shared<NGSPICE_SIMULATOR_SETTINGS>( this, "ngspice" ); std::make_shared<NGSPICE_SIMULATOR_SETTINGS>( this, "ngspice" );
} }

View File

@ -53,6 +53,7 @@ public:
int m_JunctionSize; // Size of junction dot in mils int m_JunctionSize; // Size of junction dot in mils
// User choice for junction dot size ( e.g. none = 0, smallest = 1, small = 2, etc ) // User choice for junction dot size ( e.g. none = 0, smallest = 1, small = 2, etc )
int m_JunctionSizeChoice; int m_JunctionSizeChoice;
int m_AnnotateStartNum; // Starting value for annotation
bool m_IntersheetRefsShow; bool m_IntersheetRefsShow;
bool m_IntersheetRefsListOwnPage; bool m_IntersheetRefsListOwnPage;