Attempt to untangle junction dot preferences.

This commit is contained in:
Jeff Young 2021-09-02 12:40:45 +01:00
parent e03257b55f
commit bc8245ca7b
8 changed files with 35 additions and 45 deletions

View File

@ -23,7 +23,6 @@
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <sch_painter.h> #include <sch_painter.h>
#include <eeschema_settings.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <panel_setup_formatting.h> #include <panel_setup_formatting.h>
#include <sch_junction.h> #include <sch_junction.h>
@ -137,6 +136,8 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow()
if( m_choiceJunctionDotSize->GetSelection() != wxNOT_FOUND ) if( m_choiceJunctionDotSize->GetSelection() != wxNOT_FOUND )
settings.m_JunctionSizeChoice = m_choiceJunctionDotSize->GetSelection(); settings.m_JunctionSizeChoice = m_choiceJunctionDotSize->GetSelection();
settings.m_JunctionSize = m_frame->GetSchematicJunctionSize();
settings.m_IntersheetRefsShow = m_showIntersheetsReferences->GetValue(); settings.m_IntersheetRefsShow = m_showIntersheetsReferences->GetValue();
settings.m_IntersheetRefsFormatShort = !m_radioFormatStandard->GetValue(); settings.m_IntersheetRefsFormatShort = !m_radioFormatStandard->GetValue();
settings.m_IntersheetRefsPrefix = m_prefixCtrl->GetValue(); settings.m_IntersheetRefsPrefix = m_prefixCtrl->GetValue();

View File

@ -77,13 +77,16 @@ void SCH_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
bool SCH_EDIT_FRAME::LoadProjectSettings() bool SCH_EDIT_FRAME::LoadProjectSettings()
{ {
GetRenderSettings()->SetDefaultPenWidth( m_defaults->m_DefaultLineWidth ); SCHEMATIC_SETTINGS& settings = Schematic().Settings();
GetRenderSettings()->m_DefaultWireThickness = m_defaults->m_DefaultWireThickness; settings.m_JunctionSize = GetSchematicJunctionSize();
GetRenderSettings()->m_DefaultBusThickness = m_defaults->m_DefaultBusThickness;
GetRenderSettings()->m_LabelSizeRatio = m_defaults->m_LabelSizeRatio; GetRenderSettings()->SetDefaultPenWidth( settings.m_DefaultLineWidth );
GetRenderSettings()->m_TextOffsetRatio = m_defaults->m_TextOffsetRatio; GetRenderSettings()->m_DefaultWireThickness = settings.m_DefaultWireThickness;
GetRenderSettings()->m_PinSymbolSize = m_defaults->m_PinSymbolSize; GetRenderSettings()->m_DefaultBusThickness = settings.m_DefaultBusThickness;
GetRenderSettings()->m_JunctionSize = m_defaults->m_JunctionSize; GetRenderSettings()->m_LabelSizeRatio = settings.m_LabelSizeRatio;
GetRenderSettings()->m_TextOffsetRatio = settings.m_TextOffsetRatio;
GetRenderSettings()->m_PinSymbolSize = settings.m_PinSymbolSize;
GetRenderSettings()->m_JunctionSize = settings.m_JunctionSize;
// Verify some values, because the config file can be edited by hand, // Verify some values, because the config file can be edited by hand,
// and have bad values: // and have bad values:
@ -97,9 +100,7 @@ bool SCH_EDIT_FRAME::LoadProjectSettings()
Prj().GetProjectPath() ); Prj().GetProjectPath() );
if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename ) ) if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename ) )
{
ShowInfoBarError( _( "Error loading drawing sheet." ), true ); ShowInfoBarError( _( "Error loading drawing sheet." ), true );
}
return true; return true;
} }
@ -116,16 +117,6 @@ void SCH_EDIT_FRAME::ShowSchematicSetupDialog( const wxString& aInitialPage )
{ {
Prj().GetProjectFile().NetSettings().ResolveNetClassAssignments( true ); Prj().GetProjectFile().NetSettings().ResolveNetClassAssignments( true );
EESCHEMA_SETTINGS* cfg = static_cast<EESCHEMA_SETTINGS*>( config() );
SCHEMATIC_SETTINGS& settings = Schematic().Settings();
settings.m_JunctionSize =
Prj().GetProjectFile().NetSettings().m_NetClasses.GetDefaultPtr()->GetWireWidth()
* cfg->m_Drawing.junction_size_mult_list[ settings.m_JunctionSizeChoice ];
if( Schematic().Settings().m_JunctionSize < 1 )
Schematic().Settings().m_JunctionSize = 1;
SaveProjectSettings(); SaveProjectSettings();
Kiway().CommonSettingsChanged( false, true ); Kiway().CommonSettingsChanged( false, true );
@ -134,6 +125,18 @@ void SCH_EDIT_FRAME::ShowSchematicSetupDialog( const wxString& aInitialPage )
} }
int SCH_EDIT_FRAME::GetSchematicJunctionSize()
{
std::vector<double>& sizeMultipliers = eeconfig()->m_Drawing.junction_size_mult_list;
NETCLASSPTR defaultNetclass = Prj().GetProjectFile().NetSettings().m_NetClasses.GetDefault();
int sizeChoice = Schematic().Settings().m_JunctionSizeChoice;
int junctionSize = defaultNetclass->GetWireWidth() * sizeMultipliers[ sizeChoice ];
return std::max( junctionSize, 1 );
}
void SCH_EDIT_FRAME::SaveProjectSettings() void SCH_EDIT_FRAME::SaveProjectSettings()
{ {
wxFileName fn = Schematic().RootScreen()->GetFileName(); //ConfigFileName wxFileName fn = Schematic().RootScreen()->GetFileName(); //ConfigFileName

View File

@ -82,8 +82,7 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindo
const wxString& aTitle, const wxPoint& aPosition, const wxString& aTitle, const wxPoint& aPosition,
const wxSize& aSize, long aStyle, const wxString& aFrameName ) : const wxSize& aSize, long aStyle, const wxString& aFrameName ) :
EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, aSize, aStyle, aFrameName ), EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, aSize, aStyle, aFrameName ),
m_base_frame_defaults( nullptr, "base_Frame_defaults" ), m_base_frame_defaults( nullptr, "base_Frame_defaults" )
m_defaults( &m_base_frame_defaults )
{ {
createCanvas(); createCanvas();

View File

@ -110,11 +110,6 @@ public:
KIGFX::SCH_RENDER_SETTINGS* GetRenderSettings(); KIGFX::SCH_RENDER_SETTINGS* GetRenderSettings();
SCHEMATIC_SETTINGS& GetDefaults()
{
return *m_defaults;
}
COLOR4D GetDrawBgColor() const override; COLOR4D GetDrawBgColor() const override;
/** /**
@ -258,9 +253,6 @@ protected:
/// These are only used by symbol_editor. Eeschema should be using the one inside /// These are only used by symbol_editor. Eeschema should be using the one inside
/// the SCHEMATIC. /// the SCHEMATIC.
SCHEMATIC_SETTINGS m_base_frame_defaults; SCHEMATIC_SETTINGS m_base_frame_defaults;
SCHEMATIC_SETTINGS* m_defaults;
}; };
#endif // SCH_BASE_FRAME_H_ #endif // SCH_BASE_FRAME_H_

View File

@ -238,12 +238,9 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
LoadSettings( eeconfig() ); LoadSettings( eeconfig() );
// Also links the schematic to the loaded project // NB: also links the schematic to the loaded project
CreateScreens(); CreateScreens();
// After schematic has been linked to project, SCHEMATIC_SETTINGS works
m_defaults = &m_schematic->Settings();
setupTools(); setupTools();
setupUIConditions(); setupUIConditions();
ReCreateMenuBar(); ReCreateMenuBar();
@ -555,8 +552,6 @@ void SCH_EDIT_FRAME::CreateScreens()
m_schematic->SetRoot( new SCH_SHEET( m_schematic ) ); m_schematic->SetRoot( new SCH_SHEET( m_schematic ) );
m_defaults = &m_schematic->Settings();
SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic ); SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
m_schematic->Root().SetScreen( rootScreen ); m_schematic->Root().SetScreen( rootScreen );
SetScreen( Schematic().RootScreen() ); SetScreen( Schematic().RootScreen() );

View File

@ -801,6 +801,8 @@ public:
void FixupJunctions(); void FixupJunctions();
int GetSchematicJunctionSize();
void FocusOnItem( SCH_ITEM* aItem ); void FocusOnItem( SCH_ITEM* aItem );
/** /**

View File

@ -23,7 +23,6 @@
#include <lib_symbol.h> #include <lib_symbol.h>
#include <convert_to_biu.h> #include <convert_to_biu.h>
#include <default_values.h> #include <default_values.h>
#include <eda_text.h>
#include <eeschema_settings.h> #include <eeschema_settings.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <macros.h> #include <macros.h>
@ -45,8 +44,8 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ), m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ),
m_TextOffsetRatio( DEFAULT_TEXT_OFFSET_RATIO ), m_TextOffsetRatio( DEFAULT_TEXT_OFFSET_RATIO ),
m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ), m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ),
m_JunctionSize( DEFAULT_JUNCTION_DIAM * IU_PER_MILS ),
m_JunctionSizeChoice( 3 ), m_JunctionSizeChoice( 3 ),
m_JunctionSize( DEFAULT_JUNCTION_DIAM * IU_PER_MILS ),
m_AnnotateStartNum( 0 ), m_AnnotateStartNum( 0 ),
m_IntersheetRefsShow( false ), m_IntersheetRefsShow( false ),
m_IntersheetRefsListOwnPage( true ), m_IntersheetRefsListOwnPage( true ),
@ -124,9 +123,7 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
&m_PinSymbolSize, Mils2iu( defaultPinSymbolSize ), Mils2iu( 5 ), Mils2iu( 1000 ), &m_PinSymbolSize, Mils2iu( defaultPinSymbolSize ), Mils2iu( 5 ), Mils2iu( 1000 ),
1 / IU_PER_MILS ) ); 1 / IU_PER_MILS ) );
m_params.emplace_back( new PARAM_SCALED<int>( "drawing.default_junction_size", // m_JunctionSize is only a run-time cache of the calculated size. Do not save it.
&m_JunctionSize, 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",

View File

@ -51,9 +51,10 @@ public:
double m_LabelSizeRatio; double m_LabelSizeRatio;
double m_TextOffsetRatio; double m_TextOffsetRatio;
int m_PinSymbolSize; int m_PinSymbolSize;
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; // none = 0, smallest = 1, small = 2, etc.
int m_JunctionSizeChoice; int m_JunctionSize; // a runtime cache of the calculated size
int m_AnnotateStartNum; // Starting value for annotation int m_AnnotateStartNum; // Starting value for annotation
bool m_IntersheetRefsShow; bool m_IntersheetRefsShow;