diff --git a/eeschema/dialogs/panel_libedit_color_settings.cpp b/eeschema/dialogs/panel_libedit_color_settings.cpp index c2030589d9..83e632a29d 100644 --- a/eeschema/dialogs/panel_libedit_color_settings.cpp +++ b/eeschema/dialogs/panel_libedit_color_settings.cpp @@ -22,6 +22,7 @@ */ #include +#include #include #include #include diff --git a/eeschema/dialogs/panel_setup_formatting.cpp b/eeschema/dialogs/panel_setup_formatting.cpp index 7f5ec452eb..f64ef64d9c 100644 --- a/eeschema/dialogs/panel_setup_formatting.cpp +++ b/eeschema/dialogs/panel_setup_formatting.cpp @@ -28,6 +28,8 @@ #include #include #include +#include + PANEL_SETUP_FORMATTING::PANEL_SETUP_FORMATTING( wxWindow* aWindow, SCH_EDIT_FRAME* aFrame ) : PANEL_SETUP_FORMATTING_BASE( aWindow ), @@ -70,7 +72,7 @@ bool PANEL_SETUP_FORMATTING::TransferDataToWindow() m_busWidth.SetValue( m_frame->GetDefaultBusThickness() ); m_wireWidth.SetValue( m_frame->GetDefaultWireThickness() ); m_pinSymbolSize.SetValue( m_frame->GetPinSymbolSize() ); - m_junctionSize.SetValue( SCH_JUNCTION::g_SymbolSize ); + m_junctionSize.SetValue( m_frame->GetDefaults().m_JunctionSize ); wxString offsetRatio = wxString::Format( "%f", m_frame->GetTextOffsetRatio() * 100.0 ); m_textOffsetRatioCtrl->SetValue( offsetRatio ); @@ -100,7 +102,6 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow() firstRefId != LIB_PART::GetSubpartFirstId() ) { LIB_PART::SetSubpartIdNotation( refSeparator, firstRefId ); - m_frame->SaveProjectSettings(); } m_frame->SetDefaultTextSize( (int) m_textSize.GetValue() ); @@ -108,7 +109,10 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow() m_frame->SetDefaultWireThickness( (int) m_wireWidth.GetValue() ); m_frame->SetDefaultBusThickness( (int) m_busWidth.GetValue() ); m_frame->SetPinSymbolSize( (int) m_pinSymbolSize.GetValue() ); - SCH_JUNCTION::g_SymbolSize = (int) m_junctionSize.GetValue(); + + m_frame->GetDefaults().m_JunctionSize = (int) m_junctionSize.GetValue(); + + m_frame->SaveProjectSettings(); double dtmp = 0.0; wxString msg = m_textOffsetRatioCtrl->GetValue(); @@ -117,9 +121,10 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow() m_frame->GetRenderSettings()->SetDefaultPenWidth( m_frame->GetDefaultLineWidth() ); m_frame->GetRenderSettings()->m_DefaultWireThickness = m_frame->GetDefaultWireThickness(); - m_frame->GetRenderSettings()->m_DefaultBusThickness = m_frame->GetDefaultBusThickness(); - m_frame->GetRenderSettings()->m_TextOffsetRatio = m_frame->GetTextOffsetRatio(); - m_frame->GetRenderSettings()->m_PinSymbolSize = m_frame->GetPinSymbolSize(); + m_frame->GetRenderSettings()->m_DefaultBusThickness = m_frame->GetDefaultBusThickness(); + m_frame->GetRenderSettings()->m_TextOffsetRatio = m_frame->GetTextOffsetRatio(); + m_frame->GetRenderSettings()->m_PinSymbolSize = m_frame->GetPinSymbolSize(); + m_frame->GetRenderSettings()->m_JunctionSize = m_frame->GetDefaults().m_JunctionSize; m_frame->GetCanvas()->GetView()->MarkDirty(); m_frame->GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT ); diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index c3568d0b07..343321d5dc 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -93,7 +93,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType ) textItem->SetBold( lastTextBold ); textItem->SetItalic( lastTextItalic ); textItem->SetLabelSpinStyle( lastTextOrientation ); - textItem->SetTextSize( wxSize( m_defaultTextSize, m_defaultTextSize ) ); + textItem->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) ); textItem->SetFlags( IS_NEW | IS_MOVED ); if( InvokeDialogLabelEditor( this, textItem ) != wxID_OK || textItem->GetText().IsEmpty() ) diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 3ab75d98b6..6422741f61 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -244,38 +244,40 @@ void SCH_EDIT_FRAME::AddFormattingParameters( std::vector& params ) wxCHECK( appSettings, /*void*/ ); + SCHEMATIC_SETTINGS& settings = Schematic().Settings(); + params.push_back( new PARAM_CFG_INT( wxT( "SubpartIdSeparator" ), LIB_PART::SubpartIdSeparatorPtr(), 0, 0, 126 ) ); params.push_back( new PARAM_CFG_INT( wxT( "SubpartFirstId" ), LIB_PART::SubpartFirstIdPtr(), 'A', '1', 'z' ) ); params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "LabSize" ), - &m_defaultTextSize, + &settings.m_DefaultTextSize, Mils2iu( DEFAULT_SIZE_TEXT ), Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) ); params.push_back( new PARAM_CFG_DOUBLE( wxT( "TextOffsetRatio" ), - &m_textOffsetRatio, + &settings.m_TextOffsetRatio, (double) TXT_MARGIN / DEFAULT_SIZE_TEXT, -200.0, 200.0 ) ); params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "LineThickness" ), - &m_defaultLineWidth, + &settings.m_DefaultLineWidth, Mils2iu( appSettings->m_Drawing.default_line_thickness ), Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) ); params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "BusThickness" ), - &m_defaultBusThickness, + &settings.m_DefaultBusThickness, Mils2iu( appSettings->m_Drawing.default_bus_thickness ), Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) ); params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "WireThickness" ), - &m_defaultWireThickness, + &settings.m_DefaultWireThickness, Mils2iu( appSettings->m_Drawing.default_wire_thickness ), Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) ); params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PinSymbolSize" ), - &m_pinSymbolSize, + &settings.m_PinSymbolSize, Mils2iu( appSettings->m_Drawing.pin_symbol_size ), Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) ); params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "JunctionSize" ), - &SCH_JUNCTION::g_SymbolSize, + &settings.m_JunctionSize, Mils2iu( appSettings->m_Drawing.default_junction_size ), Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) ); } @@ -322,9 +324,10 @@ bool SCH_EDIT_FRAME::LoadProjectFile() GetRenderSettings()->SetDefaultPenWidth( GetDefaultLineWidth() ); GetRenderSettings()->m_DefaultWireThickness = GetDefaultWireThickness(); - GetRenderSettings()->m_DefaultBusThickness = GetDefaultBusThickness(); - GetRenderSettings()->m_TextOffsetRatio = m_textOffsetRatio; - GetRenderSettings()->m_PinSymbolSize = m_pinSymbolSize; + GetRenderSettings()->m_DefaultBusThickness = GetDefaultBusThickness(); + GetRenderSettings()->m_TextOffsetRatio = m_defaults->m_TextOffsetRatio; + GetRenderSettings()->m_PinSymbolSize = m_defaults->m_PinSymbolSize; + GetRenderSettings()->m_JunctionSize = m_defaults->m_JunctionSize; // Verify some values, because the config file can be edited by hand, // and have bad values: diff --git a/eeschema/eeschema_settings.cpp b/eeschema/eeschema_settings.cpp index 6ec23b1c73..5356b78b08 100644 --- a/eeschema/eeschema_settings.cpp +++ b/eeschema/eeschema_settings.cpp @@ -93,6 +93,9 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : APP_SETTINGS_BASE( "eeschema", eeschema m_params.emplace_back( new PARAM( "drawing.pin_symbol_size", &m_Drawing.pin_symbol_size, DEFAULT_TEXT_SIZE / 2 ) ); + m_params.emplace_back( + new PARAM( "drawing.text_offset_ratio", &m_Drawing.text_offset_ratio, 0.08 ) ); + m_params.emplace_back( new PARAM( "drawing.default_line_thickness", &m_Drawing.default_line_thickness, DEFAULT_LINE_THICKNESS ) ); @@ -105,6 +108,9 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : APP_SETTINGS_BASE( "eeschema", eeschema m_params.emplace_back( new PARAM( "drawing.default_wire_thickness", &m_Drawing.default_wire_thickness, DEFAULT_WIRE_THICKNESS ) ); + m_params.emplace_back( new PARAM( + "drawing.default_text_size", &m_Drawing.default_text_size, DEFAULT_TEXT_SIZE ) ); + m_params.emplace_back( new PARAM( "drawing.field_names", &m_Drawing.field_names, "" ) ); diff --git a/eeschema/eeschema_settings.h b/eeschema/eeschema_settings.h index 6e55175630..2d272847d9 100644 --- a/eeschema/eeschema_settings.h +++ b/eeschema/eeschema_settings.h @@ -59,18 +59,20 @@ public: struct DRAWING { - int default_bus_thickness; - int default_junction_size; - int default_line_thickness; - int default_repeat_offset_x; - int default_repeat_offset_y; - int default_wire_thickness; - int pin_symbol_size; - COLOR4D default_sheet_border_color; - COLOR4D default_sheet_background_color; + int default_bus_thickness; + int default_junction_size; + int default_line_thickness; + int default_repeat_offset_x; + int default_repeat_offset_y; + int default_wire_thickness; + int default_text_size; + int pin_symbol_size; + double text_offset_ratio; + COLOR4D default_sheet_border_color; + COLOR4D default_sheet_background_color; wxString field_names; - bool hv_lines_only; - int repeat_label_increment; + bool hv_lines_only; + int repeat_label_increment; }; struct INPUT diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index f334322050..75fe20b78e 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -83,13 +84,8 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindo const wxString& aTitle, const wxPoint& aPosition, const wxSize& aSize, long aStyle, const wxString& aFrameName ) : EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, aSize, aStyle, aFrameName ), - m_defaultLineWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ), - m_defaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ), - m_defaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS ), - m_defaultTextSize( DEFAULT_TEXT_SIZE * IU_PER_MILS ), - m_textOffsetRatio( 0.08 ), - m_pinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ), - m_showPinElectricalTypeName( false ) + m_showPinElectricalTypeName( false ), + m_defaults( &m_base_frame_defaults ) { createCanvas(); @@ -122,6 +118,18 @@ void SCH_BASE_FRAME::SetScreen( BASE_SCREEN* aScreen ) } +EESCHEMA_SETTINGS* SCH_BASE_FRAME::eeconfig() const +{ + return dynamic_cast( config() ); +} + + +LIBEDIT_SETTINGS* SCH_BASE_FRAME::libeditconfig() const +{ + return dynamic_cast( config() ); +} + + const wxString SCH_BASE_FRAME::GetZoomLevelIndicator() const { return EDA_DRAW_FRAME::GetZoomLevelIndicator(); @@ -130,28 +138,28 @@ const wxString SCH_BASE_FRAME::GetZoomLevelIndicator() const void SCH_BASE_FRAME::SetDefaultLineWidth( int aWidth ) { - m_defaultLineWidth = aWidth; + m_defaults->m_DefaultLineWidth = aWidth; GetRenderSettings()->SetDefaultPenWidth( aWidth ); } void SCH_BASE_FRAME::SetDefaultWireThickness( int aThickness ) { - m_defaultWireThickness = aThickness; + m_defaults->m_DefaultWireThickness = aThickness; GetRenderSettings()->m_DefaultWireThickness = aThickness; } void SCH_BASE_FRAME::SetDefaultBusThickness( int aThickness ) { - m_defaultBusThickness = aThickness; + m_defaults->m_DefaultBusThickness = aThickness; GetRenderSettings()->m_DefaultBusThickness = aThickness; } void SCH_BASE_FRAME::SetPinSymbolSize( int aSize ) { - m_pinSymbolSize = aSize; + m_defaults->m_PinSymbolSize = aSize; GetRenderSettings()->m_PinSymbolSize = aSize; } diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index ba6a9ee4c4..8617a6382d 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -57,6 +57,8 @@ class PART_LIB; class SCHLIB_FILTER; class LIB_ID; class SYMBOL_LIB_TABLE; +class EESCHEMA_SETTINGS; +class LIBEDIT_SETTINGS; /** * Load symbol from symbol library table. @@ -88,17 +90,15 @@ LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, class SCH_BASE_FRAME : public EDA_DRAW_FRAME { protected: - int m_defaultLineWidth; - int m_defaultWireThickness; - int m_defaultBusThickness; - int m_defaultTextSize; - double m_textOffsetRatio; - int m_pinSymbolSize; - TEMPLATES m_templateFieldNames; bool m_showPinElectricalTypeName; + /// These are only used by libedit. Eeschema should be using the one inside the SCHEMATIC. + SCHEMATIC_SETTINGS m_base_frame_defaults; + + SCHEMATIC_SETTINGS* m_defaults; + public: SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindowType, @@ -114,13 +114,20 @@ public: SCH_SCREEN* GetScreen() const override; void SetScreen( BASE_SCREEN* aScreen ) override; - EESCHEMA_SETTINGS* eeconfig() const { return dynamic_cast( config() ); } + EESCHEMA_SETTINGS* eeconfig() const; + + LIBEDIT_SETTINGS* libeditconfig() const; void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; KIGFX::SCH_RENDER_SETTINGS* GetRenderSettings(); + SCHEMATIC_SETTINGS& GetDefaults() + { + return *m_defaults; + } + /** * Allow some frames to show/hide hidden pins. The default impl shows all pins. */ @@ -132,23 +139,23 @@ public: bool GetShowElectricalType() { return m_showPinElectricalTypeName; } void SetShowElectricalType( bool aShow ) { m_showPinElectricalTypeName = aShow; } - int GetDefaultLineWidth() const { return m_defaultLineWidth; } - void SetDefaultLineWidth( int aWidth ); + virtual int GetDefaultLineWidth() const { return m_defaults->m_DefaultLineWidth; } + virtual void SetDefaultLineWidth( int aWidth ); - int GetDefaultWireThickness() const { return m_defaultWireThickness; } - void SetDefaultWireThickness( int aThickness ); + virtual int GetDefaultWireThickness() const { return m_defaults->m_DefaultWireThickness; } + virtual void SetDefaultWireThickness( int aThickness ); - int GetDefaultBusThickness() const { return m_defaultBusThickness; } - void SetDefaultBusThickness( int aThickness ); + virtual int GetDefaultBusThickness() const { return m_defaults->m_DefaultBusThickness; } + virtual void SetDefaultBusThickness( int aThickness ); - int GetPinSymbolSize() const { return m_pinSymbolSize; } - void SetPinSymbolSize( int aSize ); + virtual int GetPinSymbolSize() const { return m_defaults->m_PinSymbolSize; } + virtual void SetPinSymbolSize( int aSize ); - int GetDefaultTextSize() const { return m_defaultTextSize; } - void SetDefaultTextSize( int aSize ) { m_defaultTextSize = aSize; } + virtual int GetDefaultTextSize() const { return m_defaults->m_DefaultTextSize; } + virtual void SetDefaultTextSize( int aSize ) { m_defaults->m_DefaultTextSize = aSize; } - double GetTextOffsetRatio() const { return m_textOffsetRatio; } - void SetTextOffsetRatio( double aRatio ) { m_textOffsetRatio = aRatio; } + virtual double GetTextOffsetRatio() const { return m_defaults->m_TextOffsetRatio; } + virtual void SetTextOffsetRatio( double aRatio ) { m_defaults->m_TextOffsetRatio = aRatio; } /** * Function GetZoomLevelIndicator diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 4072f4f6ce..0404493d63 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -210,6 +210,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): { m_schematic = new SCHEMATIC(); + m_defaults = &m_schematic->Settings(); + m_showBorderAndTitleBlock = true; // true to show sheet references m_hasAutoSave = true; m_AboutTitle = "Eeschema"; diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 22bda30e03..0a8c81b986 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include // enum PINSHEETLABEL_SHAPE @@ -46,7 +47,6 @@ class STATUS_TEXT_POPUP; -class APP_SETTINGS_BASE; class SCH_ITEM; class EDA_ITEM; class SCH_LINE; diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 22096fd07e..1f075d478c 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -38,18 +38,10 @@ #include #include #include +#include #include -int SCH_JUNCTION::g_SymbolSize = Mils2iu( 40 ); // Default diameter of the junction symbol - - -int SCH_JUNCTION::GetSymbolSize() -{ - return g_SymbolSize; -} - - SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos, SCH_LAYER_ID aLayer ) : SCH_ITEM( NULL, SCH_JUNCTION_T ) { @@ -86,8 +78,11 @@ const EDA_RECT SCH_JUNCTION::GetBoundingBox() const { EDA_RECT rect; + int size = + Schematic() ? Schematic()->Settings().m_JunctionSize : Mils2iu( DEFAULT_JUNCTION_DIAM ); + rect.SetOrigin( m_pos ); - rect.Inflate( ( GetPenWidth() + GetSymbolSize() ) / 2 ); + rect.Inflate( ( GetPenWidth() + size ) / 2 ); return rect; } @@ -98,8 +93,8 @@ void SCH_JUNCTION::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) wxDC* DC = aSettings->GetPrintDC(); COLOR4D color = aSettings->GetLayerColor( GetLayer() ); - GRFilledCircle( nullptr, DC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, GetSymbolSize() / 2, - 0, color, color ); + GRFilledCircle( nullptr, DC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, + Schematic()->Settings().m_JunctionSize / 2, 0, color, color ); } @@ -195,7 +190,7 @@ bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const void SCH_JUNCTION::Plot( PLOTTER* aPlotter ) { aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( GetLayer() ) ); - aPlotter->Circle( m_pos, GetSymbolSize(), FILLED_SHAPE ); + aPlotter->Circle( m_pos, Schematic()->Settings().m_JunctionSize, FILLED_SHAPE ); } diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 56aad21ce9..3be6ebf9ca 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -33,9 +33,6 @@ class SCH_JUNCTION : public SCH_ITEM { wxPoint m_pos; // Position of the junction. -public: - static int g_SymbolSize; // diameter of the junction graphic symbol - public: SCH_JUNCTION( const wxPoint& pos = wxPoint( 0, 0 ), SCH_LAYER_ID aLayer = LAYER_JUNCTION ); @@ -53,8 +50,6 @@ public: return wxT( "SCH_JUNCTION" ); } - static int GetSymbolSize(); - void SwapData( SCH_ITEM* aItem ) override; void ViewGetLayers( int aLayers[], int& aCount ) const override; diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 5d7591ca12..55ffa2f7e4 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -79,7 +79,8 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() : m_TextOffsetRatio( 0.08 ), m_DefaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ), m_DefaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS ), - 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 ) { SetDefaultPenWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ); } @@ -1177,7 +1178,7 @@ void SCH_PAINTER::draw( SCH_JUNCTION *aJct, int aLayer ) m_gal->SetStrokeColor( color ); m_gal->SetIsFill( !drawingShadows ); m_gal->SetFillColor( color ); - m_gal->DrawCircle( aJct->GetPosition(), SCH_JUNCTION::GetSymbolSize() / 2.0 ); + m_gal->DrawCircle( aJct->GetPosition(), m_schSettings.m_JunctionSize / 2.0 ); } diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index ee84eb7c4a..086cc2f411 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -117,6 +117,7 @@ public: int m_DefaultWireThickness; int m_DefaultBusThickness; int m_PinSymbolSize; + int m_JunctionSize; }; diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 7c3702165f..b6def971f2 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -561,7 +561,7 @@ bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer ) if( GetItem( aPosition, Mils2iu( 6 ), SCH_BUS_BUS_ENTRY_T) ) return true; - if( GetItem( aPosition, SCH_JUNCTION::GetSymbolSize(), SCH_JUNCTION_T ) ) + if( GetItem( aPosition, Schematic()->Settings().m_JunctionSize, SCH_JUNCTION_T ) ) return true; if( GetPin( aPosition, NULL, true ) ) diff --git a/eeschema/schematic.h b/eeschema/schematic.h index 25d24c7036..4b88b23f1a 100644 --- a/eeschema/schematic.h +++ b/eeschema/schematic.h @@ -22,6 +22,7 @@ #include #include +#include class BUS_ALIAS; @@ -57,6 +58,9 @@ private: /// Holds and calculates connectivity information of this schematic CONNECTION_GRAPH* m_connectionGraph; + /// Project-specific schematic settings + SCHEMATIC_SETTINGS m_settings; + /// Holds this schematic's ERC settings // TODO: This should be moved to project settings, not schematic ERC_SETTINGS* m_ercSettings; @@ -121,6 +125,11 @@ public: return m_connectionGraph; } + SCHEMATIC_SETTINGS& Settings() + { + return m_settings; + } + /** * Returns a pointer to a bus alias object for the given label, * or null if one doesn't exist diff --git a/eeschema/schematic_settings.h b/eeschema/schematic_settings.h new file mode 100644 index 0000000000..3055d1bf7b --- /dev/null +++ b/eeschema/schematic_settings.h @@ -0,0 +1,55 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef KICAD_SCHEMATIC_SETTINGS_H +#define KICAD_SCHEMATIC_SETTINGS_H + +#include +#include + +/** + * These settings were stored in SCH_BASE_FRAME previously. + * The backing store is currently the project file. + * They should likely move to a project settings file (JSON) once that framework exists. + * + * These are loaded from eeschema settings but then overwritten by the project settings. + * All of the values are stored in IU, but the backing file stores in mils. + */ +struct SCHEMATIC_SETTINGS +{ + SCHEMATIC_SETTINGS() : + m_DefaultLineWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ), + m_DefaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ), + m_DefaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS ), + m_DefaultTextSize( DEFAULT_TEXT_SIZE * IU_PER_MILS ), + m_TextOffsetRatio( 0.08 ), + m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ), + m_JunctionSize( DEFAULT_JUNCTION_DIAM * IU_PER_MILS ) + {} + + int m_DefaultLineWidth; + int m_DefaultWireThickness; + int m_DefaultBusThickness; + int m_DefaultTextSize; + double m_TextOffsetRatio; + int m_PinSymbolSize; + int m_JunctionSize; +}; + +#endif diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 2036d8147a..bee502134c 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -473,6 +473,8 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) return 0; } + previewItem->SetParent( m_frame->GetScreen() ); + m_view->ClearPreview(); m_view->AddToPreview( previewItem->Clone() );