From 15d36456a98ee671071fb32dadc9f73bd4fb323a Mon Sep 17 00:00:00 2001 From: PJM Date: Sun, 20 Jun 2021 18:41:15 -0700 Subject: [PATCH] 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 --- eeschema/dialogs/dialog_annotate.cpp | 32 +++++++++++++++++++++++++++- eeschema/schematic_settings.cpp | 12 +++++++---- eeschema/schematic_settings.h | 1 + 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/eeschema/dialogs/dialog_annotate.cpp b/eeschema/dialogs/dialog_annotate.cpp index 0fc4cfca32..b22a735043 100644 --- a/eeschema/dialogs/dialog_annotate.cpp +++ b/eeschema/dialogs/dialog_annotate.cpp @@ -31,6 +31,7 @@ #include #include #include +#include // A window name for the annotate dialog to retrieve is if not destroyed #define DLG_WINDOW_NAME "DialogAnnotateWindowName" @@ -111,6 +112,24 @@ DIALOG_ANNOTATE::~DIALOG_ANNOTATE() cfg->m_AnnotatePanel.options = m_rbOptions->GetSelection(); cfg->m_AnnotatePanel.scope = m_rbScope->GetSelection(); 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( 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; } - 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( 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_right_down_bitmap->SetBitmap( KiBitmap( BITMAPS::annotate_right_down ) ); diff --git a/eeschema/schematic_settings.cpp b/eeschema/schematic_settings.cpp index 194b9becb7..3467c291fe 100644 --- a/eeschema/schematic_settings.cpp +++ b/eeschema/schematic_settings.cpp @@ -52,7 +52,8 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin m_IntersheetRefsPrefix( DEFAULT_IREF_PREFIX ), m_IntersheetRefsSuffix( DEFAULT_IREF_SUFFIX ), m_SpiceAdjustPassiveValues( false ), - m_NgspiceSimulatorSettings( nullptr ) + m_NgspiceSimulatorSettings( nullptr ), + m_AnnotateStartNum( 0 ) { EESCHEMA_SETTINGS* appSettings = dynamic_cast( 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 ) ); // User choice for junction dot size ( e.g. none = 0, smallest = 1, small = 2, etc ) - m_params.emplace_back(new PARAM("drawing.junction_size_choice", - &m_JunctionSizeChoice, - defaultJunctionSizeChoice) ); + m_params.emplace_back( new PARAM( "drawing.junction_size_choice", + &m_JunctionSizeChoice, + defaultJunctionSizeChoice ) ); m_params.emplace_back( new PARAM_LAMBDA( "drawing.field_names", [&]() -> nlohmann::json @@ -212,6 +213,9 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin m_params.emplace_back( new PARAM( "subpart_first_id", LIB_SYMBOL::SubpartFirstIdPtr(), 'A', '1', 'z' ) ); + m_params.emplace_back( new PARAM( "annotate_start_num", + &m_AnnotateStartNum, 0 ) ); + m_NgspiceSimulatorSettings = std::make_shared( this, "ngspice" ); } diff --git a/eeschema/schematic_settings.h b/eeschema/schematic_settings.h index 55a9e208eb..91a949e0bf 100644 --- a/eeschema/schematic_settings.h +++ b/eeschema/schematic_settings.h @@ -53,6 +53,7 @@ public: int m_JunctionSize; // Size of junction dot in mils // User choice for junction dot size ( e.g. none = 0, smallest = 1, small = 2, etc ) int m_JunctionSizeChoice; + int m_AnnotateStartNum; // Starting value for annotation bool m_IntersheetRefsShow; bool m_IntersheetRefsListOwnPage;