From d761b4f22feca5c02b0a583a7406892db75e8c4f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 15 Apr 2024 21:18:54 +0100 Subject: [PATCH] RIP LIB_TEXTBOX and LIB_SHAPE. --- common/api/api_enums.cpp | 4 - common/eda_item.cpp | 2 - common/eda_shape.cpp | 18 +- eeschema/CMakeLists.txt | 6 - eeschema/api/api_sch_utils.cpp | 4 - .../dialogs/dialog_lib_shape_properties.cpp | 307 -- .../dialogs/dialog_lib_shape_properties.h | 64 - .../dialog_lib_shape_properties_base.cpp | 182 - .../dialog_lib_shape_properties_base.fbp | 1462 -------- .../dialog_lib_shape_properties_base.h | 94 - .../dialogs/dialog_lib_textbox_properties.cpp | 395 --- .../dialogs/dialog_lib_textbox_properties.h | 68 - .../dialog_lib_textbox_properties_base.cpp | 328 -- .../dialog_lib_textbox_properties_base.fbp | 3091 ----------------- .../dialog_lib_textbox_properties_base.h | 111 - eeschema/dialogs/dialog_shape_properties.cpp | 216 +- eeschema/dialogs/dialog_shape_properties.h | 19 +- .../dialogs/dialog_shape_properties_base.cpp | 200 +- .../dialogs/dialog_shape_properties_base.fbp | 2904 ++++++++++------ .../dialogs/dialog_shape_properties_base.h | 34 +- eeschema/dialogs/dialog_text_properties.cpp | 11 +- .../dialogs/panel_eeschema_color_settings.cpp | 5 +- eeschema/gfx_import_utils.cpp | 5 +- .../graphics_importer_lib_symbol.cpp | 17 +- .../import_gfx/graphics_importer_lib_symbol.h | 3 - eeschema/lib_pin.cpp | 5 +- eeschema/lib_pin.h | 20 +- eeschema/lib_shape.cpp | 602 ---- eeschema/lib_shape.h | 141 - eeschema/lib_symbol.cpp | 22 +- eeschema/lib_symbol.h | 2 +- eeschema/lib_textbox.cpp | 608 ---- eeschema/lib_textbox.h | 130 - eeschema/sch_field.h | 4 +- eeschema/sch_io/altium/sch_io_altium.cpp | 92 +- eeschema/sch_io/altium/sch_io_altium.h | 1 + .../cadstar/cadstar_sch_archive_loader.cpp | 37 +- eeschema/sch_io/eagle/sch_io_eagle.cpp | 51 +- eeschema/sch_io/eagle/sch_io_eagle.h | 16 +- .../sch_io/easyeda/sch_easyeda_parser.cpp | 73 +- eeschema/sch_io/easyeda/sch_easyeda_parser.h | 10 - .../easyedapro/sch_easyedapro_parser.cpp | 16 +- .../sch_io/easyedapro/sch_easyedapro_parser.h | 6 - .../sch_io_kicad_legacy_lib_cache.cpp | 69 +- .../sch_io_kicad_legacy_lib_cache.h | 24 +- .../sch_io_kicad_sexpr_lib_cache.cpp | 16 +- .../sch_io_kicad_sexpr_lib_cache.h | 4 +- .../kicad_sexpr/sch_io_kicad_sexpr_parser.cpp | 41 +- .../kicad_sexpr/sch_io_kicad_sexpr_parser.h | 14 +- .../sch_io/ltspice/sch_io_ltspice_parser.cpp | 22 +- .../sch_io/ltspice/sch_io_ltspice_parser.h | 10 +- eeschema/sch_painter.cpp | 466 +-- eeschema/sch_painter.h | 15 +- eeschema/sch_shape.cpp | 469 ++- eeschema/sch_shape.h | 51 +- eeschema/sch_symbol.cpp | 7 +- eeschema/sch_tablecell.cpp | 3 +- eeschema/sch_text.cpp | 6 +- eeschema/sch_textbox.cpp | 204 +- eeschema/sch_textbox.h | 21 +- eeschema/symbol_checker.cpp | 8 +- eeschema/tools/ee_grid_helper.cpp | 2 - eeschema/tools/ee_point_editor.cpp | 492 +-- eeschema/tools/ee_selection_tool.cpp | 16 +- eeschema/tools/ee_tool_base.h | 16 +- eeschema/tools/sch_drawing_tools.cpp | 6 +- eeschema/tools/sch_edit_tool.cpp | 2 +- .../tools/symbol_editor_drawing_tools.cpp | 21 +- eeschema/tools/symbol_editor_edit_tool.cpp | 29 +- eeschema/tools/symbol_editor_edit_tool.h | 2 +- eeschema/tools/symbol_editor_move_tool.cpp | 12 +- include/core/typeinfo.h | 34 +- include/eda_shape.h | 8 +- pcbnew/pcb_shape.h | 20 +- pcbnew/tools/pcb_point_editor.cpp | 34 +- qa/schematic_utils/schematic_file_util.cpp | 1 - qa/tests/eeschema/test_ee_item.cpp | 8 +- qa/tests/eeschema/test_lib_part.cpp | 22 +- 78 files changed, 3429 insertions(+), 10132 deletions(-) delete mode 100644 eeschema/dialogs/dialog_lib_shape_properties.cpp delete mode 100644 eeschema/dialogs/dialog_lib_shape_properties.h delete mode 100644 eeschema/dialogs/dialog_lib_shape_properties_base.cpp delete mode 100644 eeschema/dialogs/dialog_lib_shape_properties_base.fbp delete mode 100644 eeschema/dialogs/dialog_lib_shape_properties_base.h delete mode 100644 eeschema/dialogs/dialog_lib_textbox_properties.cpp delete mode 100644 eeschema/dialogs/dialog_lib_textbox_properties.h delete mode 100644 eeschema/dialogs/dialog_lib_textbox_properties_base.cpp delete mode 100644 eeschema/dialogs/dialog_lib_textbox_properties_base.fbp delete mode 100644 eeschema/dialogs/dialog_lib_textbox_properties_base.h delete mode 100644 eeschema/lib_shape.cpp delete mode 100644 eeschema/lib_shape.h delete mode 100644 eeschema/lib_textbox.cpp delete mode 100644 eeschema/lib_textbox.h diff --git a/common/api/api_enums.cpp b/common/api/api_enums.cpp index 0f02aa70fb..d03e066d7d 100644 --- a/common/api/api_enums.cpp +++ b/common/api/api_enums.cpp @@ -75,8 +75,6 @@ KICAD_T FromProtoEnum( types::KiCadObjectType aValue ) case types::KiCadObjectType::KOT_SCH_SHEET: return SCH_SHEET_T; case types::KiCadObjectType::KOT_SCH_PIN: return SCH_PIN_T; case types::KiCadObjectType::KOT_LIB_SYMBOL: return LIB_SYMBOL_T; - // case types::KiCadObjectType::KOT_LIB_SHAPE: return LIB_SHAPE_T; - // case types::KiCadObjectType::KOT_LIB_TEXTBOX: return LIB_TEXTBOX_T; // case types::KiCadObjectType::KOT_LIB_PIN: return LIB_PIN_T; case types::KiCadObjectType::KOT_WSG_LINE: return WSG_LINE_T; case types::KiCadObjectType::KOT_WSG_RECT: return WSG_RECT_T; @@ -137,8 +135,6 @@ types::KiCadObjectType ToProtoEnum( KICAD_T aValue ) case SCH_SHEET_T: return types::KiCadObjectType::KOT_SCH_SHEET; case SCH_PIN_T: return types::KiCadObjectType::KOT_SCH_PIN; case LIB_SYMBOL_T: return types::KiCadObjectType::KOT_LIB_SYMBOL; - // case LIB_SHAPE_T: return types::KiCadObjectType::KOT_LIB_SHAPE; - // case LIB_TEXTBOX_T: return types::KiCadObjectType::KOT_LIB_TEXTBOX; // case LIB_PIN_T: return types::KiCadObjectType::KOT_LIB_PIN; case WSG_LINE_T: return types::KiCadObjectType::KOT_WSG_LINE; case WSG_RECT_T: return types::KiCadObjectType::KOT_WSG_RECT; diff --git a/common/eda_item.cpp b/common/eda_item.cpp index 1e1f0d9742..7a610a33b8 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -396,8 +396,6 @@ static struct EDA_ITEM_DESC .Map( SCH_SCREEN_T, _HKI( "SCH Screen" ) ) .Map( LIB_SYMBOL_T, _HKI( "Symbol" ) ) - .Map( LIB_SHAPE_T, _HKI( "Graphic" ) ) - .Map( LIB_TEXTBOX_T, _HKI( "Text Box" ) ) .Map( LIB_PIN_T, _HKI( "Pin" ) ) .Map( GERBER_LAYOUT_T, _HKI( "Gerber Layout" ) ) diff --git a/common/eda_shape.cpp b/common/eda_shape.cpp index 784c515556..1c571c77ca 100644 --- a/common/eda_shape.cpp +++ b/common/eda_shape.cpp @@ -5,7 +5,7 @@ * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2011 Wayne Stambaugh * Copyright (C) 2023 CERN - * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 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 @@ -701,7 +701,7 @@ void EDA_SHAPE::SetArcAngleAndEnd( const EDA_ANGLE& aAngle, bool aCheckNegativeA } -wxString EDA_SHAPE::GetFriendlyName() const +wxString EDA_SHAPE::getFriendlyName() const { if( IsProxyItem() ) { @@ -733,7 +733,7 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aBuffer ) const bool EDA_SHAPE::IsPolyShapeValid() const { // return true if the polygonal shape is valid (has more than 2 points) - if( GetPolyShape().OutlineCount() == 0 ) - return false; - - const SHAPE_LINE_CHAIN& outline = static_cast( GetPolyShape() ).Outline( 0 ); - - return outline.PointCount() > 2; + return GetPolyShape().OutlineCount() > 0 && GetPolyShape().Outline( 0 ).PointCount() > 2; } @@ -1335,10 +1330,7 @@ int EDA_SHAPE::GetPointCount() const { // return the number of corners of the polygonal shape // this shape is expected to be only one polygon without hole - if( GetPolyShape().OutlineCount() ) - return GetPolyShape().VertexCount( 0 ); - - return 0; + return GetPolyShape().OutlineCount() ? GetPolyShape().VertexCount( 0 ) : 0; } diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 962153bed6..45b16d0ac7 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -123,12 +123,8 @@ set( EESCHEMA_DLGS dialogs/dialog_lib_edit_pin_table_base.cpp dialogs/dialog_lib_new_symbol.cpp dialogs/dialog_lib_new_symbol_base.cpp - dialogs/dialog_lib_shape_properties.cpp - dialogs/dialog_lib_shape_properties_base.cpp dialogs/dialog_lib_symbol_properties.cpp dialogs/dialog_lib_symbol_properties_base.cpp - dialogs/dialog_lib_textbox_properties.cpp - dialogs/dialog_lib_textbox_properties_base.cpp dialogs/dialog_line_properties.cpp dialogs/dialog_line_properties_base.cpp dialogs/dialog_migrate_buses.cpp @@ -360,9 +356,7 @@ set( EESCHEMA_SRCS gfx_import_utils.cpp picksymbol.cpp lib_pin.cpp - lib_shape.cpp lib_symbol.cpp - lib_textbox.cpp libarch.cpp menubar.cpp net_navigator.cpp diff --git a/eeschema/api/api_sch_utils.cpp b/eeschema/api/api_sch_utils.cpp index 6995cf6682..62cb03db60 100644 --- a/eeschema/api/api_sch_utils.cpp +++ b/eeschema/api/api_sch_utils.cpp @@ -19,9 +19,7 @@ */ #include -#include #include -#include #include #include #include @@ -91,8 +89,6 @@ std::unique_ptr CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer } case LIB_SYMBOL_T: return nullptr; // TODO: ctor currently requires non-null name - case LIB_SHAPE_T: return std::make_unique( parentLibSymbol ); - case LIB_TEXTBOX_T: return std::make_unique( parentLibSymbol ); case LIB_PIN_T: return std::make_unique( parentLibSymbol ); default: diff --git a/eeschema/dialogs/dialog_lib_shape_properties.cpp b/eeschema/dialogs/dialog_lib_shape_properties.cpp deleted file mode 100644 index 862056d4fd..0000000000 --- a/eeschema/dialogs/dialog_lib_shape_properties.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2006-2022 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 2 - * 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, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -DIALOG_LIB_SHAPE_PROPERTIES::DIALOG_LIB_SHAPE_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, - LIB_SHAPE* aShape ) : - DIALOG_LIB_SHAPE_PROPERTIES_BASE( aParent ), - m_frame( aParent ), - m_shape( aShape ), - m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits, true ) -{ - wxASSERT( aShape ); - - SetTitle( wxString::Format( GetTitle(), aShape->EDA_SHAPE::GetFriendlyName() ) ); - - m_helpLabel->SetFont( KIUI::GetInfoFont( this ).Italic() ); - - COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings(); - COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); - - m_borderColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); - m_borderColorSwatch->SetSwatchBackground( schematicBackground ); - - for( const auto& [ lineStyle, lineStyleDesc ] : lineTypeNames ) - m_borderStyleCombo->Append( lineStyleDesc.name, KiBitmapBundle( lineStyleDesc.bitmap ) ); - - m_borderStyleCombo->Append( DEFAULT_STYLE ); - - m_fillColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); - m_fillColorSwatch->SetSwatchBackground( schematicBackground ); - - m_helpLabel->SetFont( KIUI::GetInfoFont( this ).Italic() ); - - if( m_frame->GetColorSettings()->GetOverrideSchItemColors() ) - m_infoBar->ShowMessage( _( "Note: individual item colors overridden in Preferences." ) ); - - SetInitialFocus( m_borderWidthCtrl ); - - // Required under wxGTK if we want to dismiss the dialog with the ESC key - SetFocus(); - - SetupStandardButtons(); - - if( !aParent->IsSymbolEditable() || aParent->IsSymbolAlias() ) - { - m_sdbSizerCancel->SetDefault(); - m_sdbSizerOK->SetLabel( _( "Read Only" ) ); - m_sdbSizerOK->Enable( false ); - } - - m_borderColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_LIB_SHAPE_PROPERTIES::onBorderSwatch, this ); - m_fillColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_LIB_SHAPE_PROPERTIES::onFillSwatch, this ); - - // Now all widgets have the size fixed, call FinishDialogSettings - finishDialogSettings(); -} - - -DIALOG_LIB_SHAPE_PROPERTIES::~DIALOG_LIB_SHAPE_PROPERTIES() -{ - m_borderColorSwatch->Unbind( COLOR_SWATCH_CHANGED, &DIALOG_LIB_SHAPE_PROPERTIES::onBorderSwatch, this ); - m_fillColorSwatch->Unbind( COLOR_SWATCH_CHANGED, &DIALOG_LIB_SHAPE_PROPERTIES::onFillSwatch, this ); -} - - -bool DIALOG_LIB_SHAPE_PROPERTIES::TransferDataToWindow() -{ - if( !wxDialog::TransferDataToWindow() ) - return false; - - const SYMBOL* symbol = m_shape->GetParentSymbol(); - - m_checkBorder->SetValue( m_shape->GetWidth() >= 0 ); - - if( m_shape->GetWidth() >= 0 ) - m_borderWidth.SetValue( m_shape->GetWidth() ); - - m_borderWidth.Enable( m_shape->GetWidth() >= 0 ); - m_helpLabel->Enable( m_shape->GetWidth() >= 0 ); - m_borderColorLabel->Enable( m_shape->GetWidth() >= 0 ); - m_borderColorSwatch->Enable( m_shape->GetWidth() >= 0 ); - m_borderStyleLabel->Enable( m_shape->GetWidth() >= 0 ); - m_borderStyleCombo->Enable( m_shape->GetWidth() >= 0 ); - - m_borderColorSwatch->SetSwatchColor( m_shape->GetStroke().GetColor(), false ); - - int style = static_cast( m_shape->GetStroke().GetLineStyle() ); - - if( style == -1 ) - m_borderStyleCombo->SetStringSelection( DEFAULT_STYLE ); - else if( style < (int) lineTypeNames.size() ) - m_borderStyleCombo->SetSelection( style ); - else - wxFAIL_MSG( "Line type not found in the type lookup map" ); - - m_privateCheckbox->SetValue( m_shape->IsPrivate() ); - m_checkApplyToAllUnits->SetValue( - symbol && symbol->GetUnitCount() > 1 && m_shape->GetUnit() == 0 ); - m_checkApplyToAllUnits->Enable( symbol && symbol->GetUnitCount() > 1 ); - m_checkApplyToAllBodyStyles->SetValue( m_shape->GetBodyStyle() == 0 ); - - bool enableAlternateBodyStyle = symbol && symbol->HasAlternateBodyStyle(); - - // If a symbol contains no body-style-specific pins or graphic items, - // symbol->HasAlternateBodyStyle() will return false. - // But when creating a new symbol, with DeMorgan option set, the m_checkApplyToAllBodyStyles - // must be enabled in order to be able to create graphic items shared by all body styles. - if( m_frame->GetShowDeMorgan() ) - enableAlternateBodyStyle = true; - - m_checkApplyToAllBodyStyles->Enable( enableAlternateBodyStyle ); - - m_rbFillNone->Enable( true ); - m_rbFillOutline->Enable( true ); - m_rbFillBackground->Enable( true ); - m_rbFillCustom->Enable( true ); - m_fillColorSwatch->Enable( true ); - - if( m_shape->GetFillMode() == FILL_T::FILLED_SHAPE ) - { - m_rbFillOutline->SetValue( true ); - - COLOR4D color = m_shape->GetStroke().GetColor(); - - if( color == COLOR4D::UNSPECIFIED ) - color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE ); - - m_fillColorSwatch->SetSwatchColor( color, false ); - } - else if( m_shape->GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR ) - { - m_rbFillBackground->SetValue( true ); - - COLOR4D color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); - m_fillColorSwatch->SetSwatchColor( color, false ); - } - else if( m_shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR ) - { - m_rbFillCustom->SetValue( true ); - m_fillColorSwatch->SetSwatchColor( m_shape->GetFillColor(), false ); - } - else - { - m_rbFillNone->SetValue( true ); - m_fillColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false ); - } - - return true; -} - - -void DIALOG_LIB_SHAPE_PROPERTIES::onFill( wxCommandEvent& event ) -{ - if( event.GetId() == NO_FILL ) - { - m_rbFillNone->SetValue( true ); - m_fillColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false ); - } - else if( event.GetId() == FILLED_SHAPE ) - { - m_rbFillOutline->SetValue( true ); - - COLOR4D color = m_shape->GetStroke().GetColor(); - - if( color == COLOR4D::UNSPECIFIED ) - color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE ); - - m_fillColorSwatch->SetSwatchColor( color, false ); - } - else if( event.GetId() == FILLED_WITH_BG_BODYCOLOR ) - { - m_rbFillBackground->SetValue( true ); - - COLOR4D color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); - m_fillColorSwatch->SetSwatchColor( color, false ); - } - else if( event.GetId() == FILLED_WITH_COLOR ) - { - m_rbFillCustom->SetValue( true ); - m_fillColorSwatch->GetNewSwatchColor(); - } -} - - -void DIALOG_LIB_SHAPE_PROPERTIES::onBorderChecked( wxCommandEvent& event ) -{ - bool border = m_checkBorder->GetValue(); - - if( border && m_borderWidth.GetValue() < 0 ) - m_borderWidth.SetValue( schIUScale.MilsToIU( m_frame->libeditconfig()->m_Defaults.line_width ) ); - - m_borderWidth.Enable( border ); - m_borderColorLabel->Enable( border ); - m_borderColorSwatch->Enable( border ); - m_borderStyleLabel->Enable( border ); - m_borderStyleCombo->Enable( border ); -} - - -void DIALOG_LIB_SHAPE_PROPERTIES::onBorderSwatch( wxCommandEvent& aEvent ) -{ - if( m_rbFillOutline->GetValue() ) - m_fillColorSwatch->SetSwatchColor( m_borderColorSwatch->GetSwatchColor(), false ); -} - - -void DIALOG_LIB_SHAPE_PROPERTIES::onFillSwatch( wxCommandEvent& aEvent ) -{ - m_rbFillCustom->SetValue( true ); -} - - -bool DIALOG_LIB_SHAPE_PROPERTIES::TransferDataFromWindow() -{ - if( !wxDialog::TransferDataFromWindow() ) - return false; - - STROKE_PARAMS stroke = m_shape->GetStroke(); - - if( m_checkBorder->GetValue() ) - { - if( !m_borderWidth.IsIndeterminate() ) - stroke.SetWidth( m_borderWidth.GetValue() ); - } - else - { - stroke.SetWidth( -1 ); - } - - auto it = lineTypeNames.begin(); - std::advance( it, m_borderStyleCombo->GetSelection() ); - - if( it == lineTypeNames.end() ) - stroke.SetLineStyle( LINE_STYLE::DEFAULT ); - else - stroke.SetLineStyle( it->first ); - - stroke.SetColor( m_borderColorSwatch->GetSwatchColor() ); - - m_shape->SetStroke( stroke ); - - if( m_rbFillOutline->GetValue() ) - m_shape->SetFillMode( FILL_T::FILLED_SHAPE ); - else if( m_rbFillBackground->GetValue() ) - m_shape->SetFillMode( FILL_T::FILLED_WITH_BG_BODYCOLOR ); - else if( m_rbFillCustom->GetValue() ) - m_shape->SetFillMode( FILL_T::FILLED_WITH_COLOR ); - else - m_shape->SetFillMode( FILL_T::NO_FILL ); - - m_shape->SetFillColor( m_fillColorSwatch->GetSwatchColor() ); - - m_shape->SetPrivate( m_privateCheckbox->GetValue() ); - - if( GetApplyToAllConversions() ) - m_shape->SetBodyStyle( 0 ); - else - m_shape->SetBodyStyle( m_frame->GetBodyStyle() ); - - if( GetApplyToAllUnits() ) - m_shape->SetUnit( 0 ); - else - m_shape->SetUnit( m_frame->GetUnit() ); - - return true; -} - - -bool DIALOG_LIB_SHAPE_PROPERTIES::GetApplyToAllConversions() -{ - return m_checkApplyToAllBodyStyles->IsChecked(); -} - - -bool DIALOG_LIB_SHAPE_PROPERTIES::GetApplyToAllUnits() -{ - return m_checkApplyToAllUnits->IsChecked(); -} - diff --git a/eeschema/dialogs/dialog_lib_shape_properties.h b/eeschema/dialogs/dialog_lib_shape_properties.h deleted file mode 100644 index 9b88e748e9..0000000000 --- a/eeschema/dialogs/dialog_lib_shape_properties.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2009 Wayne Stambaugh - * Copyright (C) 2014-2022 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 2 - * 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, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef DIALOG_LIB_SHAPE_PROPERTIES_H -#define DIALOG_LIB_SHAPE_PROPERTIES_H - - -class LIB_SHAPE; -class SYMBOL_EDIT_FRAME; - - -#include -#include - -/** - * Dialog to edit library component graphic items. - */ -class DIALOG_LIB_SHAPE_PROPERTIES : public DIALOG_LIB_SHAPE_PROPERTIES_BASE -{ -public: - /** Constructor */ - DIALOG_LIB_SHAPE_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_SHAPE* aShape ); - ~DIALOG_LIB_SHAPE_PROPERTIES(); - - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; - - bool GetApplyToAllConversions(); - bool GetApplyToAllUnits(); - -private: - void onBorderChecked( wxCommandEvent& aEvent ) override; - void onBorderSwatch( wxCommandEvent& aEvent ); - void onFill(wxCommandEvent &aEvent) override; - void onFillSwatch( wxCommandEvent& aEvent ); - -private: - SYMBOL_EDIT_FRAME* m_frame; - LIB_SHAPE* m_shape; - UNIT_BINDER m_borderWidth; -}; - -#endif // DIALOG_LIB_SHAPE_PROPERTIES_H diff --git a/eeschema/dialogs/dialog_lib_shape_properties_base.cpp b/eeschema/dialogs/dialog_lib_shape_properties_base.cpp deleted file mode 100644 index 8c22267ce6..0000000000 --- a/eeschema/dialogs/dialog_lib_shape_properties_base.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "widgets/color_swatch.h" -#include "widgets/wx_infobar.h" - -#include "dialog_lib_shape_properties_base.h" - -/////////////////////////////////////////////////////////////////////////// - -BEGIN_EVENT_TABLE( DIALOG_LIB_SHAPE_PROPERTIES_BASE, DIALOG_SHIM ) - EVT_CHECKBOX( wxID_ANY, DIALOG_LIB_SHAPE_PROPERTIES_BASE::_wxFB_onBorderChecked ) - EVT_RADIOBUTTON( NO_FILL, DIALOG_LIB_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) - EVT_RADIOBUTTON( FILLED_SHAPE, DIALOG_LIB_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) - EVT_RADIOBUTTON( FILLED_WITH_BG_BODYCOLOR, DIALOG_LIB_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) - EVT_RADIOBUTTON( FILLED_WITH_COLOR, DIALOG_LIB_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) -END_EVENT_TABLE() - -DIALOG_LIB_SHAPE_PROPERTIES_BASE::DIALOG_LIB_SHAPE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* mainSizer; - mainSizer = new wxBoxSizer( wxVERTICAL ); - - m_infoBar = new WX_INFOBAR( this ); - m_infoBar->SetShowHideEffects( wxSHOW_EFFECT_NONE, wxSHOW_EFFECT_NONE ); - m_infoBar->SetEffectDuration( 500 ); - m_infoBar->Hide(); - - mainSizer->Add( m_infoBar, 0, wxEXPAND, 5 ); - - wxBoxSizer* bTop; - bTop = new wxBoxSizer( wxHORIZONTAL ); - - wxBoxSizer* bLeftCol; - bLeftCol = new wxBoxSizer( wxVERTICAL ); - - wxGridBagSizer* gbSizer2; - gbSizer2 = new wxGridBagSizer( 3, 0 ); - gbSizer2->SetFlexibleDirection( wxBOTH ); - gbSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_checkBorder = new wxCheckBox( this, wxID_ANY, _("Border"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer2->Add( m_checkBorder, wxGBPosition( 0, 0 ), wxGBSpan( 1, 2 ), wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_borderWidthLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_borderWidthLabel->Wrap( -1 ); - gbSizer2->Add( m_borderWidthLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); - - wxBoxSizer* bSizer7; - bSizer7 = new wxBoxSizer( wxHORIZONTAL ); - - m_borderWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer7->Add( m_borderWidthCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_borderWidthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_borderWidthUnits->Wrap( -1 ); - bSizer7->Add( m_borderWidthUnits, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 3 ); - - m_borderColorLabel = new wxStaticText( this, wxID_ANY, _("Color:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_borderColorLabel->Wrap( -1 ); - bSizer7->Add( m_borderColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 15 ); - - - bSizer7->Add( 5, 0, 0, 0, 5 ); - - m_panelBorderColor = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer22; - bSizer22 = new wxBoxSizer( wxVERTICAL ); - - m_borderColorSwatch = new COLOR_SWATCH( m_panelBorderColor, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer22->Add( m_borderColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - - m_panelBorderColor->SetSizer( bSizer22 ); - m_panelBorderColor->Layout(); - bSizer22->Fit( m_panelBorderColor ); - bSizer7->Add( m_panelBorderColor, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - - gbSizer2->Add( bSizer7, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); - - m_borderStyleLabel = new wxStaticText( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_borderStyleLabel->Wrap( -1 ); - gbSizer2->Add( m_borderStyleLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_borderStyleCombo = new wxBitmapComboBox( this, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); - m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) ); - - gbSizer2->Add( m_borderStyleCombo, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); - - m_helpLabel = new wxStaticText( this, wxID_ANY, _("Set border width to 0 to use schematic's default symbol line width."), wxDefaultPosition, wxDefaultSize, 0 ); - m_helpLabel->Wrap( 320 ); - gbSizer2->Add( m_helpLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 2 ), wxTOP|wxRIGHT|wxLEFT, 5 ); - - - bLeftCol->Add( gbSizer2, 1, wxEXPAND, 5 ); - - - bTop->Add( bLeftCol, 1, wxEXPAND|wxRIGHT, 30 ); - - wxBoxSizer* bRightCol; - bRightCol = new wxBoxSizer( wxVERTICAL ); - - wxStaticBoxSizer* bSizerFill; - bSizerFill = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fill Style") ), wxVERTICAL ); - - wxGridBagSizer* gbSizer1; - gbSizer1 = new wxGridBagSizer( 3, 0 ); - gbSizer1->SetFlexibleDirection( wxBOTH ); - gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_rbFillNone = new wxRadioButton( bSizerFill->GetStaticBox(), NO_FILL, _("Do not fill"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); - gbSizer1->Add( m_rbFillNone, wxGBPosition( 0, 0 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL, 5 ); - - m_rbFillOutline = new wxRadioButton( bSizerFill->GetStaticBox(), FILLED_SHAPE, _("Fill with body outline color"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_rbFillOutline, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL, 5 ); - - m_rbFillBackground = new wxRadioButton( bSizerFill->GetStaticBox(), FILLED_WITH_BG_BODYCOLOR, _("Fill with body background color"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_rbFillBackground, wxGBPosition( 2, 0 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL, 5 ); - - m_rbFillCustom = new wxRadioButton( bSizerFill->GetStaticBox(), FILLED_WITH_COLOR, _("Fill with:"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_rbFillCustom, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - - m_fillColorSwatch = new COLOR_SWATCH( bSizerFill->GetStaticBox(), FILLED_WITH_COLOR, wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_fillColorSwatch, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - - bSizerFill->Add( gbSizer1, 1, wxEXPAND|wxBOTTOM, 5 ); - - - bRightCol->Add( bSizerFill, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - - - bTop->Add( bRightCol, 1, wxEXPAND|wxLEFT, 30 ); - - - mainSizer->Add( bTop, 1, wxALL|wxEXPAND, 10 ); - - wxGridSizer* bBottom; - bBottom = new wxGridSizer( 0, 2, 0, 60 ); - - m_privateCheckbox = new wxCheckBox( this, wxID_ANY, _("Private to Symbol Editor"), wxDefaultPosition, wxDefaultSize, 0 ); - bBottom->Add( m_privateCheckbox, 0, wxALL, 5 ); - - m_checkApplyToAllUnits = new wxCheckBox( this, wxID_ANY, _("Common to all &units in symbol"), wxDefaultPosition, wxDefaultSize, 0 ); - bBottom->Add( m_checkApplyToAllUnits, 0, wxALL, 5 ); - - - bBottom->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_checkApplyToAllBodyStyles = new wxCheckBox( this, wxID_ANY, _("Common to all body &styles (De Morgan)"), wxDefaultPosition, wxDefaultSize, 0 ); - bBottom->Add( m_checkApplyToAllBodyStyles, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - - mainSizer->Add( bBottom, 0, wxEXPAND|wxALL, 10 ); - - m_sdbSizer = new wxStdDialogButtonSizer(); - m_sdbSizerOK = new wxButton( this, wxID_OK ); - m_sdbSizer->AddButton( m_sdbSizerOK ); - m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer->AddButton( m_sdbSizerCancel ); - m_sdbSizer->Realize(); - - mainSizer->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 5 ); - - - this->SetSizer( mainSizer ); - this->Layout(); - mainSizer->Fit( this ); - - this->Centre( wxBOTH ); -} - -DIALOG_LIB_SHAPE_PROPERTIES_BASE::~DIALOG_LIB_SHAPE_PROPERTIES_BASE() -{ -} diff --git a/eeschema/dialogs/dialog_lib_shape_properties_base.fbp b/eeschema/dialogs/dialog_lib_shape_properties_base.fbp deleted file mode 100644 index 6d7943549a..0000000000 --- a/eeschema/dialogs/dialog_lib_shape_properties_base.fbp +++ /dev/null @@ -1,1462 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - table - dialog_lib_shape_properties_base - 1000 - none - - - 1 - dialog_lib_shape_properties - - . - - 1 - 1 - 1 - 1 - UI - 0 - 1 - 0 - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 0 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_LIB_SHAPE_PROPERTIES_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - %s Properties - - 0 - - - - - - mainSizer - wxVERTICAL - none - - 5 - wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 500 - 1 - - 1 - - 0 - 1 - wxSHOW_EFFECT_NONE - wxID_ANY - - 0 - - - 0 - - 1 - m_infoBar - 1 - - - protected - 1 - - Resizable - 1 - wxSHOW_EFFECT_NONE - - WX_INFOBAR; widgets/wx_infobar.h; forward_declare - 0 - - - - - - - - 10 - wxALL|wxEXPAND - 1 - - - bTop - wxHORIZONTAL - none - - 30 - wxEXPAND|wxRIGHT - 1 - - - bLeftCol - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - - wxBOTH - - - 0 - - gbSizer2 - wxFLEX_GROWMODE_SPECIFIED - none - 3 - - 5 - 2 - 0 - wxTOP|wxRIGHT|wxLEFT - 0 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Border - - 0 - - - 0 - - 1 - m_checkBorder - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onBorderChecked - - - - 5 - 1 - 0 - wxALL - 1 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Width: - 0 - - 0 - - - 0 - - 1 - m_borderWidthLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - 1 - 1 - wxEXPAND - 1 - 1 - - - bSizer7 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - -1,-1 - 0 - -1,-1 - 1 - m_borderWidthCtrl - 1 - - - protected - 1 - - Resizable - 1 - -1,-1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 3 - wxLEFT|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - -1,-1 - 1 - m_borderWidthUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 15 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Color: - 0 - - 0 - - - 0 - - 1 - m_borderColorLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; Not forward_declare - 0 - - - - - -1 - - - - 5 - - 0 - - 0 - protected - 5 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelBorderColor - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - - - - wxBORDER_SIMPLE|wxTAB_TRAVERSAL - - - bSizer22 - wxVERTICAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - COLOR_SWATCH - 1 - - - 1 - - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_borderColorSwatch - 1 - - - protected - 1 - - Resizable - - 1 - - COLOR_SWATCH; widgets/color_swatch.h; forward_declare - 0 - - - - - - - - - - - - - 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT - 2 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Style: - 0 - - 0 - - - 0 - - 1 - m_borderStyleLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - 1 - 1 - wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL - 2 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - 240,-1 - 1 - m_borderStyleCombo - 1 - - - protected - 1 - - Resizable - -1 - 1 - - wxCB_READONLY - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - Combo! - - - - - - - 5 - 2 - 0 - wxTOP|wxRIGHT|wxLEFT - 3 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Set border width to 0 to use schematic's default symbol line width. - 0 - - 0 - - - 0 - - 1 - m_helpLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - 320 - - - - - - - - 30 - wxEXPAND|wxLEFT - 1 - - - bRightCol - wxVERTICAL - none - - 5 - wxEXPAND|wxTOP|wxBOTTOM - 0 - - wxID_ANY - Fill Style - - bSizerFill - wxVERTICAL - 1 - none - - 5 - wxEXPAND|wxBOTTOM - 1 - - - wxBOTH - - - 0 - - gbSizer1 - wxFLEX_GROWMODE_SPECIFIED - none - 3 - - 5 - 2 - 0 - wxALIGN_CENTER_VERTICAL - 0 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - NO_FILL - Do not fill - - 0 - - - 0 - - 1 - m_rbFillNone - 1 - - - protected - 1 - - Resizable - 1 - - wxRB_GROUP - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - onFill - - - - 5 - 2 - 0 - wxALIGN_CENTER_VERTICAL - 1 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - FILLED_SHAPE - Fill with body outline color - - 0 - - - 0 - - 1 - m_rbFillOutline - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - onFill - - - - 5 - 2 - 0 - wxALIGN_CENTER_VERTICAL - 2 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - FILLED_WITH_BG_BODYCOLOR - Fill with body background color - - 0 - - - 0 - - 1 - m_rbFillBackground - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - onFill - - - - 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL - 3 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - FILLED_WITH_COLOR - Fill with: - - 0 - - - 0 - - 1 - m_rbFillCustom - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - onFill - - - - 5 - 1 - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 3 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - COLOR_SWATCH - 1 - - - 1 - - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - FILLED_WITH_COLOR - - - 0 - - - 0 - - 1 - m_fillColorSwatch - 1 - - - protected - 1 - - Resizable - - 1 - - COLOR_SWATCH; widgets/color_swatch.h; forward_declare - 0 - - - - - - - - - - - - - - - - 10 - wxEXPAND|wxALL - 0 - - 2 - 60 - - bBottom - none - 0 - 0 - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Private to Symbol Editor - - 0 - - - 0 - - 1 - m_privateCheckbox - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Common to all &units in symbol - - 0 - - - 0 - - 1 - m_checkApplyToAllUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Common to all body &styles (De Morgan) - - 0 - - - 0 - - 1 - m_checkApplyToAllBodyStyles - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - - - - - diff --git a/eeschema/dialogs/dialog_lib_shape_properties_base.h b/eeschema/dialogs/dialog_lib_shape_properties_base.h deleted file mode 100644 index 0b5f068b28..0000000000 --- a/eeschema/dialogs/dialog_lib_shape_properties_base.h +++ /dev/null @@ -1,94 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include -#include -class COLOR_SWATCH; -class WX_INFOBAR; - -#include "dialog_shim.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_LIB_SHAPE_PROPERTIES_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_LIB_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM -{ - DECLARE_EVENT_TABLE() - private: - - // Private event handlers - void _wxFB_onBorderChecked( wxCommandEvent& event ){ onBorderChecked( event ); } - void _wxFB_onFill( wxCommandEvent& event ){ onFill( event ); } - - - protected: - enum - { - NO_FILL = 1000, - FILLED_SHAPE, - FILLED_WITH_BG_BODYCOLOR, - FILLED_WITH_COLOR - }; - - WX_INFOBAR* m_infoBar; - wxCheckBox* m_checkBorder; - wxStaticText* m_borderWidthLabel; - wxTextCtrl* m_borderWidthCtrl; - wxStaticText* m_borderWidthUnits; - wxStaticText* m_borderColorLabel; - wxPanel* m_panelBorderColor; - COLOR_SWATCH* m_borderColorSwatch; - wxStaticText* m_borderStyleLabel; - wxBitmapComboBox* m_borderStyleCombo; - wxStaticText* m_helpLabel; - wxRadioButton* m_rbFillNone; - wxRadioButton* m_rbFillOutline; - wxRadioButton* m_rbFillBackground; - wxRadioButton* m_rbFillCustom; - COLOR_SWATCH* m_fillColorSwatch; - wxCheckBox* m_privateCheckbox; - wxCheckBox* m_checkApplyToAllUnits; - wxCheckBox* m_checkApplyToAllBodyStyles; - wxStdDialogButtonSizer* m_sdbSizer; - wxButton* m_sdbSizerOK; - wxButton* m_sdbSizerCancel; - - // Virtual event handlers, override them in your derived class - virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); } - virtual void onFill( wxCommandEvent& event ) { event.Skip(); } - - - public: - - DIALOG_LIB_SHAPE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("%s Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - - ~DIALOG_LIB_SHAPE_PROPERTIES_BASE(); - -}; - diff --git a/eeschema/dialogs/dialog_lib_textbox_properties.cpp b/eeschema/dialogs/dialog_lib_textbox_properties.cpp deleted file mode 100644 index 8345d8be8d..0000000000 --- a/eeschema/dialogs/dialog_lib_textbox_properties.cpp +++ /dev/null @@ -1,395 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2022 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 2 - * 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, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "symbol_editor_drawing_tools.h" -#include - -DIALOG_LIB_TEXTBOX_PROPERTIES::DIALOG_LIB_TEXTBOX_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, - LIB_TEXTBOX* aTextBox ) : - DIALOG_LIB_TEXTBOX_PROPERTIES_BASE( aParent ), - m_frame( aParent ), - m_currentText( aTextBox ), - m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ), - m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits ), - m_scintillaTricks( nullptr ), - m_helpWindow( nullptr ) -{ - COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings(); - COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); - - m_borderColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); - m_borderColorSwatch->SetSwatchBackground( schematicBackground ); - - for( const auto& [ lineStyle, lineStyleDesc ] : lineTypeNames ) - m_borderStyleCombo->Append( lineStyleDesc.name, KiBitmapBundle( lineStyleDesc.bitmap ) ); - - m_borderStyleCombo->Append( DEFAULT_STYLE ); - - m_fillColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); - m_fillColorSwatch->SetSwatchBackground( schematicBackground ); - - m_textCtrl->SetEOLMode( wxSTC_EOL_LF ); - -#ifdef _WIN32 - // Without this setting, on Windows, some esoteric unicode chars create display issue - // in a wxStyledTextCtrl. - // for SetTechnology() info, see https://www.scintilla.org/ScintillaDoc.html#SCI_SETTECHNOLOGY - m_textCtrl->SetTechnology(wxSTC_TECHNOLOGY_DIRECTWRITE); -#endif - - m_scintillaTricks = new SCINTILLA_TRICKS( m_textCtrl, wxT( "{}" ), false, - // onAcceptFn - [this]( wxKeyEvent& aEvent ) - { - wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); - } ); - - m_textEntrySizer->AddGrowableRow( 0 ); - - m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); - m_textColorSwatch->SetSwatchBackground( schematicBackground ); - - SetInitialFocus( m_textCtrl ); - - m_separator1->SetIsSeparator(); - - m_bold->SetIsCheckButton(); - m_bold->SetBitmap( KiBitmapBundle( BITMAPS::text_bold ) ); - m_italic->SetIsCheckButton(); - m_italic->SetBitmap( KiBitmapBundle( BITMAPS::text_italic ) ); - - m_separator2->SetIsSeparator(); - - m_hAlignLeft->SetIsRadioButton(); - m_hAlignLeft->SetBitmap( KiBitmapBundle( BITMAPS::text_align_left ) ); - m_hAlignCenter->SetIsRadioButton(); - m_hAlignCenter->SetBitmap( KiBitmapBundle( BITMAPS::text_align_center ) ); - m_hAlignRight->SetIsRadioButton(); - m_hAlignRight->SetBitmap( KiBitmapBundle( BITMAPS::text_align_right ) ); - m_separator3->SetIsSeparator(); - - m_vAlignTop->SetIsRadioButton(); - m_vAlignTop->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_top ) ); - m_vAlignCenter->SetIsRadioButton(); - m_vAlignCenter->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_center ) ); - m_vAlignBottom->SetIsRadioButton(); - m_vAlignBottom->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_bottom ) ); - - m_separator4->SetIsSeparator(); - - m_horizontal->SetIsRadioButton(); - m_horizontal->SetBitmap( KiBitmapBundle( BITMAPS::text_horizontal ) ); - m_vertical->SetIsRadioButton(); - m_vertical->SetBitmap( KiBitmapBundle( BITMAPS::text_vertical ) ); - - m_separator5->SetIsSeparator(); - - SetupStandardButtons(); - Layout(); - - m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onHAlignButton, this ); - m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onHAlignButton, this ); - m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onHAlignButton, this ); - m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onVAlignButton, this ); - m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onVAlignButton, this ); - m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onVAlignButton, this ); - m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onTextAngleButton, this ); - m_vertical->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onTextAngleButton, this ); - - // Now all widgets have the size fixed, call FinishDialogSettings - finishDialogSettings(); -} - - -DIALOG_LIB_TEXTBOX_PROPERTIES::~DIALOG_LIB_TEXTBOX_PROPERTIES() -{ - delete m_scintillaTricks; - - if( m_helpWindow ) - m_helpWindow->Destroy(); -} - - -bool DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow() -{ - if( !wxDialog::TransferDataToWindow() ) - return false; - - const SYMBOL* symbol = m_currentText->GetParentSymbol(); - - m_textCtrl->SetValue( m_currentText->GetText() ); - m_textCtrl->EmptyUndoBuffer(); - - m_fontCtrl->SetFontSelection( m_currentText->GetFont() ); - m_textSize.SetValue( m_currentText->GetTextWidth() ); - m_textColorSwatch->SetSwatchColor( m_currentText->GetTextColor(), false ); - - m_bold->Check( m_currentText->IsBold() ); - m_italic->Check( m_currentText->IsItalic() ); - - switch( m_currentText->GetHorizJustify() ) - { - case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check(); break; - case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check(); break; - case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check(); break; - case GR_TEXT_H_ALIGN_INDETERMINATE: break; - } - - switch( m_currentText->GetVertJustify() ) - { - case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check(); break; - case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check(); break; - case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check(); break; - case GR_TEXT_V_ALIGN_INDETERMINATE: break; - } - - if( m_currentText->GetTextAngle() == ANGLE_VERTICAL ) - m_vertical->Check(); - else - m_horizontal->Check(); - - if( m_currentText->GetWidth() >= 0 ) - { - m_borderCheckbox->SetValue( true ); - m_borderWidth.SetValue( m_currentText->GetWidth() ); - } - else - { - m_borderCheckbox->SetValue( false ); - - m_borderWidth.Enable( false ); - m_borderColorLabel->Enable( false ); - m_borderColorSwatch->Enable( false ); - m_borderStyleLabel->Enable( false ); - m_borderStyleCombo->Enable( false ); - } - - m_borderColorSwatch->SetSwatchColor( m_currentText->GetStroke().GetColor(), false ); - - int style = static_cast( m_currentText->GetStroke().GetLineStyle() ); - - if( style == -1 ) - m_borderStyleCombo->SetStringSelection( DEFAULT_STYLE ); - else if( style < (int) lineTypeNames.size() ) - m_borderStyleCombo->SetSelection( style ); - else - wxFAIL_MSG( "Line type not found in the type lookup map" ); - - m_filledCtrl->SetValue( m_currentText->IsFilled() ); - m_fillColorSwatch->SetSwatchColor( m_currentText->GetFillColor(), false ); - - m_fillColorLabel->Enable( m_currentText->IsFilled() ); - m_fillColorSwatch->Enable( m_currentText->IsFilled() ); - - m_privateCheckbox->SetValue( m_currentText->IsPrivate() ); - m_commonToAllUnits->SetValue( - symbol && symbol->GetUnitCount() > 1 && m_currentText->GetUnit() == 0 ); - m_commonToAllUnits->Enable( symbol && symbol->GetUnitCount() > 1 ); - m_commonToAllBodyStyles->SetValue( m_currentText->GetBodyStyle() == 0 ); - - return true; -} - - -void DIALOG_LIB_TEXTBOX_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent ) -{ - for( BITMAP_BUTTON* btn : { m_hAlignLeft, m_hAlignCenter, m_hAlignRight } ) - { - if( btn->IsChecked() && btn != aEvent.GetEventObject() ) - btn->Check( false ); - } -} - - -void DIALOG_LIB_TEXTBOX_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent ) -{ - for( BITMAP_BUTTON* btn : { m_vAlignTop, m_vAlignCenter, m_vAlignBottom } ) - { - if( btn->IsChecked() && btn != aEvent.GetEventObject() ) - btn->Check( false ); - } -} - - -void DIALOG_LIB_TEXTBOX_PROPERTIES::onTextAngleButton( wxCommandEvent& aEvent ) -{ - for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } ) - { - if( btn->IsChecked() && btn != aEvent.GetEventObject() ) - btn->Check( false ); - } -} - - -bool DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow() -{ - if( !wxDialog::TransferDataFromWindow() ) - return false; - - wxString text = m_textCtrl->GetValue(); - -#ifdef __WXMAC__ - // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting - text.Replace( wxS( "\r" ), wxS( "\n" ) ); -#elif defined( __WINDOWS__ ) - // On Windows, a new line is coded as \r\n. We use only \n in kicad files and in - // drawing routines so strip the \r char. - text.Replace( wxS( "\r" ), wxS( "" ) ); -#endif - - m_currentText->SetText( text ); - - if( m_currentText->GetTextWidth() != m_textSize.GetValue() ) - m_currentText->SetTextSize( VECTOR2I( m_textSize.GetValue(), m_textSize.GetValue() ) ); - - if( m_fontCtrl->HaveFontSelection() ) - { - m_currentText->SetFont( m_fontCtrl->GetFontSelection( m_bold->IsChecked(), - m_italic->IsChecked() ) ); - } - - // Must come after SetTextSize() - m_currentText->SetBold( m_italic->IsChecked() ); - m_currentText->SetItalic( m_italic->IsChecked() ); - - m_currentText->SetTextColor( m_textColorSwatch->GetSwatchColor() ); - - if( m_hAlignRight->IsChecked() ) - m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - else if( m_hAlignCenter->IsChecked() ) - m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); - else - m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - - if( m_vAlignBottom->IsChecked() ) - m_currentText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - else if( m_vAlignCenter->IsChecked() ) - m_currentText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); - else - m_currentText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - - if( m_vertical->IsChecked() ) - m_currentText->SetTextAngle( ANGLE_VERTICAL ); - else - m_currentText->SetTextAngle( ANGLE_HORIZONTAL ); - - STROKE_PARAMS stroke = m_currentText->GetStroke(); - - if( m_borderCheckbox->GetValue() ) - stroke.SetWidth( std::max( (long long int) 0, m_borderWidth.GetValue() ) ); - else - stroke.SetWidth( -1 ); - - auto it = lineTypeNames.begin(); - std::advance( it, m_borderStyleCombo->GetSelection() ); - - if( it == lineTypeNames.end() ) - stroke.SetLineStyle( LINE_STYLE::DEFAULT ); - else - stroke.SetLineStyle( it->first ); - - stroke.SetColor( m_borderColorSwatch->GetSwatchColor() ); - - m_currentText->SetStroke( stroke ); - - m_currentText->SetFillMode( m_filledCtrl->GetValue() ? FILL_T::FILLED_WITH_COLOR - : FILL_T::NO_FILL ); - m_currentText->SetFillColor( m_fillColorSwatch->GetSwatchColor() ); - - m_currentText->SetPrivate( m_privateCheckbox->GetValue() ); - - if( !m_commonToAllUnits->GetValue() ) - m_currentText->SetUnit( m_frame->GetUnit() ); - else - m_currentText->SetUnit( 0 ); - - if( !m_commonToAllBodyStyles->GetValue() ) - m_currentText->SetBodyStyle( m_frame->GetBodyStyle() ); - else - m_currentText->SetBodyStyle( 0 ); - - // Record settings used for next time: - auto* tools = m_frame->GetToolManager()->GetTool(); - tools->SetLastTextAngle( m_currentText->GetTextAngle() ); - tools->SetDrawSpecificBodyStyle( !m_commonToAllBodyStyles->GetValue() ); - tools->SetDrawSpecificUnit( !m_commonToAllUnits->GetValue() ); - - m_frame->SetMsgPanel( m_currentText ); - - return true; -} - - -void DIALOG_LIB_TEXTBOX_PROPERTIES::OnFormattingHelp( wxHyperlinkEvent& aEvent ) -{ - m_helpWindow = SCH_TEXT::ShowSyntaxHelp( this ); -} - - -void DIALOG_LIB_TEXTBOX_PROPERTIES::onMultiLineTCLostFocus( wxFocusEvent& event ) -{ - if( m_scintillaTricks ) - m_scintillaTricks->CancelAutocomplete(); - - event.Skip(); -} - - -void DIALOG_LIB_TEXTBOX_PROPERTIES::onBorderChecked( wxCommandEvent& event ) -{ - bool border = m_borderCheckbox->GetValue(); - - if( border && m_borderWidth.GetValue() < 0 ) - m_borderWidth.SetValue( schIUScale.MilsToIU( m_frame->libeditconfig()->m_Defaults.line_width ) ); - - m_borderWidth.Enable( border ); - m_borderColorLabel->Enable( border ); - m_borderColorSwatch->Enable( border ); - m_borderStyleLabel->Enable( border ); - m_borderStyleCombo->Enable( border ); -} - - -void DIALOG_LIB_TEXTBOX_PROPERTIES::onFillChecked( wxCommandEvent& event ) -{ - bool fill = m_filledCtrl->GetValue(); - - m_fillColorLabel->Enable( fill ); - m_fillColorSwatch->Enable( fill ); -} - - diff --git a/eeschema/dialogs/dialog_lib_textbox_properties.h b/eeschema/dialogs/dialog_lib_textbox_properties.h deleted file mode 100644 index 4328f26ffc..0000000000 --- a/eeschema/dialogs/dialog_lib_textbox_properties.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2022 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 2 - * 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, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef DIALOG_LIB_TEXTBOX_PROPERTIES_H -#define DIALOG_LIB_TEXTBOX_PROPERTIES_H - -#include -#include -#include "dialog_lib_textbox_properties_base.h" - - -class SYMBOL_EDIT_FRAME; -class LIB_TEXTBOX; -class SCINTILLA_TRICKS; -class HTML_MESSAGE_BOX; - - -class DIALOG_LIB_TEXTBOX_PROPERTIES : public DIALOG_LIB_TEXTBOX_PROPERTIES_BASE -{ -public: - DIALOG_LIB_TEXTBOX_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_TEXTBOX* aTextBox ); - ~DIALOG_LIB_TEXTBOX_PROPERTIES(); - -private: - void onHAlignButton( wxCommandEvent &aEvent ); - void onVAlignButton( wxCommandEvent &aEvent ); - void onTextAngleButton( wxCommandEvent &aEvent ); - void onBorderChecked( wxCommandEvent& event ) override; - void onFillChecked( wxCommandEvent& event ) override; - - void OnFormattingHelp( wxHyperlinkEvent& aEvent ) override; - void onMultiLineTCLostFocus( wxFocusEvent& event ) override; - - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; - - SYMBOL_EDIT_FRAME* m_frame; - LIB_TEXTBOX* m_currentText; - UNIT_BINDER m_textSize; - UNIT_BINDER m_borderWidth; - SCINTILLA_TRICKS* m_scintillaTricks; - - HTML_MESSAGE_BOX* m_helpWindow; -}; - - - -#endif // DIALOG_LIB_TEXTBOX_PROPERTIES_H diff --git a/eeschema/dialogs/dialog_lib_textbox_properties_base.cpp b/eeschema/dialogs/dialog_lib_textbox_properties_base.cpp deleted file mode 100644 index 419f2a3581..0000000000 --- a/eeschema/dialogs/dialog_lib_textbox_properties_base.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "widgets/bitmap_button.h" -#include "widgets/color_swatch.h" -#include "widgets/font_choice.h" - -#include "dialog_lib_textbox_properties_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::DIALOG_LIB_TEXTBOX_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* bMainSizer; - bMainSizer = new wxBoxSizer( wxVERTICAL ); - - m_textEntrySizer = new wxGridBagSizer( 3, 3 ); - m_textEntrySizer->SetFlexibleDirection( wxBOTH ); - m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_textLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_textLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), 0, 5 ); - - m_textCtrl = new wxStyledTextCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN, wxEmptyString ); - m_textCtrl->SetUseTabs( true ); - m_textCtrl->SetTabWidth( 4 ); - m_textCtrl->SetIndent( 4 ); - m_textCtrl->SetTabIndents( false ); - m_textCtrl->SetBackSpaceUnIndents( false ); - m_textCtrl->SetViewEOL( false ); - m_textCtrl->SetViewWhiteSpace( false ); - m_textCtrl->SetMarginWidth( 2, 0 ); - m_textCtrl->SetIndentationGuides( false ); - m_textCtrl->SetReadOnly( false ); - m_textCtrl->SetMarginWidth( 1, 0 ); - m_textCtrl->SetMarginWidth( 0, 0 ); - m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS ); - m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("BLACK") ) ); - m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("WHITE") ) ); - m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS ); - m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("BLACK") ) ); - m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("WHITE") ) ); - m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY ); - m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUS ); - m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("BLACK") ) ); - m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("WHITE") ) ); - m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUS ); - m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("BLACK") ) ); - m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("WHITE") ) ); - m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY ); - m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY ); - m_textCtrl->SetSelBackground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); - m_textCtrl->SetSelForeground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) ); - m_textCtrl->SetMinSize( wxSize( 500,140 ) ); - - m_textEntrySizer->Add( m_textCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 5 ), wxEXPAND, 5 ); - - m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_fontLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_fontLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxTOP, 5 ); - - wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") }; - int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString ); - m_fontCtrl = new FONT_CHOICE( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fontCtrlNChoices, m_fontCtrlChoices, 0 ); - m_fontCtrl->SetSelection( 0 ); - m_textEntrySizer->Add( m_fontCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP, 5 ); - - wxBoxSizer* bSizeCtrlSizer; - bSizeCtrlSizer = new wxBoxSizer( wxHORIZONTAL ); - - m_separator1 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_separator1->Enable( false ); - - bSizeCtrlSizer->Add( m_separator1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - m_bold = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_bold->SetToolTip( _("Bold") ); - - bSizeCtrlSizer->Add( m_bold, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_italic = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_italic->SetToolTip( _("Italic") ); - - bSizeCtrlSizer->Add( m_italic, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_separator2 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_separator2->Enable( false ); - - bSizeCtrlSizer->Add( m_separator2, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_hAlignLeft = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_hAlignLeft->SetToolTip( _("Align left") ); - - bSizeCtrlSizer->Add( m_hAlignLeft, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_hAlignCenter = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_hAlignCenter->SetToolTip( _("Align horizontal center") ); - - bSizeCtrlSizer->Add( m_hAlignCenter, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_hAlignRight = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_hAlignRight->SetToolTip( _("Align right") ); - - bSizeCtrlSizer->Add( m_hAlignRight, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_separator3 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_separator3->Enable( false ); - - bSizeCtrlSizer->Add( m_separator3, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_vAlignTop = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_vAlignTop->SetToolTip( _("Align top") ); - - bSizeCtrlSizer->Add( m_vAlignTop, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_vAlignCenter = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_vAlignCenter->SetToolTip( _("Align top") ); - - bSizeCtrlSizer->Add( m_vAlignCenter, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_vAlignBottom = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_vAlignBottom->SetToolTip( _("Align top") ); - - bSizeCtrlSizer->Add( m_vAlignBottom, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_separator4 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_separator4->Enable( false ); - - bSizeCtrlSizer->Add( m_separator4, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_horizontal = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_horizontal->SetToolTip( _("Align bottom") ); - - bSizeCtrlSizer->Add( m_horizontal, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_vertical = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_vertical->SetToolTip( _("Align vertical center") ); - - bSizeCtrlSizer->Add( m_vertical, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_separator5 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_separator5->Enable( false ); - - bSizeCtrlSizer->Add( m_separator5, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - m_textEntrySizer->Add( bSizeCtrlSizer, wxGBPosition( 2, 3 ), wxGBSpan( 1, 3 ), wxEXPAND|wxTOP, 5 ); - - wxBoxSizer* bSizer41; - bSizer41 = new wxBoxSizer( wxVERTICAL ); - - m_syntaxHelp = new wxHyperlinkCtrl( this, wxID_ANY, _("Syntax help"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); - m_syntaxHelp->SetToolTip( _("Show syntax help window") ); - - bSizer41->Add( m_syntaxHelp, 0, wxRIGHT|wxLEFT, 5 ); - - - m_textEntrySizer->Add( bSizer41, wxGBPosition( 1, 5 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALIGN_RIGHT|wxBOTTOM|wxLEFT, 5 ); - - m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textSizeLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_textSizeLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - - wxBoxSizer* bSizer71; - bSizer71 = new wxBoxSizer( wxHORIZONTAL ); - - m_textSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer71->Add( m_textSizeCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textSizeUnits->Wrap( -1 ); - bSizer71->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 3 ); - - m_textColorLabel = new wxStaticText( this, wxID_ANY, _("Color:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textColorLabel->Wrap( -1 ); - bSizer71->Add( m_textColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 15 ); - - - bSizer71->Add( 5, 0, 0, 0, 5 ); - - m_panelBorderColor1 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer221; - bSizer221 = new wxBoxSizer( wxVERTICAL ); - - m_textColorSwatch = new COLOR_SWATCH( m_panelBorderColor1, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer221->Add( m_textColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - - m_panelBorderColor1->SetSizer( bSizer221 ); - m_panelBorderColor1->Layout(); - bSizer221->Fit( m_panelBorderColor1 ); - bSizer71->Add( m_panelBorderColor1, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - m_textEntrySizer->Add( bSizer71, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); - - - m_textEntrySizer->Add( 0, 15, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); - - m_borderCheckbox = new wxCheckBox( this, wxID_ANY, _("Border"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textEntrySizer->Add( m_borderCheckbox, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), 0, 5 ); - - m_borderWidthLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_borderWidthLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - - wxBoxSizer* bSizer7; - bSizer7 = new wxBoxSizer( wxHORIZONTAL ); - - m_borderWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer7->Add( m_borderWidthCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_borderWidthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_borderWidthUnits->Wrap( -1 ); - bSizer7->Add( m_borderWidthUnits, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 3 ); - - m_borderColorLabel = new wxStaticText( this, wxID_ANY, _("Color:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_borderColorLabel->Wrap( -1 ); - bSizer7->Add( m_borderColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 15 ); - - - bSizer7->Add( 5, 0, 0, 0, 5 ); - - m_panelBorderColor = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer22; - bSizer22 = new wxBoxSizer( wxVERTICAL ); - - m_borderColorSwatch = new COLOR_SWATCH( m_panelBorderColor, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer22->Add( m_borderColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - - m_panelBorderColor->SetSizer( bSizer22 ); - m_panelBorderColor->Layout(); - bSizer22->Fit( m_panelBorderColor ); - bSizer7->Add( m_panelBorderColor, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - m_textEntrySizer->Add( bSizer7, wxGBPosition( 6, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); - - m_borderStyleLabel = new wxStaticText( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_borderStyleLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 7, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - - m_borderStyleCombo = new wxBitmapComboBox( this, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); - m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) ); - - m_textEntrySizer->Add( m_borderStyleCombo, wxGBPosition( 7, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - - - m_textEntrySizer->Add( 0, 15, wxGBPosition( 8, 0 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); - - m_filledCtrl = new wxCheckBox( this, wxID_ANY, _("Background fill"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textEntrySizer->Add( m_filledCtrl, wxGBPosition( 5, 4 ), wxGBSpan( 1, 2 ), wxRIGHT, 140 ); - - wxBoxSizer* bSizer8; - bSizer8 = new wxBoxSizer( wxHORIZONTAL ); - - m_fillColorLabel = new wxStaticText( this, wxID_ANY, _("Fill color:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_fillColorLabel->Wrap( -1 ); - bSizer8->Add( m_fillColorLabel, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); - - m_panelFillColor = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer211; - bSizer211 = new wxBoxSizer( wxVERTICAL ); - - m_fillColorSwatch = new COLOR_SWATCH( m_panelFillColor, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer211->Add( m_fillColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - - m_panelFillColor->SetSizer( bSizer211 ); - m_panelFillColor->Layout(); - bSizer211->Fit( m_panelFillColor ); - bSizer8->Add( m_panelFillColor, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - m_textEntrySizer->Add( bSizer8, wxGBPosition( 6, 4 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); - - m_privateCheckbox = new wxCheckBox( this, wxID_ANY, _("Private to symbol editor"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textEntrySizer->Add( m_privateCheckbox, wxGBPosition( 9, 0 ), wxGBSpan( 1, 2 ), 0, 5 ); - - m_commonToAllUnits = new wxCheckBox( this, wxID_ANY, _("Common to all units"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textEntrySizer->Add( m_commonToAllUnits, wxGBPosition( 9, 4 ), wxGBSpan( 1, 2 ), 0, 5 ); - - m_commonToAllBodyStyles = new wxCheckBox( this, wxID_ANY, _("Common to all body styles"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textEntrySizer->Add( m_commonToAllBodyStyles, wxGBPosition( 10, 4 ), wxGBSpan( 1, 2 ), wxRIGHT, 90 ); - - - m_textEntrySizer->AddGrowableCol( 3 ); - - bMainSizer->Add( m_textEntrySizer, 1, wxALL|wxEXPAND, 10 ); - - m_sdbSizer1 = new wxStdDialogButtonSizer(); - m_sdbSizer1OK = new wxButton( this, wxID_OK ); - m_sdbSizer1->AddButton( m_sdbSizer1OK ); - m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); - m_sdbSizer1->Realize(); - - bMainSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 ); - - - this->SetSizer( bMainSizer ); - this->Layout(); - bMainSizer->Fit( this ); - - // Connect Events - m_textCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); - m_syntaxHelp->Connect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); - m_borderCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::onBorderChecked ), NULL, this ); - m_filledCtrl->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::onFillChecked ), NULL, this ); -} - -DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::~DIALOG_LIB_TEXTBOX_PROPERTIES_BASE() -{ - // Disconnect Events - m_textCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); - m_syntaxHelp->Disconnect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); - m_borderCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::onBorderChecked ), NULL, this ); - m_filledCtrl->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::onFillChecked ), NULL, this ); - -} diff --git a/eeschema/dialogs/dialog_lib_textbox_properties_base.fbp b/eeschema/dialogs/dialog_lib_textbox_properties_base.fbp deleted file mode 100644 index 0ab013e569..0000000000 --- a/eeschema/dialogs/dialog_lib_textbox_properties_base.fbp +++ /dev/null @@ -1,3091 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_lib_textbox_properties_base - 1000 - none - - - 1 - dialog_lib_textbox_properties_base - - . - - 1 - 1 - 1 - 1 - UI - 0 - 1 - 0 - - 0 - wxAUI_MGR_DEFAULT - - - - 1 - 0 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_LIB_TEXTBOX_PROPERTIES_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Text Box Properties - - 0 - - - - - - bMainSizer - wxVERTICAL - none - - 10 - wxALL|wxEXPAND - 1 - - -1,-1 - wxBOTH - 3 - - 3 - - m_textEntrySizer - wxFLEX_GROWMODE_SPECIFIED - protected - 3 - - 5 - 1 - 0 - - 0 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Text: - 0 - - 0 - - - 0 - - 1 - m_textLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 5 - 5 - 1 - wxEXPAND - 0 - 1 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - 0 - - 0 - 0 - wxID_ANY - 0 - 0 - - 0 - - - 0 - 500,140 - 1 - m_textCtrl - 1 - - - protected - 1 - - 0 - Resizable - 1 - - ; forward_declare - 0 - 4 - 0 - - 1 - 0 - 0 - - - wxBORDER_SUNKEN - onMultiLineTCLostFocus - - - - 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL|wxTOP - 2 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Font: - 0 - - 0 - - - 0 - - 1 - m_fontLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - 2 - 1 - wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP - 2 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Default Font" "KiCad Font" - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_fontCtrl - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - FONT_CHOICE; widgets/font_choice.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - 3 - 3 - wxEXPAND|wxTOP - 2 - 1 - - - bSizeCtrlSizer - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 0 - - 1 - - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - - 0 - - 1 - m_separator1 - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Bold - - 0 - - 0 - - - 0 - - 1 - m_bold - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Bold - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Italic - - 0 - - 0 - - - 0 - - 1 - m_italic - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Italic - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 0 - - 1 - - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - - 0 - - 1 - m_separator2 - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align right - - 0 - - 0 - - - 0 - - 1 - m_hAlignLeft - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align left - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align bottom - - 0 - - 0 - - - 0 - - 1 - m_hAlignCenter - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align horizontal center - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align left - - 0 - - 0 - - - 0 - - 1 - m_hAlignRight - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align right - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 0 - - 1 - - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - - 0 - - 1 - m_separator3 - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align top - - 0 - - 0 - - - 0 - - 1 - m_vAlignTop - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align top - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align middle - - 0 - - 0 - - - 0 - - 1 - m_vAlignCenter - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align top - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align bottom - - 0 - - 0 - - - 0 - - 1 - m_vAlignBottom - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align top - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 0 - - 1 - - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - - 0 - - 1 - m_separator4 - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align top - - 0 - - 0 - - - 0 - - 1 - m_horizontal - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align bottom - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align middle - - 0 - - 0 - - - 0 - - 1 - m_vertical - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align vertical center - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 0 - - 1 - - - 0 - 0 - wxID_ANY - - - 0 - - 0 - - - 0 - - 1 - m_separator5 - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - 1 - 5 - wxEXPAND|wxALIGN_RIGHT|wxBOTTOM|wxLEFT - 1 - 1 - - - bSizer41 - wxVERTICAL - none - - 5 - wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - - wxID_ANY - Syntax help - - 0 - - - 0 - - 1 - m_syntaxHelp - - 1 - - - protected - 1 - - Resizable - 1 - - wxHL_DEFAULT_STYLE - ; ; forward_declare - 0 - Show syntax help window - - - - - - OnFormattingHelp - - - - - - 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL - 3 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Text size: - 0 - - 0 - - - 0 - - 1 - m_textSizeLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - 1 - 1 - wxEXPAND - 3 - 1 - - - bSizer71 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - -1,-1 - 0 - -1,-1 - 1 - m_textSizeCtrl - 1 - - - protected - 1 - - Resizable - 1 - -1,-1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - -1,-1 - 1 - m_textSizeUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 15 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Color: - 0 - - 0 - - - 0 - - 1 - m_textColorLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; Not forward_declare - 0 - - - - - -1 - - - - 5 - - 0 - - 0 - protected - 5 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelBorderColor1 - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - - - - wxBORDER_SIMPLE|wxTAB_TRAVERSAL - - - bSizer221 - wxVERTICAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - COLOR_SWATCH - 1 - - - 1 - - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_textColorSwatch - 1 - - - protected - 1 - - Resizable - - 1 - - COLOR_SWATCH; widgets/color_swatch.h; forward_declare - 0 - - - - - - - - - - - - - 5 - 1 - 0 - wxEXPAND - 4 - 1 - - 15 - protected - 0 - - - - 5 - 1 - 0 - - 5 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Border - - 0 - - - 0 - - 1 - m_borderCheckbox - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onBorderChecked - - - - 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL - 6 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Width: - 0 - - 0 - - - 0 - - 1 - m_borderWidthLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - 1 - 1 - wxEXPAND - 6 - 1 - - - bSizer7 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - -1,-1 - 0 - -1,-1 - 1 - m_borderWidthCtrl - 1 - - - protected - 1 - - Resizable - 1 - -1,-1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 3 - wxLEFT|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - -1,-1 - 1 - m_borderWidthUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 15 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Color: - 0 - - 0 - - - 0 - - 1 - m_borderColorLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; Not forward_declare - 0 - - - - - -1 - - - - 5 - - 0 - - 0 - protected - 5 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelBorderColor - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - - - - wxBORDER_SIMPLE|wxTAB_TRAVERSAL - - - bSizer22 - wxVERTICAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - COLOR_SWATCH - 1 - - - 1 - - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_borderColorSwatch - 1 - - - protected - 1 - - Resizable - - 1 - - COLOR_SWATCH; widgets/color_swatch.h; forward_declare - 0 - - - - - - - - - - - - - 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL - 7 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Style: - 0 - - 0 - - - 0 - - 1 - m_borderStyleLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - 2 - 1 - wxALIGN_CENTER_VERTICAL|wxEXPAND - 7 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - 240,-1 - 1 - m_borderStyleCombo - 1 - - - protected - 1 - - Resizable - -1 - 1 - - wxCB_READONLY - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - Combo! - - - - - - - 5 - 1 - 0 - wxEXPAND - 8 - 1 - - 15 - protected - 0 - - - - 140 - 2 - 4 - wxRIGHT - 5 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Background fill - - 0 - - - 0 - - 1 - m_filledCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onFillChecked - - - - 5 - 1 - 4 - wxEXPAND - 6 - 1 - - - bSizer8 - wxHORIZONTAL - none - - 5 - wxRIGHT|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Fill color: - 0 - - 0 - - - 0 - - 1 - m_fillColorLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelFillColor - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - - - - wxBORDER_SIMPLE|wxTAB_TRAVERSAL - - - bSizer211 - wxVERTICAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - COLOR_SWATCH - 1 - - - 1 - - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_fillColorSwatch - 1 - - - protected - 1 - - Resizable - - 1 - - COLOR_SWATCH; widgets/color_swatch.h; forward_declare - 0 - - - - - - - - - - - - - 5 - 2 - 0 - - 9 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Private to symbol editor - - 0 - - - 0 - - 1 - m_privateCheckbox - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - 2 - 4 - - 9 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Common to all units - - 0 - - - 0 - - 1 - m_commonToAllUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 90 - 2 - 4 - wxRIGHT - 10 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Common to all body styles - - 0 - - - 0 - - 1 - m_commonToAllBodyStyles - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer1 - protected - - - - - - diff --git a/eeschema/dialogs/dialog_lib_textbox_properties_base.h b/eeschema/dialogs/dialog_lib_textbox_properties_base.h deleted file mode 100644 index 7b5bbd3b47..0000000000 --- a/eeschema/dialogs/dialog_lib_textbox_properties_base.h +++ /dev/null @@ -1,111 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include -#include -class BITMAP_BUTTON; -class COLOR_SWATCH; -class FONT_CHOICE; - -#include "dialog_shim.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_LIB_TEXTBOX_PROPERTIES_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_LIB_TEXTBOX_PROPERTIES_BASE : public DIALOG_SHIM -{ - private: - - protected: - wxGridBagSizer* m_textEntrySizer; - wxStaticText* m_textLabel; - wxStyledTextCtrl* m_textCtrl; - wxStaticText* m_fontLabel; - FONT_CHOICE* m_fontCtrl; - BITMAP_BUTTON* m_separator1; - BITMAP_BUTTON* m_bold; - BITMAP_BUTTON* m_italic; - BITMAP_BUTTON* m_separator2; - BITMAP_BUTTON* m_hAlignLeft; - BITMAP_BUTTON* m_hAlignCenter; - BITMAP_BUTTON* m_hAlignRight; - BITMAP_BUTTON* m_separator3; - BITMAP_BUTTON* m_vAlignTop; - BITMAP_BUTTON* m_vAlignCenter; - BITMAP_BUTTON* m_vAlignBottom; - BITMAP_BUTTON* m_separator4; - BITMAP_BUTTON* m_horizontal; - BITMAP_BUTTON* m_vertical; - BITMAP_BUTTON* m_separator5; - wxHyperlinkCtrl* m_syntaxHelp; - wxStaticText* m_textSizeLabel; - wxTextCtrl* m_textSizeCtrl; - wxStaticText* m_textSizeUnits; - wxStaticText* m_textColorLabel; - wxPanel* m_panelBorderColor1; - COLOR_SWATCH* m_textColorSwatch; - wxCheckBox* m_borderCheckbox; - wxStaticText* m_borderWidthLabel; - wxTextCtrl* m_borderWidthCtrl; - wxStaticText* m_borderWidthUnits; - wxStaticText* m_borderColorLabel; - wxPanel* m_panelBorderColor; - COLOR_SWATCH* m_borderColorSwatch; - wxStaticText* m_borderStyleLabel; - wxBitmapComboBox* m_borderStyleCombo; - wxCheckBox* m_filledCtrl; - wxStaticText* m_fillColorLabel; - wxPanel* m_panelFillColor; - COLOR_SWATCH* m_fillColorSwatch; - wxCheckBox* m_privateCheckbox; - wxCheckBox* m_commonToAllUnits; - wxCheckBox* m_commonToAllBodyStyles; - wxStdDialogButtonSizer* m_sdbSizer1; - wxButton* m_sdbSizer1OK; - wxButton* m_sdbSizer1Cancel; - - // Virtual event handlers, override them in your derived class - virtual void onMultiLineTCLostFocus( wxFocusEvent& event ) { event.Skip(); } - virtual void OnFormattingHelp( wxHyperlinkEvent& event ) { event.Skip(); } - virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); } - virtual void onFillChecked( wxCommandEvent& event ) { event.Skip(); } - - - public: - - DIALOG_LIB_TEXTBOX_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Box Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - - ~DIALOG_LIB_TEXTBOX_PROPERTIES_BASE(); - -}; - diff --git a/eeschema/dialogs/dialog_shape_properties.cpp b/eeschema/dialogs/dialog_shape_properties.cpp index 83c430f3ec..be49786a1d 100644 --- a/eeschema/dialogs/dialog_shape_properties.cpp +++ b/eeschema/dialogs/dialog_shape_properties.cpp @@ -24,26 +24,36 @@ #include #include #include +#include #include #include #include +#include #include +#include -DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_SHAPE* aShape ) : +DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_SHAPE* aShape ) : DIALOG_SHAPE_PROPERTIES_BASE( aParent ), m_frame( aParent ), m_shape( aShape ), m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits, true ) { - SetTitle( wxString::Format( GetTitle(), aShape->EDA_SHAPE::GetFriendlyName() ) ); + SetTitle( wxString::Format( GetTitle(), aShape->GetFriendlyName() ) ); + + // DIALOG_SHIM needs a unique hash_key because classname is not sufficient because the + // different shapes (and even whether or not we're within the symbol editor) cause different + // dialog layouts). + m_hash_key = TO_UTF8( GetTitle() + aParent->GetName() ); m_helpLabel1->SetFont( KIUI::GetInfoFont( this ).Italic() ); m_helpLabel2->SetFont( KIUI::GetInfoFont( this ).Italic() ); - SetInitialFocus( m_borderWidthCtrl ); + COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings(); + COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); m_borderColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); + m_borderColorSwatch->SetSwatchBackground( schematicBackground ); for( const auto& [ lineStyle, lineStyleDesc ] : lineTypeNames ) m_borderStyleCombo->Append( lineStyleDesc.name, KiBitmapBundle( lineStyleDesc.bitmap ) ); @@ -51,6 +61,7 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_S m_borderStyleCombo->Append( DEFAULT_STYLE ); m_fillColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); + m_fillColorSwatch->SetSwatchBackground( schematicBackground ); KIGFX::COLOR4D canvas = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ); m_borderColorSwatch->SetSwatchBackground( canvas.ToColour() ); @@ -59,16 +70,49 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_S if( m_frame->GetColorSettings()->GetOverrideSchItemColors() ) m_infoBar->ShowMessage( _( "Note: individual item colors overridden in Preferences." ) ); + SetInitialFocus( m_borderWidthCtrl ); + // Required under wxGTK if we want to dismiss the dialog with the ESC key SetFocus(); SetupStandardButtons(); + if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast( m_frame ) ) + { + m_fillBook->SetSelection( 1 ); + + if( !symbolEditor->IsSymbolEditable() || symbolEditor->IsSymbolAlias() ) + { + m_sdbSizerCancel->SetDefault(); + m_sdbSizerOK->SetLabel( _( "Read Only" ) ); + m_sdbSizerOK->Enable( false ); + } + } + else + { + m_fillBook->SetSelection( 0 ); + m_symbolEditorSizer->Show( false ); + } + + m_borderColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onBorderSwatch, + this ); + m_customColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onCustomColorSwatch, + this ); + // Now all widgets have the size fixed, call FinishDialogSettings finishDialogSettings(); } +DIALOG_SHAPE_PROPERTIES::~DIALOG_SHAPE_PROPERTIES() +{ + m_borderColorSwatch->Unbind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onBorderSwatch, + this ); + m_customColorSwatch->Unbind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onCustomColorSwatch, + this ); +} + + bool DIALOG_SHAPE_PROPERTIES::TransferDataToWindow() { if( !wxDialog::TransferDataToWindow() ) @@ -101,8 +145,66 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataToWindow() else wxFAIL_MSG( "Line type not found in the type lookup map" ); - m_filledCtrl->SetValue( m_shape->IsFilled() ); - m_fillColorSwatch->SetSwatchColor( m_shape->GetFillColor(), false ); + if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast( m_frame ) ) + { + m_rbFillNone->Enable( true ); + m_rbFillOutline->Enable( true ); + m_rbFillBackground->Enable( true ); + m_rbFillCustom->Enable( true ); + m_customColorSwatch->Enable( true ); + + if( m_shape->GetFillMode() == FILL_T::FILLED_SHAPE ) + { + m_rbFillOutline->SetValue( true ); + + COLOR4D color = m_shape->GetStroke().GetColor(); + + if( color == COLOR4D::UNSPECIFIED ) + color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE ); + + m_customColorSwatch->SetSwatchColor( color, false ); + } + else if( m_shape->GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR ) + { + m_rbFillBackground->SetValue( true ); + + COLOR4D color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); + m_customColorSwatch->SetSwatchColor( color, false ); + } + else if( m_shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR ) + { + m_rbFillCustom->SetValue( true ); + m_customColorSwatch->SetSwatchColor( m_shape->GetFillColor(), false ); + } + else + { + m_rbFillNone->SetValue( true ); + m_customColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false ); + } + + const SYMBOL* symbol = m_shape->GetParentSymbol(); + + m_privateCheckbox->SetValue( m_shape->IsPrivate() ); + m_checkApplyToAllUnits->SetValue( symbol->GetUnitCount() > 1 && m_shape->GetUnit() == 0 ); + m_checkApplyToAllUnits->Enable( symbol->GetUnitCount() > 1 ); + m_checkApplyToAllBodyStyles->SetValue( m_shape->GetBodyStyle() == 0 ); + + bool enableAlternateBodyStyle = symbol->HasAlternateBodyStyle(); + + // If a symbol contains no body-style-specific pins or graphic items, + // symbol->HasAlternateBodyStyle() will return false. + // But when creating a new symbol, with DeMorgan option set, the m_checkApplyToAllBodyStyles + // must be enabled in order to be able to create graphic items shared by all body styles. + if( symbolEditor->GetShowDeMorgan() ) + enableAlternateBodyStyle = true; + + m_checkApplyToAllBodyStyles->Enable( enableAlternateBodyStyle ); + } + else + { + m_filledCtrl->SetValue( m_shape->IsFilled() ); + m_fillColorSwatch->SetSwatchColor( m_shape->GetFillColor(), false ); + } return true; } @@ -113,7 +215,16 @@ void DIALOG_SHAPE_PROPERTIES::onBorderChecked( wxCommandEvent& event ) bool border = m_borderCheckbox->GetValue(); if( border && m_borderWidth.GetValue() < 0 ) - m_borderWidth.SetValue( schIUScale.MilsToIU( m_frame->eeconfig()->m_Drawing.default_line_thickness ) ); + { + int defaultInMils; + + if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast( m_frame ) ) + defaultInMils = symbolEditor->libeditconfig()->m_Defaults.line_width; + else + defaultInMils = m_frame->eeconfig()->m_Drawing.default_line_thickness; + + m_borderWidth.SetValue( schIUScale.MilsToIU( defaultInMils ) ); + } m_borderWidth.Enable( border ); m_borderColorLabel->Enable( border ); @@ -132,6 +243,52 @@ void DIALOG_SHAPE_PROPERTIES::onFillChecked( wxCommandEvent& aEvent ) } +void DIALOG_SHAPE_PROPERTIES::onFillRadioButton( wxCommandEvent& event ) +{ + if( event.GetId() == NO_FILL ) + { + m_rbFillNone->SetValue( true ); + m_fillColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false ); + } + else if( event.GetId() == FILLED_SHAPE ) + { + m_rbFillOutline->SetValue( true ); + + COLOR4D color = m_shape->GetStroke().GetColor(); + + if( color == COLOR4D::UNSPECIFIED ) + color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE ); + + m_fillColorSwatch->SetSwatchColor( color, false ); + } + else if( event.GetId() == FILLED_WITH_BG_BODYCOLOR ) + { + m_rbFillBackground->SetValue( true ); + + COLOR4D color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); + m_fillColorSwatch->SetSwatchColor( color, false ); + } + else if( event.GetId() == FILLED_WITH_COLOR ) + { + m_rbFillCustom->SetValue( true ); + m_fillColorSwatch->GetNewSwatchColor(); + } +} + + +void DIALOG_SHAPE_PROPERTIES::onBorderSwatch( wxCommandEvent& aEvent ) +{ + if( m_rbFillOutline->GetValue() ) + m_fillColorSwatch->SetSwatchColor( m_borderColorSwatch->GetSwatchColor(), false ); +} + + +void DIALOG_SHAPE_PROPERTIES::onCustomColorSwatch( wxCommandEvent& aEvent ) +{ + m_rbFillCustom->SetValue( true ); +} + + bool DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow() { if( !wxDialog::TransferDataFromWindow() ) @@ -145,9 +302,14 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow() STROKE_PARAMS stroke = m_shape->GetStroke(); if( m_borderCheckbox->GetValue() ) - stroke.SetWidth( std::max( 0, m_borderWidth.GetIntValue() ) ); + { + if( !m_borderWidth.IsIndeterminate() ) + stroke.SetWidth( std::max( 0, m_borderWidth.GetIntValue() ) ); + } else + { stroke.SetWidth( -1 ); + } auto it = lineTypeNames.begin(); std::advance( it, m_borderStyleCombo->GetSelection() ); @@ -161,13 +323,43 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow() m_shape->SetStroke( stroke ); - m_shape->SetFillMode( m_filledCtrl->GetValue() ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL ); - m_shape->SetFillColor( m_fillColorSwatch->GetSwatchColor() ); + if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast( m_frame ) ) + { + if( m_rbFillOutline->GetValue() ) + m_shape->SetFillMode( FILL_T::FILLED_SHAPE ); + else if( m_rbFillBackground->GetValue() ) + m_shape->SetFillMode( FILL_T::FILLED_WITH_BG_BODYCOLOR ); + else if( m_rbFillCustom->GetValue() ) + m_shape->SetFillMode( FILL_T::FILLED_WITH_COLOR ); + else + m_shape->SetFillMode( FILL_T::NO_FILL ); + + m_shape->SetFillColor( m_customColorSwatch->GetSwatchColor() ); + + m_shape->SetPrivate( m_privateCheckbox->GetValue() ); + + if( m_checkApplyToAllBodyStyles->IsChecked() ) + m_shape->SetBodyStyle( 0 ); + else + m_shape->SetBodyStyle( symbolEditor->GetBodyStyle() ); + + if( m_checkApplyToAllUnits->IsChecked() ) + m_shape->SetUnit( 0 ); + else + m_shape->SetUnit( symbolEditor->GetUnit() ); + } + else + { + if( m_filledCtrl->GetValue() ) + m_shape->SetFillMode( FILL_T::FILLED_WITH_COLOR ); + else + m_shape->SetFillMode( FILL_T::NO_FILL ); + + m_shape->SetFillColor( m_fillColorSwatch->GetSwatchColor() ); + } if( !commit.Empty() ) - { - commit.Push( wxString::Format( _( "Edit %s" ), m_shape->EDA_SHAPE::GetFriendlyName() ) ); - } + commit.Push( wxString::Format( _( "Edit %s" ), m_shape->GetFriendlyName() ) ); return true; } diff --git a/eeschema/dialogs/dialog_shape_properties.h b/eeschema/dialogs/dialog_shape_properties.h index 13761fa7fd..fc361b54f4 100644 --- a/eeschema/dialogs/dialog_shape_properties.h +++ b/eeschema/dialogs/dialog_shape_properties.h @@ -26,7 +26,7 @@ class SCH_SHAPE; -class SCH_EDIT_FRAME; +class SCH_BASE_FRAME; #include @@ -36,17 +36,24 @@ class SCH_EDIT_FRAME; class DIALOG_SHAPE_PROPERTIES : public DIALOG_SHAPE_PROPERTIES_BASE { public: - DIALOG_SHAPE_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_SHAPE* aShape ); + DIALOG_SHAPE_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_SHAPE* aShape ); + ~DIALOG_SHAPE_PROPERTIES() override; bool TransferDataToWindow() override; bool TransferDataFromWindow() override; -private: - void onBorderChecked( wxCommandEvent& aEvent) override; - void onFillChecked( wxCommandEvent& aEvent ) override; + bool GetApplyToAllConversions() { return m_checkApplyToAllBodyStyles->IsChecked(); } + bool GetApplyToAllUnits() { return m_checkApplyToAllUnits->IsChecked(); } private: - SCH_EDIT_FRAME* m_frame; + void onBorderChecked( wxCommandEvent& aEvent) override; + void onBorderSwatch( wxCommandEvent& aEvent ); + void onFillChecked( wxCommandEvent& aEvent ) override; + void onFillRadioButton(wxCommandEvent &aEvent) override; + void onCustomColorSwatch( wxCommandEvent& aEvent ); + +private: + SCH_BASE_FRAME* m_frame; SCH_SHAPE* m_shape; UNIT_BINDER m_borderWidth; }; diff --git a/eeschema/dialogs/dialog_shape_properties_base.cpp b/eeschema/dialogs/dialog_shape_properties_base.cpp index b1a0a24172..916fdf5a6e 100644 --- a/eeschema/dialogs/dialog_shape_properties_base.cpp +++ b/eeschema/dialogs/dialog_shape_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -15,6 +15,10 @@ BEGIN_EVENT_TABLE( DIALOG_SHAPE_PROPERTIES_BASE, DIALOG_SHIM ) EVT_CHECKBOX( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onBorderChecked ) EVT_CHECKBOX( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillChecked ) + EVT_RADIOBUTTON( NO_FILL, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillRadioButton ) + EVT_RADIOBUTTON( FILLED_SHAPE, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) + EVT_RADIOBUTTON( FILLED_WITH_BG_BODYCOLOR, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) + EVT_RADIOBUTTON( FILLED_WITH_COLOR, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFill ) END_EVENT_TABLE() DIALOG_SHAPE_PROPERTIES_BASE::DIALOG_SHAPE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) @@ -31,17 +35,20 @@ DIALOG_SHAPE_PROPERTIES_BASE::DIALOG_SHAPE_PROPERTIES_BASE( wxWindow* parent, wx mainSizer->Add( m_infoBar, 0, wxBOTTOM|wxEXPAND, 5 ); - m_textEntrySizer = new wxGridBagSizer( 3, 3 ); - m_textEntrySizer->SetFlexibleDirection( wxBOTH ); - m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_textEntrySizer->SetEmptyCellSize( wxSize( 36,-1 ) ); + wxBoxSizer* bColumns; + bColumns = new wxBoxSizer( wxHORIZONTAL ); + + m_borderSizer = new wxGridBagSizer( 3, 3 ); + m_borderSizer->SetFlexibleDirection( wxBOTH ); + m_borderSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + m_borderSizer->SetEmptyCellSize( wxSize( 36,-1 ) ); m_borderCheckbox = new wxCheckBox( this, wxID_ANY, _("Border"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textEntrySizer->Add( m_borderCheckbox, wxGBPosition( 0, 0 ), wxGBSpan( 1, 2 ), wxBOTTOM, 2 ); + m_borderSizer->Add( m_borderCheckbox, wxGBPosition( 0, 0 ), wxGBSpan( 1, 2 ), wxBOTTOM, 2 ); m_borderWidthLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 ); m_borderWidthLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + m_borderSizer->Add( m_borderWidthLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); wxBoxSizer* bSizer7; bSizer7 = new wxBoxSizer( wxHORIZONTAL ); @@ -74,61 +81,156 @@ DIALOG_SHAPE_PROPERTIES_BASE::DIALOG_SHAPE_PROPERTIES_BASE( wxWindow* parent, wx bSizer7->Add( m_panelBorderColor, 0, wxALIGN_CENTER_VERTICAL, 5 ); - m_textEntrySizer->Add( bSizer7, wxGBPosition( 1, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); + m_borderSizer->Add( bSizer7, wxGBPosition( 1, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); m_borderStyleLabel = new wxStaticText( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, 0 ); m_borderStyleLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + m_borderSizer->Add( m_borderStyleLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_borderStyleCombo = new wxBitmapComboBox( this, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) ); - m_textEntrySizer->Add( m_borderStyleCombo, wxGBPosition( 2, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - - m_filledCtrl = new wxCheckBox( this, wxID_ANY, _("Filled shape"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textEntrySizer->Add( m_filledCtrl, wxGBPosition( 0, 5 ), wxGBSpan( 1, 2 ), wxRIGHT, 80 ); - - wxBoxSizer* bSizer8; - bSizer8 = new wxBoxSizer( wxHORIZONTAL ); - - m_fillColorLabel = new wxStaticText( this, wxID_ANY, _("Fill color:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_fillColorLabel->Wrap( -1 ); - bSizer8->Add( m_fillColorLabel, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); - - m_panelFillColor = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer211; - bSizer211 = new wxBoxSizer( wxVERTICAL ); - - m_fillColorSwatch = new COLOR_SWATCH( m_panelFillColor, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer211->Add( m_fillColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - - m_panelFillColor->SetSizer( bSizer211 ); - m_panelFillColor->Layout(); - bSizer211->Fit( m_panelFillColor ); - bSizer8->Add( m_panelFillColor, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - m_textEntrySizer->Add( bSizer8, wxGBPosition( 1, 5 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); - - - m_textEntrySizer->AddGrowableCol( 3 ); - - mainSizer->Add( m_textEntrySizer, 0, wxEXPAND|wxALL, 10 ); - - wxBoxSizer* bSizer12; - bSizer12 = new wxBoxSizer( wxVERTICAL ); + m_borderSizer->Add( m_borderStyleCombo, wxGBPosition( 2, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_helpLabel1 = new wxStaticText( this, wxID_ANY, _("Set border width to 0 to use schematic's default line width."), wxDefaultPosition, wxDefaultSize, 0 ); - m_helpLabel1->Wrap( -1 ); - bSizer12->Add( m_helpLabel1, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 10 ); + m_helpLabel1->Wrap( 320 ); + m_borderSizer->Add( m_helpLabel1, wxGBPosition( 3, 0 ), wxGBSpan( 1, 2 ), wxTOP, 8 ); - m_helpLabel2 = new wxStaticText( this, wxID_ANY, _("Clear colors to use Schematic Editor colors."), wxDefaultPosition, wxDefaultSize, 0 ); + + bColumns->Add( m_borderSizer, 9, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); + + + bColumns->Add( 15, 0, 0, wxEXPAND, 5 ); + + m_fillBook = new wxSimplebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_schematicPage = new wxPanel( m_fillBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer8; + bSizer8 = new wxBoxSizer( wxVERTICAL ); + + m_fillSizer = new wxGridBagSizer( 3, 3 ); + m_fillSizer->SetFlexibleDirection( wxBOTH ); + m_fillSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + m_fillSizer->SetEmptyCellSize( wxSize( 36,12 ) ); + + m_filledCtrl = new wxCheckBox( m_schematicPage, wxID_ANY, _("Filled shape"), wxDefaultPosition, wxDefaultSize, 0 ); + m_fillSizer->Add( m_filledCtrl, wxGBPosition( 0, 0 ), wxGBSpan( 1, 2 ), wxBOTTOM, 2 ); + + wxBoxSizer* bSizer81; + bSizer81 = new wxBoxSizer( wxHORIZONTAL ); + + m_fillColorLabel = new wxStaticText( m_schematicPage, wxID_ANY, _("Fill color:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_fillColorLabel->Wrap( -1 ); + bSizer81->Add( m_fillColorLabel, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_panelFillColor = new wxPanel( m_schematicPage, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer21; + bSizer21 = new wxBoxSizer( wxVERTICAL ); + + m_fillColorSwatch = new COLOR_SWATCH( m_panelFillColor, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer21->Add( m_fillColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + m_panelFillColor->SetSizer( bSizer21 ); + m_panelFillColor->Layout(); + bSizer21->Fit( m_panelFillColor ); + bSizer81->Add( m_panelFillColor, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + m_fillSizer->Add( bSizer81, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); + + m_helpLabel2 = new wxStaticText( m_schematicPage, wxID_ANY, _("Clear colors to use Schematic Editor colors."), wxDefaultPosition, wxDefaultSize, 0 ); m_helpLabel2->Wrap( -1 ); - bSizer12->Add( m_helpLabel2, 0, wxBOTTOM|wxRIGHT|wxLEFT, 10 ); + m_fillSizer->Add( m_helpLabel2, wxGBPosition( 4, 0 ), wxGBSpan( 1, 2 ), wxTOP|wxRIGHT, 8 ); - mainSizer->Add( bSizer12, 0, wxBOTTOM|wxEXPAND, 5 ); + bSizer8->Add( m_fillSizer, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 ); + + + m_schematicPage->SetSizer( bSizer8 ); + m_schematicPage->Layout(); + bSizer8->Fit( m_schematicPage ); + m_fillBook->AddPage( m_schematicPage, _("a page"), false ); + m_symbolEditorPage = new wxPanel( m_fillBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer9; + bSizer9 = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* bSizerFill; + bSizerFill = new wxStaticBoxSizer( new wxStaticBox( m_symbolEditorPage, wxID_ANY, _("Fill Style") ), wxVERTICAL ); + + wxGridBagSizer* gbSizer1; + gbSizer1 = new wxGridBagSizer( 3, 0 ); + gbSizer1->SetFlexibleDirection( wxBOTH ); + gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_rbFillNone = new wxRadioButton( bSizerFill->GetStaticBox(), NO_FILL, _("Do not fill"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); + gbSizer1->Add( m_rbFillNone, wxGBPosition( 0, 0 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_rbFillOutline = new wxRadioButton( bSizerFill->GetStaticBox(), FILLED_SHAPE, _("Fill with body outline color"), wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_rbFillOutline, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_rbFillBackground = new wxRadioButton( bSizerFill->GetStaticBox(), FILLED_WITH_BG_BODYCOLOR, _("Fill with body background color"), wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_rbFillBackground, wxGBPosition( 2, 0 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_rbFillCustom = new wxRadioButton( bSizerFill->GetStaticBox(), FILLED_WITH_COLOR, _("Fill with:"), wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_rbFillCustom, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_customColorSwatch = new COLOR_SWATCH( bSizerFill->GetStaticBox(), FILLED_WITH_COLOR, wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_customColorSwatch, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + + bSizerFill->Add( gbSizer1, 1, wxEXPAND|wxBOTTOM, 5 ); + + + bSizer9->Add( bSizerFill, 1, wxEXPAND, 5 ); + + + m_symbolEditorPage->SetSizer( bSizer9 ); + m_symbolEditorPage->Layout(); + bSizer9->Fit( m_symbolEditorPage ); + m_fillBook->AddPage( m_symbolEditorPage, _("a page"), false ); + + bColumns->Add( m_fillBook, 8, wxEXPAND | wxALL, 10 ); + + + mainSizer->Add( bColumns, 0, wxEXPAND, 5 ); + + m_symbolEditorSizer = new wxBoxSizer( wxVERTICAL ); + + + m_symbolEditorSizer->Add( 0, 10, 0, wxEXPAND, 5 ); + + wxBoxSizer* bColumns2; + bColumns2 = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bLeft2; + bLeft2 = new wxBoxSizer( wxVERTICAL ); + + m_privateCheckbox = new wxCheckBox( this, wxID_ANY, _("Private to Symbol Editor"), wxDefaultPosition, wxDefaultSize, 0 ); + bLeft2->Add( m_privateCheckbox, 0, wxTOP, 5 ); + + + bColumns2->Add( bLeft2, 9, wxEXPAND|wxRIGHT|wxLEFT, 10 ); + + + bColumns2->Add( 15, 0, 0, wxEXPAND, 5 ); + + wxBoxSizer* bRight2; + bRight2 = new wxBoxSizer( wxVERTICAL ); + + m_checkApplyToAllUnits = new wxCheckBox( this, wxID_ANY, _("Common to all &units in symbol"), wxDefaultPosition, wxDefaultSize, 0 ); + bRight2->Add( m_checkApplyToAllUnits, 0, wxTOP|wxRIGHT, 5 ); + + m_checkApplyToAllBodyStyles = new wxCheckBox( this, wxID_ANY, _("Common to all body &styles (De Morgan)"), wxDefaultPosition, wxDefaultSize, 0 ); + bRight2->Add( m_checkApplyToAllBodyStyles, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); + + + bColumns2->Add( bRight2, 8, wxEXPAND|wxRIGHT|wxLEFT, 10 ); + + + m_symbolEditorSizer->Add( bColumns2, 1, wxEXPAND, 5 ); + + + mainSizer->Add( m_symbolEditorSizer, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 ); m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); diff --git a/eeschema/dialogs/dialog_shape_properties_base.fbp b/eeschema/dialogs/dialog_shape_properties_base.fbp index 405e741e37..bd961893ec 100644 --- a/eeschema/dialogs/dialog_shape_properties_base.fbp +++ b/eeschema/dialogs/dialog_shape_properties_base.fbp @@ -1,71 +1,303 @@ - + - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - table - dialog_shape_properties_base - 1000 - none - - - 1 - dialog_shape_properties - - . - - 1 - 1 - 1 - 1 - UI - 0 - 1 - 0 - - 0 - wxAUI_MGR_DEFAULT + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + table + dialog_shape_properties_base + 1000 + none + + + 1 + dialog_shape_properties + + . + + 1 + 1 + 1 + 1 + UI + 0 + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_SHAPE_PROPERTIES_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + %s Properties + + 0 + + + + + + mainSizer + wxVERTICAL + none + + 5 + wxBOTTOM|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + - wxBOTH + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left + 0 + 500 1 - impl_virtual - + 1 - 0 + 0 + 1 + wxSHOW_EFFECT_NONE wxID_ANY + + 0 + + 0 - DIALOG_SHAPE_PROPERTIES_BASE + 1 + m_infoBar + 1 + + + protected + 1 - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - %s Properties + Resizable + 1 + wxSHOW_EFFECT_NONE + + WX_INFOBAR; widgets/wx_infobar.h; forward_declare + 0 - 0 - + + + + 5 + wxEXPAND + 0 + + + bColumns + wxHORIZONTAL + none + + 10 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 9 + + 36,-1 + wxBOTH + + + 3 - mainSizer - wxVERTICAL - none - - 5 - wxBOTTOM|wxEXPAND - 0 - + m_borderSizer + wxFLEX_GROWMODE_SPECIFIED + protected + 3 + + 2 + 2 + 0 + wxBOTTOM + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Border + + 0 + + + 0 + + 1 + m_borderCheckbox + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onBorderChecked + + + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Width: + 0 + + 0 + + + 0 + + 1 + m_borderWidthLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 2 + 1 + wxEXPAND + 1 + 1 + + + bSizer7 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL + 0 + 1 1 1 @@ -86,23 +318,89 @@ Dock 0 Left - 500 + 0 1 1 0 - 1 - wxSHOW_EFFECT_NONE + 0 wxID_ANY 0 - + 0 + -1,-1 0 - + -1,-1 1 - m_infoBar + m_borderWidthCtrl + 1 + + + protected + 1 + + Resizable + 1 + -1,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + -1,-1 + 1 + m_borderWidthUnits 1 @@ -111,244 +409,769 @@ Resizable 1 - wxSHOW_EFFECT_NONE - WX_INFOBAR; widgets/wx_infobar.h; forward_declare + + 0 + -1 + - - - 10 - wxEXPAND|wxALL - 0 - - 36,-1 - wxBOTH - 3 - - 3 + + 15 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Color: + 0 + + 0 + + + 0 - m_textEntrySizer - wxFLEX_GROWMODE_SPECIFIED + 1 + m_borderColorLabel + 1 + + protected - 3 - + 1 + + Resizable + 1 + + + ; ; Not forward_declare + 0 + + + + + -1 + + + + 5 + + 0 + + 0 + protected + 5 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelBorderColor + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxBORDER_SIMPLE|wxTAB_TRAVERSAL + + + bSizer23 + wxVERTICAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + COLOR_SWATCH + 1 + + + 1 + + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + m_borderColorSwatch + 1 + + + protected + 1 + + Resizable + + 1 + + COLOR_SWATCH; widgets/color_swatch.h; forward_declare + 0 + + + + + + + + + + + + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Style: + 0 + + 0 + + + 0 + + 1 + m_borderStyleLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 2 + 1 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 240,-1 + 1 + m_borderStyleCombo + 1 + + + protected + 1 + + Resizable + -1 + 1 + + wxCB_READONLY + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + Combo! + + + + + + + 8 + 2 + 0 + wxTOP + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Set border width to 0 to use schematic's default line width. + 0 + + 0 + + + 0 + + 1 + m_helpLabel1 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + 320 + + + + + + 5 + wxEXPAND + 0 + + 0 + protected + 15 + + + + 10 + wxEXPAND | wxALL + 8 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_fillBook + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + + + a page + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_schematicPage + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + bSizer8 + wxVERTICAL + none + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT + 1 + + 36,12 + wxBOTH + + + 3 + + m_fillSizer + wxFLEX_GROWMODE_SPECIFIED + protected + 3 + 2 2 0 wxBOTTOM 0 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Border - - 0 - - - 0 - - 1 - m_borderCheckbox - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onBorderChecked + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Filled shape + + 0 + + + 0 + + 1 + m_filledCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onFillChecked - - - 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL - 1 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Width: - 0 - - 0 - - - 0 - - 1 - m_borderWidthLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - + + 5 2 - 1 + 0 wxEXPAND 1 1 - - - bSizer7 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - -1,-1 - 0 - -1,-1 - 1 - m_borderWidthCtrl - 1 - - - protected - 1 - - Resizable - 1 - -1,-1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - + + + bSizer81 + wxHORIZONTAL + none + + 5 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Fill color: + 0 + + 0 + + + 0 + + 1 + m_fillColorLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 - - 3 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelFillColor + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxBORDER_SIMPLE|wxTAB_TRAVERSAL + + + bSizer21 + wxVERTICAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL + 0 + 1 1 1 @@ -362,13 +1185,17 @@ 1 0 + COLOR_SWATCH 1 + 1 + 0 Dock 0 Left + 0 1 1 @@ -376,69 +1203,7 @@ 0 0 wxID_ANY - mm - 0 - - 0 - - - 0 - -1,-1 - 1 - m_borderWidthUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 15 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Color: - 0 + 0 @@ -446,7 +1211,7 @@ 0 1 - m_borderColorLabel + m_fillColorSwatch 1 @@ -454,709 +1219,810 @@ 1 Resizable + 1 - - ; ; Not forward_declare + COLOR_SWATCH; widgets/color_swatch.h; forward_declare 0 - -1 - - - - 5 - - 0 - - 0 - protected - 5 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelBorderColor - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - - - - wxBORDER_SIMPLE|wxTAB_TRAVERSAL - - - bSizer23 - wxVERTICAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - COLOR_SWATCH - 1 - - - 1 - - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_borderColorSwatch - 1 - - - protected - 1 - - Resizable - - 1 - - COLOR_SWATCH; widgets/color_swatch.h; forward_declare - 0 - - - - - - - + + + - - - 5 - 1 + + + 8 + 2 0 - wxALIGN_CENTER_VERTICAL - 2 + wxTOP|wxRIGHT + 4 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Style: - 0 - - 0 - - - 0 - - 1 - m_borderStyleLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Clear colors to use Schematic Editor colors. + 0 + + 0 + + + 0 + + 1 + m_helpLabel2 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + - + + + + + + a page + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_symbolEditorPage + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + bSizer9 + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + wxID_ANY + Fill Style + + bSizerFill + wxVERTICAL + 1 + none + 5 - 2 - 1 - wxALIGN_CENTER_VERTICAL|wxEXPAND - 2 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - 240,-1 - 1 - m_borderStyleCombo - 1 - - - protected - 1 - - Resizable - -1 - 1 - - wxCB_READONLY - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - Combo! - - - - - - - 80 - 2 - 5 - wxRIGHT - 0 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Filled shape - - 0 - - - 0 - - 1 - m_filledCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onFillChecked - - - - 5 - 2 - 5 - wxEXPAND - 1 - 1 - - - bSizer8 - wxHORIZONTAL - none - - 5 - wxRIGHT|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Fill color: - 0 - - 0 - - - 0 - - 1 - m_fillColorLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - + wxEXPAND|wxBOTTOM + 1 + + + wxBOTH + + + 0 + + gbSizer1 + wxFLEX_GROWMODE_SPECIFIED + none + 3 + + 5 + 2 + 0 + wxALIGN_CENTER_VERTICAL + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + NO_FILL + Do not fill + + 0 + + + 0 + + 1 + m_rbFillNone + 1 + + + protected + 1 + + Resizable + 1 + + wxRB_GROUP + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + onFillRadioButton - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelFillColor - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - - - - wxBORDER_SIMPLE|wxTAB_TRAVERSAL - - - bSizer211 - wxVERTICAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - COLOR_SWATCH - 1 - - - 1 - - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_fillColorSwatch - 1 - - - protected - 1 - - Resizable - - 1 - - COLOR_SWATCH; widgets/color_swatch.h; forward_declare - 0 - - - - - - - - + + + 5 + 2 + 0 + wxALIGN_CENTER_VERTICAL + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + FILLED_SHAPE + Fill with body outline color + + 0 + + + 0 + + 1 + m_rbFillOutline + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + onFill + + + 5 + 2 + 0 + wxALIGN_CENTER_VERTICAL + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + FILLED_WITH_BG_BODYCOLOR + Fill with body background color + + 0 + + + 0 + + 1 + m_rbFillBackground + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + onFill + + + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + FILLED_WITH_COLOR + Fill with: + + 0 + + + 0 + + 1 + m_rbFillCustom + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + onFill + + + + 5 + 1 + 1 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + COLOR_SWATCH + 1 + + + 1 + + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + FILLED_WITH_COLOR + + + 0 + + + 0 + + 1 + m_customColorSwatch + 1 + + + protected + 1 + + Resizable + + 1 + + COLOR_SWATCH; widgets/color_swatch.h; forward_declare + 0 + + + + + + + + + - - 5 - wxBOTTOM|wxEXPAND - 0 - - - bSizer12 - wxVERTICAL - none - - 10 - wxTOP|wxRIGHT|wxLEFT|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Set border width to 0 to use schematic's default line width. - 0 - - 0 - - - 0 - - 1 - m_helpLabel1 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 10 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Clear colors to use Schematic Editor colors. - 0 - - 0 - - - 0 - - 1 - m_helpLabel2 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - - - 5 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - + + + + 5 + wxEXPAND|wxTOP|wxBOTTOM + 1 + + + m_symbolEditorSizer + wxVERTICAL + protected + + 5 + wxEXPAND + 0 + + 10 + protected + 0 + + + + 5 + wxEXPAND + 1 + + + bColumns2 + wxHORIZONTAL + none + + 10 + wxEXPAND|wxRIGHT|wxLEFT + 9 + + + bLeft2 + wxVERTICAL + none + + 5 + wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Private to Symbol Editor + + 0 + + + 0 + + 1 + m_privateCheckbox + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxEXPAND + 0 + + 0 + protected + 15 + + + + 10 + wxEXPAND|wxRIGHT|wxLEFT + 8 + + + bRight2 + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Common to all &units in symbol + + 0 + + + 0 + + 1 + m_checkApplyToAllUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Common to all body &styles (De Morgan) + + 0 + + + 0 + + 1 + m_checkApplyToAllBodyStyles + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + + + diff --git a/eeschema/dialogs/dialog_shape_properties_base.h b/eeschema/dialogs/dialog_shape_properties_base.h index 7bdf4e08a4..56a4f776cf 100644 --- a/eeschema/dialogs/dialog_shape_properties_base.h +++ b/eeschema/dialogs/dialog_shape_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -27,6 +27,9 @@ class WX_INFOBAR; #include #include #include +#include +#include +#include #include #include @@ -43,11 +46,21 @@ class DIALOG_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM // Private event handlers void _wxFB_onBorderChecked( wxCommandEvent& event ){ onBorderChecked( event ); } void _wxFB_onFillChecked( wxCommandEvent& event ){ onFillChecked( event ); } + void _wxFB_onFillRadioButton( wxCommandEvent& event ){ onFillRadioButton( event ); } + void _wxFB_onFill( wxCommandEvent& event ){ onFill( event ); } protected: + enum + { + NO_FILL = 1000, + FILLED_SHAPE, + FILLED_WITH_BG_BODYCOLOR, + FILLED_WITH_COLOR + }; + WX_INFOBAR* m_infoBar; - wxGridBagSizer* m_textEntrySizer; + wxGridBagSizer* m_borderSizer; wxCheckBox* m_borderCheckbox; wxStaticText* m_borderWidthLabel; wxTextCtrl* m_borderWidthCtrl; @@ -57,12 +70,25 @@ class DIALOG_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM COLOR_SWATCH* m_borderColorSwatch; wxStaticText* m_borderStyleLabel; wxBitmapComboBox* m_borderStyleCombo; + wxStaticText* m_helpLabel1; + wxSimplebook* m_fillBook; + wxPanel* m_schematicPage; + wxGridBagSizer* m_fillSizer; wxCheckBox* m_filledCtrl; wxStaticText* m_fillColorLabel; wxPanel* m_panelFillColor; COLOR_SWATCH* m_fillColorSwatch; - wxStaticText* m_helpLabel1; wxStaticText* m_helpLabel2; + wxPanel* m_symbolEditorPage; + wxRadioButton* m_rbFillNone; + wxRadioButton* m_rbFillOutline; + wxRadioButton* m_rbFillBackground; + wxRadioButton* m_rbFillCustom; + COLOR_SWATCH* m_customColorSwatch; + wxBoxSizer* m_symbolEditorSizer; + wxCheckBox* m_privateCheckbox; + wxCheckBox* m_checkApplyToAllUnits; + wxCheckBox* m_checkApplyToAllBodyStyles; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; @@ -70,6 +96,8 @@ class DIALOG_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM // Virtual event handlers, override them in your derived class virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); } virtual void onFillChecked( wxCommandEvent& event ) { event.Skip(); } + virtual void onFillRadioButton( wxCommandEvent& event ) { event.Skip(); } + virtual void onFill( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index a850f28740..aa6ee64bf0 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_ITEM* aTextItem ) : @@ -87,6 +87,11 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_ITE m_filledCtrl->Show( false ); } + // DIALOG_SHIM needs a unique hash_key because classname is not sufficient because the + // different text item types (and even whether or not we're within the symbol editor) cause + // different dialog layouts). + m_hash_key = TO_UTF8( GetTitle() + aParent->GetName() ); + m_textCtrl->SetEOLMode( wxSTC_EOL_LF ); #ifdef _WIN32 @@ -493,10 +498,8 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() m_currentItem->SetExcludedFromSim( m_excludeFromSim->GetValue() ); - if( m_isSymbolEditor ) + if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast( m_frame ) ) { - SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast( m_frame ); - m_currentItem->SetPrivate( m_privateCheckbox->GetValue() ); if( !m_commonToAllUnits->GetValue() ) diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index 4626bb895a..9cbd75949f 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -375,8 +375,9 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() symbol->SetShowPinNumbers( true ); symbol->SetPinNameOffset( 0 ); - LIB_SHAPE* comp_body = new LIB_SHAPE( symbol, SHAPE_T::POLY ); + SCH_SHAPE* comp_body = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); + comp_body->SetParent( symbol ); comp_body->SetUnit( 0 ); comp_body->SetBodyStyle( 0 ); comp_body->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); diff --git a/eeschema/gfx_import_utils.cpp b/eeschema/gfx_import_utils.cpp index 7d43e9e2c2..3ab24d982a 100644 --- a/eeschema/gfx_import_utils.cpp +++ b/eeschema/gfx_import_utils.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -118,8 +118,7 @@ void ConvertImageToLibShapes( LIB_SYMBOL* aSymbol, int unit, wxImage img, VECTOR for( const SHAPE_POLY_SET::POLYGON& poly : polySet.CPolygons() ) { - std::unique_ptr shape = - std::make_unique( aSymbol, SHAPE_T::POLY ); + auto shape = std::make_unique( SHAPE_T::POLY, LAYER_DEVICE ); shape->SetPolyShape( poly ); diff --git a/eeschema/import_gfx/graphics_importer_lib_symbol.cpp b/eeschema/import_gfx/graphics_importer_lib_symbol.cpp index f45817d1b1..54bd14cba2 100644 --- a/eeschema/import_gfx/graphics_importer_lib_symbol.cpp +++ b/eeschema/import_gfx/graphics_importer_lib_symbol.cpp @@ -26,7 +26,7 @@ #include "graphics_importer_lib_symbol.h" #include -#include +#include #include #include @@ -81,7 +81,8 @@ void GRAPHICS_IMPORTER_LIB_SYMBOL::AddLine( const VECTOR2D& aStart, const VECTOR if( pt0 == pt1 ) return; - std::unique_ptr line = std::make_unique( m_symbol, SHAPE_T::POLY ); + std::unique_ptr line = std::make_unique( SHAPE_T::POLY, LAYER_DEVICE ); + line->SetParent( m_symbol ); line->SetUnit( m_unit ); line->SetStroke( MapStrokeParams( aStroke ) ); @@ -96,7 +97,8 @@ void GRAPHICS_IMPORTER_LIB_SYMBOL::AddCircle( const VECTOR2D& aCenter, double aR const IMPORTED_STROKE& aStroke, bool aFilled, const COLOR4D& aFillColor ) { - std::unique_ptr circle = std::make_unique( m_symbol, SHAPE_T::CIRCLE ); + std::unique_ptr circle = std::make_unique( SHAPE_T::CIRCLE, LAYER_DEVICE ); + circle->SetParent( m_symbol ); circle->SetUnit( m_unit ); circle->SetFillColor( aFillColor ); circle->SetFilled( aFilled ); @@ -111,7 +113,8 @@ void GRAPHICS_IMPORTER_LIB_SYMBOL::AddCircle( const VECTOR2D& aCenter, double aR void GRAPHICS_IMPORTER_LIB_SYMBOL::AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, const EDA_ANGLE& aAngle, const IMPORTED_STROKE& aStroke ) { - std::unique_ptr arc = std::make_unique( m_symbol, SHAPE_T::ARC ); + std::unique_ptr arc = std::make_unique( SHAPE_T::ARC, LAYER_DEVICE ); + arc->SetParent( m_symbol ); arc->SetUnit( m_unit ); /** @@ -160,7 +163,8 @@ void GRAPHICS_IMPORTER_LIB_SYMBOL::AddPolygon( const std::vector& aVer if( convertedPoints.empty() ) return; - std::unique_ptr polygon = std::make_unique( m_symbol, SHAPE_T::POLY ); + std::unique_ptr polygon = std::make_unique( SHAPE_T::POLY, LAYER_DEVICE ); + polygon->SetParent( m_symbol ); polygon->SetUnit( m_unit ); if( aFilled ) @@ -205,7 +209,8 @@ void GRAPHICS_IMPORTER_LIB_SYMBOL::AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd, const IMPORTED_STROKE& aStroke ) { - std::unique_ptr spline = std::make_unique( m_symbol, SHAPE_T::BEZIER ); + std::unique_ptr spline = std::make_unique( SHAPE_T::BEZIER, LAYER_DEVICE ); + spline->SetParent( m_symbol ); spline->SetUnit( m_unit ); spline->SetStroke( MapStrokeParams( aStroke ) ); spline->SetStart( MapCoordinate( aStart ) ); diff --git a/eeschema/import_gfx/graphics_importer_lib_symbol.h b/eeschema/import_gfx/graphics_importer_lib_symbol.h index 12c8b588d2..7702292979 100644 --- a/eeschema/import_gfx/graphics_importer_lib_symbol.h +++ b/eeschema/import_gfx/graphics_importer_lib_symbol.h @@ -29,11 +29,8 @@ #include -#include class LIB_SYMBOL; -class LIB_SHAPE; -class LIB_TEXT; class GRAPHICS_IMPORTER_LIB_SYMBOL : public GRAPHICS_IMPORTER { diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 81ed312140..eb0d2b4754 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1249,7 +1249,7 @@ void LIB_PIN::validateExtentsCache( KIFONT::FONT* aFont, int aSize, const wxStri } -const BOX2I LIB_PIN::GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber, +const BOX2I LIB_PIN::GetBoundingBox( bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber, bool aIncludeElectricalType ) const { EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); @@ -1269,9 +1269,10 @@ const BOX2I LIB_PIN::GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNa bool includeType = aIncludeElectricalType; int minsizeV = TARGET_PIN_RADIUS; - if( !aIncludeInvisiblePins && !IsVisible() ) + if( !aIncludeLabelsOnInvisiblePins && !IsVisible() ) { includeName = false; + includeNumber = false; includeType = false; } diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index e5d9f22d74..bdf9f1e0b1 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -27,7 +27,6 @@ #ifndef CLASS_PIN_H #define CLASS_PIN_H -#include #include #include @@ -185,16 +184,15 @@ public: const BOX2I GetBoundingBox() const override { return GetBoundingBox( false, true, true ); } /** - * @param aIncludeInvisibles - if false, do not include labels for invisible pins - * in the calculation. + * @param aIncludeLabelsOnInvisblePins - if false, do not include labels for invisible pins + * in the calculation. */ - const BOX2I GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber, + const BOX2I GetBoundingBox( bool aIncludeLabelsOnInvisblePins, bool aIncludeNameAndNumber, bool aIncludeElectricalType ) const; /** - * Return whether this pin forms a global power connection: i.e., is part of - * a power symbol and of type POWER_IN, or is a legacy invisible global - * power pin on a symbol. + * Return whether this pin forms a global power connection: i.e., is part of a power symbol + * and of type POWER_IN, or is a legacy invisible global power pin on a symbol. */ bool IsGlobalPower() const { @@ -222,11 +220,9 @@ public: void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override; /** - * Plot the pin number and pin text info, given the pin line coordinates. - * Same as DrawPinTexts((), but output is the plotter - * The line must be vertical or horizontal. - * If TextInside then the text is been put inside (moving from x1, y1 in - * the opposite direction to x2,y2), otherwise all is drawn outside. + * Plot the pin name and number. + * @param aTextInside - draw the names & numbers inside the symbol body (ie: in the opposite + * direction of \a aPinOrient). */ void PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient, int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed ) const; diff --git a/eeschema/lib_shape.cpp b/eeschema/lib_shape.cpp deleted file mode 100644 index 336a41f54d..0000000000 --- a/eeschema/lib_shape.cpp +++ /dev/null @@ -1,602 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2024 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 2 - * 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, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -LIB_SHAPE::LIB_SHAPE( SCH_ITEM* aParent, SHAPE_T aShape, int aLineWidth, FILL_T aFillType, - KICAD_T aType ) : - SCH_ITEM( aParent, aType ), - EDA_SHAPE( aShape, aLineWidth, aFillType ) -{ - m_editState = 0; -} - - -bool LIB_SHAPE::HitTest( const VECTOR2I& aPosRef, int aAccuracy ) const -{ - if( aAccuracy < schIUScale.MilsToIU( MINIMUM_SELECTION_DISTANCE ) ) - aAccuracy = schIUScale.MilsToIU( MINIMUM_SELECTION_DISTANCE ); - - return hitTest( DefaultTransform.TransformCoordinate( aPosRef ), aAccuracy ); -} - - -bool LIB_SHAPE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const -{ - if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) ) - return false; - - return hitTest( DefaultTransform.TransformCoordinate( aRect ), aContained, aAccuracy ); -} - - -EDA_ITEM* LIB_SHAPE::Clone() const -{ - return new LIB_SHAPE( *this ); -} - - -int LIB_SHAPE::compare( const SCH_ITEM& aOther, int aCompareFlags ) const -{ - int retv = SCH_ITEM::compare( aOther, aCompareFlags ); - - if( retv ) - return retv; - - return EDA_SHAPE::Compare( &static_cast( aOther ) ); -} - - -void LIB_SHAPE::Move( const VECTOR2I& aOffset ) -{ - move( aOffset ); -} - - -void LIB_SHAPE::Normalize() -{ - if( GetShape() == SHAPE_T::RECTANGLE ) - { - VECTOR2I size = GetEnd() - GetPosition(); - - if( size.y > 0 ) - { - SetStartY( GetStartY() + size.y ); - SetEndY( GetStartY() - size.y ); - } - - if( size.x < 0 ) - { - SetStartX( GetStartX() + size.x ); - SetEndX( GetStartX() - size.x ); - } - } -} - - -void LIB_SHAPE::MirrorHorizontally( int aCenter ) -{ - flip( VECTOR2I( aCenter, 0 ), true ); -} - - -void LIB_SHAPE::MirrorVertically( int aCenter ) -{ - flip( VECTOR2I( 0, aCenter ), false ); -} - - -void LIB_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) -{ - EDA_ANGLE rot_angle = aRotateCCW ? -ANGLE_90 : ANGLE_90; - - rotate( aCenter, rot_angle ); -} - - -void LIB_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, - int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) -{ - if( IsPrivate() ) - return; - - SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); - - VECTOR2I start = renderSettings->TransformCoordinate( m_start ) + aOffset; - VECTOR2I end = renderSettings->TransformCoordinate( m_end ) + aOffset; - - static std::vector cornerList; - - if( GetShape() == SHAPE_T::POLY ) - { - const SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 ); - cornerList.clear(); - - for( const VECTOR2I& pt : poly.CPoints() ) - cornerList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset ); - } - else if( GetShape() == SHAPE_T::BEZIER ) - { - cornerList.clear(); - - for( const VECTOR2I& pt : m_bezierPoints ) - cornerList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset ); - } - - int penWidth; - COLOR4D color = GetStroke().GetColor(); - LINE_STYLE lineStyle = GetStroke().GetLineStyle(); - FILL_T fill = m_fill; - - if( aBackground ) - { - if( !aPlotter->GetColorMode() ) - return; - - switch( m_fill ) - { - case FILL_T::FILLED_SHAPE: - return; - - case FILL_T::FILLED_WITH_COLOR: - color = GetFillColor(); - break; - - case FILL_T::FILLED_WITH_BG_BODYCOLOR: - color = renderSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND ); - break; - - default: - return; - } - - penWidth = 0; - lineStyle = LINE_STYLE::SOLID; - } - else - { - if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) - color = renderSettings->GetLayerColor( LAYER_DEVICE ); - - if( lineStyle == LINE_STYLE::DEFAULT ) - lineStyle = LINE_STYLE::SOLID; - - if( m_fill == FILL_T::FILLED_SHAPE ) - fill = m_fill; - else - fill = FILL_T::NO_FILL; - - penWidth = GetEffectivePenWidth( renderSettings ); - } - - COLOR4D bg = renderSettings->GetBackgroundColor(); - - if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() ) - bg = COLOR4D::WHITE; - - if( aDimmed ) - { - color.Desaturate( ); - color = color.Mix( bg, 0.5f ); - } - - aPlotter->SetColor( color ); - aPlotter->SetDash( penWidth, lineStyle ); - - switch( GetShape() ) - { - case SHAPE_T::ARC: - { - VECTOR2I mid = renderSettings->TransformCoordinate( GetArcMid() ) + aOffset; - - aPlotter->Arc( start, mid, end, fill, penWidth ); - break; - } - - case SHAPE_T::CIRCLE: - { - VECTOR2I center = renderSettings->TransformCoordinate( getCenter() ) + aOffset; - - aPlotter->Circle( center, GetRadius() * 2, fill, penWidth ); - break; - } - - case SHAPE_T::RECTANGLE: - aPlotter->Rect( start, end, fill, penWidth ); - break; - - case SHAPE_T::POLY: - case SHAPE_T::BEZIER: - aPlotter->PlotPoly( cornerList, fill, penWidth ); - break; - - default: - UNIMPLEMENTED_FOR( SHAPE_T_asString() ); - } - - aPlotter->SetDash( penWidth, LINE_STYLE::SOLID ); -} - - -int LIB_SHAPE::GetPenWidth() const -{ - return GetWidth(); -} - - -void LIB_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, - const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) -{ - if( IsPrivate() ) - return; - - int penWidth = GetEffectivePenWidth( aSettings ); - - if( aForceNoFill && IsFilled() && penWidth == 0 ) - return; - - wxDC* DC = aSettings->GetPrintDC(); - VECTOR2I pt1 = aSettings->m_Transform.TransformCoordinate( m_start ) + aOffset; - VECTOR2I pt2 = aSettings->m_Transform.TransformCoordinate( m_end ) + aOffset; - VECTOR2I c; - COLOR4D color = GetStroke().GetColor(); - - if( color == COLOR4D::UNSPECIFIED ) - color = aSettings->GetLayerColor( LAYER_DEVICE ); - - COLOR4D bg = aSettings->GetBackgroundColor(); - - if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() ) - bg = COLOR4D::WHITE; - - if( aDimmed ) - { - color.Desaturate( ); - color = color.Mix( bg, 0.5f ); - } - - unsigned ptCount = 0; - VECTOR2I* buffer = nullptr; - - if( GetShape() == SHAPE_T::POLY ) - { - const SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 ); - - ptCount = poly.GetPointCount(); - buffer = new VECTOR2I[ptCount]; - - for( unsigned ii = 0; ii < ptCount; ++ii ) - buffer[ii] = aSettings->m_Transform.TransformCoordinate( poly.CPoint( ii ) ) + aOffset; - } - else if( GetShape() == SHAPE_T::BEZIER ) - { - ptCount = m_bezierPoints.size(); - buffer = new VECTOR2I[ptCount]; - - for( size_t ii = 0; ii < ptCount; ++ii ) - buffer[ii] = aSettings->m_Transform.TransformCoordinate( m_bezierPoints[ii] ) + aOffset; - } - else if( GetShape() == SHAPE_T::ARC ) - { - c = aSettings->m_Transform.TransformCoordinate( getCenter() ) + aOffset; - - EDA_ANGLE t1, t2; - - CalcArcAngles( t1, t2 ); - - // N.B. The order of evaluation is critical here as MapAngles will modify t1, t2 - // and the Normalize routine depends on these modifications for the correct output - bool transformed = aSettings->m_Transform.MapAngles( &t1, &t2 ); - EDA_ANGLE arc_angle = ( t1 - t2 ).Normalize180(); - bool transformed2 = ( arc_angle > ANGLE_0 ) && ( arc_angle < ANGLE_180 ); - - if( transformed == transformed2 ) - std::swap( pt1, pt2 ); - } - - COLOR4D fillColor = COLOR4D::UNSPECIFIED; - - if( !aForceNoFill ) - { - if( GetFillMode() == FILL_T::FILLED_SHAPE ) - fillColor = color; - else if( GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR ) - fillColor = aSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND ); - else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR ) - fillColor = GetFillColor(); - } - - if( fillColor != COLOR4D::UNSPECIFIED ) - { - if( aDimmed ) - { - fillColor.Desaturate( ); - fillColor = fillColor.Mix( bg, 0.5f ); - } - - switch( GetShape() ) - { - case SHAPE_T::ARC: - GRFilledArc( DC, pt1, pt2, c, 0, fillColor, fillColor ); - break; - - case SHAPE_T::CIRCLE: - GRFilledCircle( DC, pt1, GetRadius(), 0, fillColor, fillColor ); - break; - - case SHAPE_T::RECTANGLE: - GRFilledRect( DC, pt1, pt2, 0, fillColor, fillColor ); - break; - - case SHAPE_T::POLY: - GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor ); - break; - - case SHAPE_T::BEZIER: - GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor ); - break; - - default: - UNIMPLEMENTED_FOR( SHAPE_T_asString() ); - } - } - else - { - penWidth = std::max( penWidth, aSettings->GetDefaultPenWidth() ); - } - - if( penWidth > 0 ) - { - if( GetEffectiveLineStyle() == LINE_STYLE::SOLID ) - { - switch( GetShape() ) - { - case SHAPE_T::ARC: - GRArc( DC, pt1, pt2, c, penWidth, color ); - break; - - case SHAPE_T::CIRCLE: - GRCircle( DC, pt1, GetRadius(), penWidth, color ); - break; - - case SHAPE_T::RECTANGLE: - GRRect( DC, pt1, pt2, penWidth, color ); - break; - - case SHAPE_T::POLY: - GRPoly( DC, ptCount, buffer, false, penWidth, color, color ); - break; - - case SHAPE_T::BEZIER: - GRPoly( DC, ptCount, buffer, false, penWidth, color, color ); - break; - - default: - UNIMPLEMENTED_FOR( SHAPE_T_asString() ); - } - } - else - { - std::vector shapes = MakeEffectiveShapes( true ); - - for( SHAPE* shape : shapes ) - { - STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings, - [&]( const VECTOR2I& a, const VECTOR2I& b ) - { - VECTOR2I pts = aSettings->m_Transform.TransformCoordinate( a ) + aOffset; - VECTOR2I pte = aSettings->m_Transform.TransformCoordinate( b ) + aOffset; - GRLine( DC, pts.x, pts.y, pte.x, pte.y, penWidth, color ); - } ); - } - - for( SHAPE* shape : shapes ) - delete shape; - } - } - - delete[] buffer; -} - - -const BOX2I LIB_SHAPE::GetBoundingBox() const -{ - BOX2I bbox = getBoundingBox(); - - bbox.RevertYAxis(); - - return bbox; -} - - -void LIB_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) -{ - getSymbolEditorMsgPanelInfo( aFrame, aList ); - - ShapeGetMsgPanelInfo( aFrame, aList ); -} - - -wxString LIB_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const -{ - switch( GetShape() ) - { - case SHAPE_T::ARC: - return wxString::Format( _( "Arc with radius %s" ), - aUnitsProvider->MessageTextFromValue( GetRadius() ) ); - - case SHAPE_T::CIRCLE: - return wxString::Format( _( "Circle with radius %s" ), - aUnitsProvider->MessageTextFromValue( GetRadius() ) ); - - case SHAPE_T::RECTANGLE: - return wxString::Format( _( "Rectangle with width %s height %s" ), - aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ), - aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) ); - - case SHAPE_T::POLY: - return wxString::Format( _( "Polyline with %d points" ), - int( m_poly.Outline( 0 ).GetPointCount() ) ); - - case SHAPE_T::BEZIER: - return wxString::Format( _( "Bezier Curve with %d points" ), - int( m_bezierPoints.size() ) ); - - default: - UNIMPLEMENTED_FOR( SHAPE_T_asString() ); - return wxEmptyString; - } -} - - -BITMAPS LIB_SHAPE::GetMenuImage() const -{ - switch( GetShape() ) - { - case SHAPE_T::SEGMENT: return BITMAPS::add_line; - case SHAPE_T::ARC: return BITMAPS::add_arc; - case SHAPE_T::CIRCLE: return BITMAPS::add_circle; - case SHAPE_T::RECTANGLE: return BITMAPS::add_rectangle; - case SHAPE_T::POLY: return BITMAPS::add_graphical_segments; - case SHAPE_T::BEZIER: return BITMAPS::add_bezier; - - default: - UNIMPLEMENTED_FOR( SHAPE_T_asString() ); - return BITMAPS::question_mark; - } -} - - -void LIB_SHAPE::AddPoint( const VECTOR2I& aPosition ) -{ - if( GetShape() == SHAPE_T::POLY ) - { - if( m_poly.IsEmpty() ) - m_poly.NewOutline(); - - m_poly.Outline( 0 ).Append( aPosition, true ); - } - else - { - UNIMPLEMENTED_FOR( SHAPE_T_asString() ); - } -} - - -bool LIB_SHAPE::operator==( const SCH_ITEM& aOther ) const -{ - if( aOther.Type() != Type() ) - return false; - - const LIB_SHAPE& other = static_cast( aOther ); - - return SCH_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other ); -} - - -double LIB_SHAPE::Similarity( const SCH_ITEM& aOther ) const -{ - if( m_Uuid == aOther.m_Uuid ) - return 1.0; - - if( aOther.Type() != Type() ) - return 0.0; - - const LIB_SHAPE& other = static_cast( aOther ); - - double similarity = SimilarityBase( other ); - - similarity *= EDA_SHAPE::Similarity( other ); - - return similarity; -} - - -void LIB_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const -{ - aCount = 3; - aLayers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : LAYER_DEVICE; - aLayers[1] = IsPrivate() ? LAYER_NOTES_BACKGROUND : LAYER_DEVICE_BACKGROUND; - aLayers[2] = LAYER_SELECTION_SHADOWS; -} - - -static struct LIB_SHAPE_DESC -{ - LIB_SHAPE_DESC() - { - PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); - REGISTER_TYPE( LIB_SHAPE ); - propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.InheritsAfter( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( SCH_ITEM ) ); - propMgr.InheritsAfter( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( EDA_SHAPE ) ); - - // Only polygons have meaningful Position properties. - // On other shapes, these are duplicates of the Start properties. - auto isPolygon = - []( INSPECTABLE* aItem ) -> bool - { - if( LIB_SHAPE* shape = dynamic_cast( aItem ) ) - return shape->GetShape() == SHAPE_T::POLY; - - return false; - }; - - propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( SCH_ITEM ), - _HKI( "Position X" ), isPolygon ); - propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( SCH_ITEM ), - _HKI( "Position Y" ), isPolygon ); - - propMgr.Mask( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Filled" ) ); - - ENUM_MAP& fillEnum = ENUM_MAP::Instance(); - - if( fillEnum.Choices().GetCount() == 0 ) - { - fillEnum.Map( FILL_T::NO_FILL, _HKI( "None" ) ) - .Map( FILL_T::FILLED_SHAPE, _HKI( "Body outline color" ) ) - .Map( FILL_T::FILLED_WITH_BG_BODYCOLOR, _HKI( "Body background color" ) ) - .Map( FILL_T::FILLED_WITH_COLOR, _HKI( "Fill color" ) ); - } - - void ( LIB_SHAPE::*fillModeSetter )( FILL_T ) = &LIB_SHAPE::SetFillMode; - FILL_T ( LIB_SHAPE::*fillModeGetter )() const = &LIB_SHAPE::GetFillMode; - - propMgr.AddProperty( new PROPERTY_ENUM< LIB_SHAPE, FILL_T>( _HKI( "Fill" ), - fillModeSetter, fillModeGetter ), - _HKI( "Shape Properties" ) ); - } -} _LIB_SHAPE_DESC; - -ENUM_TO_WXANY( FILL_T ) diff --git a/eeschema/lib_shape.h b/eeschema/lib_shape.h deleted file mode 100644 index 3b6204f084..0000000000 --- a/eeschema/lib_shape.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2024 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 2 - * 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, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef LIB_SHAPE_H -#define LIB_SHAPE_H - -#include -#include - - -class LIB_SHAPE : public SCH_ITEM, public EDA_SHAPE -{ -public: - LIB_SHAPE( SCH_ITEM* aParent, SHAPE_T aShape = SHAPE_T::UNDEFINED, int aLineWidth = 0, - FILL_T aFillType = FILL_T::NO_FILL, KICAD_T aType = LIB_SHAPE_T ); - - // Do not create a copy constructor. The one generated by the compiler is adequate. - - ~LIB_SHAPE() { } - - wxString GetClass() const override - { - return wxT( "LIB_SHAPE" ); - } - - static inline bool ClassOf( const EDA_ITEM* aItem ) - { - return aItem && aItem->Type() == LIB_SHAPE_T; - } - - wxString GetFriendlyName() const override - { - return ShowShape(); - } - - STROKE_PARAMS GetStroke() const override { return m_stroke; } - void SetStroke( const STROKE_PARAMS& aStroke ) override { m_stroke = aStroke; } - - bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; - bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override; - - int GetPenWidth() const override; - - LINE_STYLE GetEffectiveLineStyle() const - { - if( m_stroke.GetLineStyle() == LINE_STYLE::DEFAULT ) - return LINE_STYLE::SOLID; - else - return m_stroke.GetLineStyle(); - } - - const BOX2I GetBoundingBox() const override; - - void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - - void BeginEdit( const VECTOR2I& aStartPoint ) override { beginEdit( aStartPoint ); } - bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); } - void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); } - - void EndEdit( bool aClosed = false ) override { endEdit( aClosed ); } - void SetEditState( int aState ) { setEditState( aState ); } - - void AddPoint( const VECTOR2I& aPosition ); - - void Move( const VECTOR2I& aOffset ) override; - - VECTOR2I GetPosition() const override { return getPosition(); } - void SetPosition( const VECTOR2I& aPosition ) override { setPosition( aPosition ); } - - VECTOR2I GetCenter() const { return getCenter(); } - - /** - * Make a set of SHAPE objects representing the LIB_SHAPE. Caller owns the objects. - * - * @param aEdgeOnly indicates only edges should be generated (even if 0 width), and no fill - * shapes. - */ - virtual std::vector MakeEffectiveShapes( bool aEdgeOnly = false ) const override - { - return makeEffectiveShapes( aEdgeOnly, true ); - } - - void Normalize(); - - void MirrorHorizontally( int aCenter ) override; - void MirrorVertically( int aCenter ) override; - void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override; - - void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, - const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override; - - void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, - int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override; - - wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override; - - BITMAPS GetMenuImage() const override; - - EDA_ITEM* Clone() const override; - - void ViewGetLayers( int aLayers[], int& aCount ) const override; - - double Similarity( const SCH_ITEM& aOther ) const override; - - bool operator==( const SCH_ITEM& aOther ) const override; - -private: - /** - * @copydoc SCH_ITEM::compare() - * - * The circle specific sort order is as follows: - * - Circle horizontal (X) position. - * - Circle vertical (Y) position. - * - Circle radius. - */ - int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override; -}; - - -#endif // LIB_SHAPE_H diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 80b6dc05b3..0219d58cfb 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include @@ -289,7 +289,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR for( auto it = m_drawings.begin(); it != m_drawings.end(); ++it ) { - if( it->Type() == LIB_SHAPE_T ) + if( it->Type() == SCH_SHAPE_T ) aShapes.insert( &(*it) ); else if( it->Type() == SCH_FIELD_T ) aFields.insert( &(*it) ); @@ -303,7 +303,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR for( auto it = aRhs.m_drawings.begin(); it != aRhs.m_drawings.end(); ++it ) { - if( it->Type() == LIB_SHAPE_T ) + if( it->Type() == SCH_SHAPE_T ) bShapes.insert( &(*it) ); else if( it->Type() == SCH_FIELD_T ) bFields.insert( &(*it) ); @@ -768,9 +768,9 @@ void LIB_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBo item.Print( aSettings, aUnit, aBodyStyle, aOffset, aForceNoFill, aDimmed ); } } - else if( item.Type() == LIB_SHAPE_T ) + else if( item.Type() == SCH_SHAPE_T ) { - LIB_SHAPE& shape = static_cast( item ); + SCH_SHAPE& shape = static_cast( item ); if( shape.GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR ) aForceNoFill = true; @@ -800,9 +800,9 @@ void LIB_SYMBOL::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUni if( item.IsPrivate() ) continue; - if( item.Type() == LIB_SHAPE_T ) + if( item.Type() == SCH_SHAPE_T ) { - LIB_SHAPE& shape = static_cast( item ); + SCH_SHAPE& shape = static_cast( item ); // Do not draw items not attached to the current part if( aUnit && shape.m_unit && ( shape.m_unit != aUnit ) ) @@ -902,14 +902,14 @@ void LIB_SYMBOL::PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT void LIB_SYMBOL::FixupDrawItems() { - std::vector potential_top_items; + std::vector potential_top_items; std::vector bottom_items; for( SCH_ITEM& item : m_drawings ) { - if( item.Type() == LIB_SHAPE_T ) + if( item.Type() == SCH_SHAPE_T ) { - LIB_SHAPE& shape = static_cast( item ); + SCH_SHAPE& shape = static_cast( item ); if( shape.GetFillMode() == FILL_T::FILLED_WITH_COLOR ) potential_top_items.push_back( &shape ); @@ -928,7 +928,7 @@ void LIB_SYMBOL::FixupDrawItems() return a->GetBoundingBox().GetArea() > b->GetBoundingBox().GetArea(); } ); - for( LIB_SHAPE* item : potential_top_items ) + for( SCH_SHAPE* item : potential_top_items ) { for( SCH_ITEM* bottom_item : bottom_items ) { diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index 00cab138eb..002d55cd5c 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -45,7 +45,7 @@ class TEST_LIB_SYMBOL_FIXTURE; typedef std::shared_ptr LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL typedef std::weak_ptr LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL -typedef MULTIVECTOR LIB_ITEMS_CONTAINER; +typedef MULTIVECTOR LIB_ITEMS_CONTAINER; typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS; diff --git a/eeschema/lib_textbox.cpp b/eeschema/lib_textbox.cpp deleted file mode 100644 index 57e1a79854..0000000000 --- a/eeschema/lib_textbox.cpp +++ /dev/null @@ -1,608 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2022-2024 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 2 - * 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, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -LIB_TEXTBOX::LIB_TEXTBOX( SCH_ITEM* aParent, int aLineWidth, FILL_T aFillType, - const wxString& text ) : - LIB_SHAPE( aParent, SHAPE_T::RECTANGLE, aLineWidth, aFillType, LIB_TEXTBOX_T ), - EDA_TEXT( schIUScale, text ) -{ - SetTextSize( VECTOR2I( schIUScale.MilsToIU( DEFAULT_TEXT_SIZE ), - schIUScale.MilsToIU( DEFAULT_TEXT_SIZE ) ) ); - SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - SetMultilineAllowed( true ); - - int defaultMargin = GetLegacyTextMargin(); - m_marginLeft = defaultMargin; - m_marginTop = defaultMargin; - m_marginRight = defaultMargin; - m_marginBottom = defaultMargin; -} - - -LIB_TEXTBOX::LIB_TEXTBOX( const LIB_TEXTBOX& aText ) : - LIB_SHAPE( aText ), - EDA_TEXT( aText ) -{ - m_marginLeft = aText.m_marginLeft; - m_marginTop = aText.m_marginTop; - m_marginRight = aText.m_marginRight; - m_marginBottom = aText.m_marginBottom; -} - - -int LIB_TEXTBOX::GetLegacyTextMargin() const -{ - return KiROUND( GetTextSize().y * 0.8 ); -} - - -void LIB_TEXTBOX::MirrorHorizontally( int aCenter ) -{ - // Text is NOT really mirrored; it just has its justification flipped - if( GetTextAngle() == ANGLE_HORIZONTAL ) - { - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - } -} - - -void LIB_TEXTBOX::MirrorVertically( int aCenter ) -{ - // Text is NOT really mirrored; it just has its justification flipped - if( GetTextAngle() == ANGLE_VERTICAL ) - { - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - } -} - - -void LIB_TEXTBOX::Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) -{ - LIB_SHAPE::Rotate( aCenter, aRotateCCW ); - SetTextAngle( GetTextAngle() == ANGLE_VERTICAL ? ANGLE_HORIZONTAL : ANGLE_VERTICAL ); -} - - -VECTOR2I LIB_TEXTBOX::GetDrawPos() const -{ - BOX2I bbox( VECTOR2I( std::min( m_start.x, m_end.x ), std::min( -m_start.y, -m_end.y ) ), - VECTOR2I( abs( m_end.x - m_start.x ), abs( m_end.y - m_start.y ) ) ); - - VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom ); - - if( GetTextAngle().IsVertical() ) - { - switch( GetHorizJustify() ) - { - case GR_TEXT_H_ALIGN_LEFT: - pos.y = bbox.GetBottom() - m_marginBottom; - break; - case GR_TEXT_H_ALIGN_CENTER: - pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2; - break; - case GR_TEXT_H_ALIGN_RIGHT: - pos.y = bbox.GetTop() + m_marginTop; - break; - case GR_TEXT_H_ALIGN_INDETERMINATE: - wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) ); - break; - } - - switch( GetVertJustify() ) - { - case GR_TEXT_V_ALIGN_TOP: - pos.x = bbox.GetLeft() + m_marginLeft; - break; - case GR_TEXT_V_ALIGN_CENTER: - pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2; - break; - case GR_TEXT_V_ALIGN_BOTTOM: - pos.x = bbox.GetRight() - m_marginRight; - break; - case GR_TEXT_V_ALIGN_INDETERMINATE: - wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) ); - break; - } - } - else - { - switch( GetHorizJustify() ) - { - case GR_TEXT_H_ALIGN_LEFT: - pos.x = bbox.GetLeft() + m_marginLeft; - break; - case GR_TEXT_H_ALIGN_CENTER: - pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2; - break; - case GR_TEXT_H_ALIGN_RIGHT: - pos.x = bbox.GetRight() - m_marginRight; - break; - case GR_TEXT_H_ALIGN_INDETERMINATE: - wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) ); - break; - } - - switch( GetVertJustify() ) - { - case GR_TEXT_V_ALIGN_TOP: - pos.y = bbox.GetTop() + m_marginTop; - break; - case GR_TEXT_V_ALIGN_CENTER: - pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2; - break; - case GR_TEXT_V_ALIGN_BOTTOM: - pos.y = bbox.GetBottom() - m_marginBottom; - break; - case GR_TEXT_V_ALIGN_INDETERMINATE: - wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) ); - break; - } - } - - return pos; -} - - -int LIB_TEXTBOX::compare( const SCH_ITEM& aOther, int aCompareFlags ) const -{ - wxASSERT( aOther.Type() == LIB_TEXTBOX_T ); - - int retv = SCH_ITEM::compare( aOther, aCompareFlags ); - - if( retv ) - return retv; - - const LIB_TEXTBOX* tmp = static_cast( &aOther ); - - int result = GetText().CmpNoCase( tmp->GetText() ); - - if( result != 0 ) - return result; - - if( GetTextWidth() != tmp->GetTextWidth() ) - return GetTextWidth() - tmp->GetTextWidth(); - - if( GetTextHeight() != tmp->GetTextHeight() ) - return GetTextHeight() - tmp->GetTextHeight(); - - if( IsBold() != tmp->IsBold() ) - return IsBold() - tmp->IsBold(); - - if( IsItalic() != tmp->IsItalic() ) - return IsItalic() - tmp->IsItalic(); - - if( GetHorizJustify() != tmp->GetHorizJustify() ) - return GetHorizJustify() - tmp->GetHorizJustify(); - - if( GetTextAngle().AsTenthsOfADegree() != tmp->GetTextAngle().AsTenthsOfADegree() ) - return GetTextAngle().AsTenthsOfADegree() - tmp->GetTextAngle().AsTenthsOfADegree(); - - if( GetMarginLeft() != tmp->GetMarginLeft() ) - return GetMarginLeft() - tmp->GetMarginLeft(); - - if( GetMarginTop() != tmp->GetMarginTop() ) - return GetMarginTop() - tmp->GetMarginTop(); - - if( GetMarginRight() != tmp->GetMarginRight() ) - return GetMarginRight() - tmp->GetMarginRight(); - - if( GetMarginBottom() != tmp->GetMarginBottom() ) - return GetMarginBottom() - tmp->GetMarginBottom(); - - return EDA_SHAPE::Compare( &static_cast( aOther ) ); -} - - -KIFONT::FONT* LIB_TEXTBOX::getDrawFont() const -{ - KIFONT::FONT* font = EDA_TEXT::GetFont(); - - if( !font ) - font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() ); - - return font; -} - - -void LIB_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, - const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) -{ - if( IsPrivate() ) - return; - - bool blackAndWhiteMode = GetGRForceBlackPenState(); - int penWidth = GetEffectivePenWidth( aSettings ); - COLOR4D color = GetStroke().GetColor(); - LINE_STYLE lineStyle = GetStroke().GetLineStyle(); - - wxDC* DC = aSettings->GetPrintDC(); - VECTOR2I pt1 = aSettings->m_Transform.TransformCoordinate( m_start ) + aOffset; - VECTOR2I pt2 = aSettings->m_Transform.TransformCoordinate( m_end ) + aOffset; - - if( !aForceNoFill && GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode ) - GRFilledRect( DC, pt1, pt2, penWidth, GetFillColor(), GetFillColor() ); - - if( penWidth > 0 ) - { - penWidth = std::max( penWidth, aSettings->GetMinPenWidth() ); - - if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED ) - color = aSettings->GetLayerColor( LAYER_DEVICE ); - - COLOR4D bg = aSettings->GetBackgroundColor(); - - if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() ) - bg = COLOR4D::WHITE; - - if( aDimmed ) - { - color.Desaturate( ); - color = color.Mix( bg, 0.5f ); - } - - if( lineStyle == LINE_STYLE::DEFAULT ) - lineStyle = LINE_STYLE::SOLID; - - if( lineStyle <= LINE_STYLE::FIRST_TYPE ) - { - GRRect( DC, pt1, pt2, penWidth, color ); - } - else - { - std::vector shapes = MakeEffectiveShapes( true ); - - for( SHAPE* shape : shapes ) - { - STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings, - [&]( const VECTOR2I& a, const VECTOR2I& b ) - { - VECTOR2I pts = aSettings->m_Transform.TransformCoordinate( a ) + aOffset; - VECTOR2I pte = aSettings->m_Transform.TransformCoordinate( b ) + aOffset; - GRLine( DC, pts.x, pts.y, pte.x, pte.y, penWidth, color ); - } ); - } - - for( SHAPE* shape : shapes ) - delete shape; - } - } - - LIB_TEXTBOX text( *this ); - - color = GetTextColor(); - - if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED ) - color = aSettings->GetLayerColor( LAYER_DEVICE ); - - COLOR4D bg = aSettings->GetBackgroundColor(); - - if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() ) - bg = COLOR4D::WHITE; - - if( aDimmed ) - { - color.Desaturate( ); - color = color.Mix( bg, 0.5f ); - } - - penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetMinPenWidth() ); - - if( aSettings->m_Transform.y1 ) - { - text.SetTextAngle( text.GetTextAngle() == ANGLE_HORIZONTAL ? ANGLE_VERTICAL - : ANGLE_HORIZONTAL ); - } - - KIFONT::FONT* font = GetFont(); - - if( !font ) - font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() ); - - // NB: GetDrawPos() will want Symbol Editor (upside-down) coordinates - text.SetStart( VECTOR2I( pt1.x, -pt1.y ) ); - text.SetEnd( VECTOR2I( pt2.x, -pt2.y ) ); - - GRPrintText( DC, text.GetDrawPos(), color, text.GetShownText( true ), text.GetTextAngle(), - text.GetTextSize(), text.GetHorizJustify(), text.GetVertJustify(), penWidth, - text.IsItalic(), text.IsBold(), font, GetFontMetrics() ); -} - - -wxString LIB_TEXTBOX::GetShownText( bool aAllowExtraText, int aDepth ) const -{ - wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth ); - - KIFONT::FONT* font = GetFont(); - VECTOR2D size = GetEnd() - GetStart(); - int colWidth; - - if( GetTextAngle().IsVertical() ) - colWidth = abs( size.y ) - ( GetMarginTop() + GetMarginBottom() ); - else - colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() ); - - if( !font ) - font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() ); - - font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() ); - - return text; -} - - -bool LIB_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const -{ - if( aAccuracy < schIUScale.MilsToIU( MINIMUM_SELECTION_DISTANCE ) ) - aAccuracy = schIUScale.MilsToIU( MINIMUM_SELECTION_DISTANCE ); - - BOX2I rect = GetBoundingBox(); - - rect.Inflate( aAccuracy ); - - return rect.Contains( aPosition ); -} - - -bool LIB_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const -{ - BOX2I rect = aRect; - - rect.Inflate( aAccuracy ); - - if( aContained ) - return rect.Contains( GetBoundingBox() ); - - return rect.Intersects( GetBoundingBox() ); -} - - -wxString LIB_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const -{ - return wxString::Format( _( "Graphic Text Box" ) ); -} - - -BITMAPS LIB_TEXTBOX::GetMenuImage() const -{ - return BITMAPS::add_textbox; -} - - -void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, - int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) -{ - wxASSERT( aPlotter != nullptr ); - - if( IsPrivate() ) - return; - - if( aBackground ) - { - LIB_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed ); - return; - } - - SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); - VECTOR2I start = renderSettings->TransformCoordinate( m_start ) + aOffset; - VECTOR2I end = renderSettings->TransformCoordinate( m_end ) + aOffset; - COLOR4D bg = renderSettings->GetBackgroundColor(); - - if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() ) - bg = COLOR4D::WHITE; - - int penWidth = GetEffectivePenWidth( renderSettings ); - COLOR4D color = GetStroke().GetColor(); - LINE_STYLE lineStyle = GetStroke().GetLineStyle(); - - if( penWidth > 0 ) - { - if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) - color = renderSettings->GetLayerColor( LAYER_DEVICE ); - - if( lineStyle == LINE_STYLE::DEFAULT ) - lineStyle = LINE_STYLE::SOLID; - - if( aDimmed ) - { - color.Desaturate( ); - color = color.Mix( bg, 0.5f ); - } - - aPlotter->SetColor( color ); - aPlotter->SetDash( penWidth, lineStyle ); - aPlotter->Rect( start, end, FILL_T::NO_FILL, penWidth ); - aPlotter->SetDash( penWidth, LINE_STYLE::SOLID ); - } - - KIFONT::FONT* font = GetFont(); - - if( !font ) - font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() ); - - LIB_TEXTBOX text( *this ); - - color = GetTextColor(); - - if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) - color = renderSettings->GetLayerColor( LAYER_DEVICE ); - - if( aDimmed ) - { - color.Desaturate( ); - color = color.Mix( bg, 0.5f ); - } - - penWidth = std::max( GetEffectiveTextPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() ); - - if( renderSettings->m_Transform.y1 ) - { - text.SetTextAngle( text.GetTextAngle() == ANGLE_HORIZONTAL ? ANGLE_VERTICAL - : ANGLE_HORIZONTAL ); - } - - // NB: GetDrawPos() will want Symbol Editor (upside-down) coordinates - text.SetStart( VECTOR2I( start.x, -start.y ) ); - text.SetEnd( VECTOR2I( end.x, -end.y ) ); - - std::vector positions; - wxArrayString strings_list; - wxStringSplit( GetShownText( true ), strings_list, '\n' ); - positions.reserve( strings_list.Count() ); - - text.GetLinePositions( positions, (int) strings_list.Count() ); - - TEXT_ATTRIBUTES attrs = text.GetAttributes(); - attrs.m_StrokeWidth = penWidth; - attrs.m_Multiline = false; - - for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) - { - aPlotter->PlotText( positions[ii], color, strings_list.Item( ii ), attrs, font, - GetFontMetrics() ); - } -} - - -void LIB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) -{ - // Don't use GetShownText() here; we want to show the user the variable references - aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) ); - - aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) ); - - wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) }; - int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0; - aList.emplace_back( _( "Style" ), textStyle[style] ); - - aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) ); - - aList.emplace_back( _( "Box Width" ), - aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) ); - - aList.emplace_back( _( "Box Height" ), - aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ) ); - - m_stroke.GetMsgPanelInfo( aFrame, aList ); -} - - -bool LIB_TEXTBOX::operator==( const SCH_ITEM& aOther ) const -{ - if( aOther.Type() != LIB_TEXTBOX_T ) - return false; - - const LIB_TEXTBOX& other = static_cast( aOther ); - - return LIB_SHAPE::operator==( other ) && EDA_TEXT::operator==( other ); -} - - -double LIB_TEXTBOX::Similarity( const SCH_ITEM& aOther ) const -{ - if( m_Uuid == aOther.m_Uuid ) - return 1.0; - - if( aOther.Type() != LIB_TEXTBOX_T ) - return 0.0; - - const LIB_TEXTBOX& other = static_cast( aOther ); - - double similarity = SimilarityBase( other ); - similarity *= LIB_SHAPE::Similarity( other ); - similarity *= EDA_TEXT::Similarity( other ); - - return similarity; -} - - -void LIB_TEXTBOX::ViewGetLayers( int aLayers[], int& aCount ) const -{ - aCount = 3; - aLayers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : LAYER_DEVICE; - aLayers[1] = IsPrivate() ? LAYER_NOTES_BACKGROUND : LAYER_DEVICE_BACKGROUND; - aLayers[2] = LAYER_SELECTION_SHADOWS; -} - - -static struct LIB_TEXTBOX_DESC -{ - LIB_TEXTBOX_DESC() - { - PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); - REGISTER_TYPE( LIB_TEXTBOX ); - - propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.InheritsAfter( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( LIB_SHAPE ) ); - propMgr.InheritsAfter( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ) ); - propMgr.InheritsAfter( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ) ); - - propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) ); - - propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) ); - propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) ); - propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) ); - propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) ); - - propMgr.AddProperty( new PROPERTY( _HKI( "Margin Left" ), - &LIB_TEXTBOX::SetMarginLeft, &LIB_TEXTBOX::GetMarginLeft, PROPERTY_DISPLAY::PT_SIZE ) ); - propMgr.AddProperty( new PROPERTY( _HKI( "Margin Top" ), - &LIB_TEXTBOX::SetMarginTop, &LIB_TEXTBOX::GetMarginTop, PROPERTY_DISPLAY::PT_SIZE ) ); - propMgr.AddProperty( new PROPERTY( _HKI( "Margin Right" ), - &LIB_TEXTBOX::SetMarginRight, &LIB_TEXTBOX::GetMarginRight, PROPERTY_DISPLAY::PT_SIZE ) ); - propMgr.AddProperty( new PROPERTY( _HKI( "Margin Bottom" ), - &LIB_TEXTBOX::SetMarginBottom, &LIB_TEXTBOX::GetMarginBottom, PROPERTY_DISPLAY::PT_SIZE ) ); - - propMgr.AddProperty( new PROPERTY( _HKI( "Text Size" ), - &LIB_TEXTBOX::SetLibTextSize, &LIB_TEXTBOX::GetLibTextSize, PROPERTY_DISPLAY::PT_SIZE ), - _HKI( "Text Properties" ) ); - - propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) ); - } -} _LIB_TEXTBOX_DESC; diff --git a/eeschema/lib_textbox.h b/eeschema/lib_textbox.h deleted file mode 100644 index 327ee5fe95..0000000000 --- a/eeschema/lib_textbox.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2022-2024 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 2 - * 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, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef LIB_TEXTBOX_H -#define LIB_TEXTBOX_H - - -#include -#include - - -class HTML_MESSAGE_BOX; - -class LIB_TEXTBOX : public LIB_SHAPE, public EDA_TEXT -{ -public: - LIB_TEXTBOX( SCH_ITEM* aParent, int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL, - const wxString& aText = wxEmptyString ); - - LIB_TEXTBOX( const LIB_TEXTBOX& aText ); - - ~LIB_TEXTBOX() { } - - static inline bool ClassOf( const EDA_ITEM* aItem ) - { - return aItem && aItem->Type() == LIB_TEXTBOX_T; - } - - virtual wxString GetClass() const override - { - return wxT( "LIB_TEXTBOX" ); - } - - int GetLegacyTextMargin() const; - - void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; } - void SetMarginTop( int aTop ) { m_marginTop = aTop; } - void SetMarginRight( int aRight ) { m_marginRight = aRight; } - void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; } - - int GetMarginLeft() const { return m_marginLeft; } - int GetMarginTop() const { return m_marginTop; } - int GetMarginRight() const { return m_marginRight; } - int GetMarginBottom() const { return m_marginBottom; } - - int GetLibTextSize() const { return GetTextWidth(); } - void SetLibTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); } - - VECTOR2I GetDrawPos() const override; - - wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override; - - void MirrorHorizontally( int aCenter ) override; - void MirrorVertically( int aCenter ) override; - void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override; - - bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; - - bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override; - - bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override - { - return SCH_ITEM::Matches( GetText(), aSearchData ); - } - - bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override - { - return EDA_TEXT::Replace( aSearchData ); - } - - virtual bool IsReplaceable() const override { return true; } - - wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override; - - BITMAPS GetMenuImage() const override; - - void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, - const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override; - - void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, - int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override; - - EDA_ITEM* Clone() const override - { - return new LIB_TEXTBOX( *this ); - } - - void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - - void ViewGetLayers( int aLayers[], int& aCount ) const override; - - double Similarity( const SCH_ITEM& aOther ) const override; - - bool operator==( const SCH_ITEM& aOther ) const override; - -protected: - KIFONT::FONT* getDrawFont() const override; - -private: - int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override; - -private: - int m_marginLeft; - int m_marginTop; - int m_marginRight; - int m_marginBottom; -}; - - -#endif /* LIB_TEXTBOX_H */ diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index c2c652c7c1..c7855897b6 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -3,7 +3,7 @@ * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2022 CERN - * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2024 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 @@ -95,7 +95,7 @@ public: wxString GetFriendlyName() const override { - return _( "Field" ); + return _( "Field" ); } bool IsHypertext() const override diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp index bf3a36b00b..86520d405a 100644 --- a/eeschema/sch_io/altium/sch_io_altium.cpp +++ b/eeschema/sch_io/altium/sch_io_altium.cpp @@ -25,7 +25,6 @@ #include #include "altium_parser_sch.h" -#include "sch_shape.h" #include #include #include @@ -37,16 +36,15 @@ #include #include -#include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -135,7 +133,7 @@ static void SetSchShapeFillAndColor( const ASCH_FILL_INTERFACE& elem, SCH_SHAPE* } -static void SetLibShapeLine( const ASCH_BORDER_INTERFACE& elem, LIB_SHAPE* shape, +static void SetLibShapeLine( const ASCH_BORDER_INTERFACE& elem, SCH_SHAPE* shape, ALTIUM_SCH_RECORD aType ) { COLOR4D color = GetColorFromInt( elem.Color ); @@ -165,7 +163,7 @@ static void SetLibShapeLine( const ASCH_BORDER_INTERFACE& elem, LIB_SHAPE* shape shape->SetStroke( STROKE_PARAMS( elem.LineWidth, LINE_STYLE::SOLID, color ) ); } -static void SetLibShapeFillAndColor( const ASCH_FILL_INTERFACE& elem, LIB_SHAPE* shape, +static void SetLibShapeFillAndColor( const ASCH_FILL_INTERFACE& elem, SCH_SHAPE* shape, ALTIUM_SCH_RECORD aType, int aStrokeColor ) { COLOR4D bgcolor = GetColorFromInt( elem.AreaColor ); @@ -215,7 +213,8 @@ static void SetLibShapeFillAndColor( const ASCH_FILL_INTERFACE& elem, LIB_SHAPE* } -SCH_IO_ALTIUM::SCH_IO_ALTIUM() : SCH_IO( wxS( "Altium" ) ) +SCH_IO_ALTIUM::SCH_IO_ALTIUM() : + SCH_IO( wxS( "Altium" ) ) { m_isIntLib = false; m_rootSheet = nullptr; @@ -1661,10 +1660,9 @@ void SCH_IO_ALTIUM::AddLibTextBox( const ASCH_TEXT_FRAME *aElem, std::vectorfirst ); } - LIB_TEXTBOX* textBox = new LIB_TEXTBOX( symbol ); + SCH_TEXTBOX* textBox = new SCH_TEXTBOX( LAYER_DEVICE ); textBox->SetUnit( std::max( 0, aElem->ownerpartid ) ); - symbol->AddDrawItem( textBox, false ); /// Handle text frames that are in a library symbol, not on schematic @@ -1808,7 +1806,7 @@ void SCH_IO_ALTIUM::ParseBezier( const std::map& aProperties if( i + 2 == elem.points.size() ) { // special case: single line - LIB_SHAPE* line = new LIB_SHAPE( symbol, SHAPE_T::POLY ); + SCH_SHAPE* line = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); symbol->AddDrawItem( line, false ); line->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -1830,7 +1828,7 @@ void SCH_IO_ALTIUM::ParseBezier( const std::map& aProperties // I haven't a clue what this is all about, but the sample document we have in // https://gitlab.com/kicad/code/kicad/-/issues/8974 responds best by treating it // as another single line special case. - LIB_SHAPE* line = new LIB_SHAPE( symbol, SHAPE_T::POLY ); + SCH_SHAPE* line = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); symbol->AddDrawItem( line, false ); line->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -1849,7 +1847,7 @@ void SCH_IO_ALTIUM::ParseBezier( const std::map& aProperties else { // Bezier always has exactly 4 control points - LIB_SHAPE* bezier = new LIB_SHAPE( symbol, SHAPE_T::BEZIER ); + SCH_SHAPE* bezier = new SCH_SHAPE( SHAPE_T::BEZIER, LAYER_DEVICE ); symbol->AddDrawItem( bezier, false ); bezier->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -1935,7 +1933,7 @@ void SCH_IO_ALTIUM::ParsePolyline( const std::map& aProperti if( aSymbol.empty() && !IsComponentPartVisible( elem ) ) return; - LIB_SHAPE* line = new LIB_SHAPE( symbol, SHAPE_T::POLY ); + SCH_SHAPE* line = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); symbol->AddDrawItem( line, false ); line->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -2006,7 +2004,7 @@ void SCH_IO_ALTIUM::ParsePolygon( const std::map& aPropertie if( aSymbol.empty() && !IsComponentPartVisible( elem ) ) return; - LIB_SHAPE* line = new LIB_SHAPE( symbol, SHAPE_T::POLY ); + SCH_SHAPE* line = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); symbol->AddDrawItem( line, false ); line->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -2087,7 +2085,7 @@ void SCH_IO_ALTIUM::ParseRoundRectangle( const std::map& aPr if( aSymbol.empty() && !IsComponentPartVisible( elem ) ) return; - LIB_SHAPE* rect = nullptr; + SCH_SHAPE* rect = nullptr; int width = std::abs( elem.TopRight.x - elem.BottomLeft.x ); int height = std::abs( elem.TopRight.y - elem.BottomLeft.y ); @@ -2096,7 +2094,7 @@ void SCH_IO_ALTIUM::ParseRoundRectangle( const std::map& aPr if( std::abs( elem.CornerRadius.x ) >= width / 2 && std::abs( elem.CornerRadius.y ) >= height / 2 ) { - rect = new LIB_SHAPE( symbol, SHAPE_T::CIRCLE ); + rect = new SCH_SHAPE( SHAPE_T::CIRCLE, LAYER_DEVICE ); VECTOR2I center = ( elem.TopRight + elem.BottomLeft ) / 2; int radius = std::min( width / 2, height / 2 ); @@ -2110,7 +2108,7 @@ void SCH_IO_ALTIUM::ParseRoundRectangle( const std::map& aPr } else { - rect = new LIB_SHAPE( symbol, SHAPE_T::RECTANGLE ); + rect = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ); if( !schsym ) { @@ -2205,7 +2203,7 @@ void SCH_IO_ALTIUM::ParseArc( const std::map& aProperties, if( elem.m_StartAngle == 0 && ( elem.m_EndAngle == 0 || elem.m_EndAngle == 360 ) ) { - LIB_SHAPE* circle = new LIB_SHAPE( symbol, SHAPE_T::CIRCLE ); + SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE, LAYER_DEVICE ); symbol->AddDrawItem( circle, false ); circle->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -2220,7 +2218,7 @@ void SCH_IO_ALTIUM::ParseArc( const std::map& aProperties, } else { - LIB_SHAPE* arc = new LIB_SHAPE( symbol, SHAPE_T::ARC ); + SCH_SHAPE* arc = new SCH_SHAPE( SHAPE_T::ARC, LAYER_DEVICE ); symbol->AddDrawItem( arc, false ); arc->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -2317,7 +2315,7 @@ void SCH_IO_ALTIUM::ParseEllipticalArc( const std::map& aPro for( const BEZIER& bezier : beziers ) { - LIB_SHAPE* schbezier = new LIB_SHAPE( symbol, SHAPE_T::BEZIER ); + SCH_SHAPE* schbezier = new SCH_SHAPE( SHAPE_T::BEZIER, LAYER_DEVICE ); symbol->AddDrawItem( schbezier, false ); schbezier->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -2441,7 +2439,7 @@ void SCH_IO_ALTIUM::ParseEllipse( const std::map& aPropertie for( const BEZIER& bezier : beziers ) { - LIB_SHAPE* libbezier = new LIB_SHAPE( symbol, SHAPE_T::BEZIER ); + SCH_SHAPE* libbezier = new SCH_SHAPE( SHAPE_T::BEZIER, LAYER_DEVICE ); symbol->AddDrawItem( libbezier, false ); libbezier->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -2471,7 +2469,7 @@ void SCH_IO_ALTIUM::ParseEllipse( const std::map& aPropertie // Add a polygon to fill the center if( elem.IsSolid ) { - LIB_SHAPE* libline = new LIB_SHAPE( symbol, SHAPE_T::POLY ); + SCH_SHAPE* libline = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); symbol->AddDrawItem( libline, false ); libline->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -2536,7 +2534,7 @@ void SCH_IO_ALTIUM::ParseCircle( const std::map& aProperties schsym = m_symbols.at( libSymbolIt->first ); } - LIB_SHAPE* circle = new LIB_SHAPE( symbol, SHAPE_T::CIRCLE ); + SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE, LAYER_DEVICE ); symbol->AddDrawItem( circle, false ); circle->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -2601,7 +2599,7 @@ void SCH_IO_ALTIUM::ParseLine( const std::map& aProperties, if( aSymbol.empty() && !IsComponentPartVisible( elem ) ) return; - LIB_SHAPE* line = new LIB_SHAPE( symbol, SHAPE_T::POLY ); + SCH_SHAPE* line = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); symbol->AddDrawItem( line, false ); line->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -2836,7 +2834,7 @@ void SCH_IO_ALTIUM::ParseRectangle( const std::map& aPropert if( aSymbol.empty() && !IsComponentPartVisible( elem ) ) return; - LIB_SHAPE* rect = new LIB_SHAPE( symbol, SHAPE_T::RECTANGLE ); + SCH_SHAPE* rect = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ); symbol->AddDrawItem( rect, false ); rect->SetUnit( std::max( 0, elem.ownerpartid ) ); @@ -2976,7 +2974,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ { if( aStyle == ASCH_POWER_PORT_STYLE::CIRCLE || aStyle == ASCH_POWER_PORT_STYLE::ARROW ) { - LIB_SHAPE* line1 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line1 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line1, false ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->AddPoint( { 0, 0 } ); @@ -2984,7 +2982,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ if( aStyle == ASCH_POWER_PORT_STYLE::CIRCLE ) { - LIB_SHAPE* circle = new LIB_SHAPE( aKsymbol, SHAPE_T::CIRCLE ); + SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE, LAYER_DEVICE ); aKsymbol->AddDrawItem( circle, false ); circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) ); circle->SetPosition( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -75 ) } ); @@ -2992,7 +2990,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ } else { - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2, false ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -25 ), schIUScale.MilsToIU( -50 ) } ); @@ -3005,13 +3003,13 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ } else if( aStyle == ASCH_POWER_PORT_STYLE::WAVE ) { - LIB_SHAPE* line = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line, false ); line->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line->AddPoint( { 0, 0 } ); line->AddPoint( { 0, schIUScale.MilsToIU( -72 ) } ); - LIB_SHAPE* bezier = new LIB_SHAPE( aKsymbol, SHAPE_T::BEZIER ); + SCH_SHAPE* bezier = new SCH_SHAPE( SHAPE_T::BEZIER, LAYER_DEVICE ); aKsymbol->AddDrawItem( bezier, false ); bezier->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) ); bezier->SetStart( { schIUScale.MilsToIU( 30 ), schIUScale.MilsToIU( -50 ) } ); @@ -3026,7 +3024,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ || aStyle == ASCH_POWER_PORT_STYLE::EARTH || aStyle == ASCH_POWER_PORT_STYLE::GOST_ARROW ) { - LIB_SHAPE* line1 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line1 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line1, false ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->AddPoint( { 0, 0 } ); @@ -3034,25 +3032,25 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ if( aStyle == ASCH_POWER_PORT_STYLE::POWER_GROUND ) { - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2, false ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -100 ) } ); line2->AddPoint( { schIUScale.MilsToIU( 100 ), schIUScale.MilsToIU( -100 ) } ); - LIB_SHAPE* line3 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line3 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line3, false ); line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line3->AddPoint( { schIUScale.MilsToIU( -70 ), schIUScale.MilsToIU( -130 ) } ); line3->AddPoint( { schIUScale.MilsToIU( 70 ), schIUScale.MilsToIU( -130 ) } ); - LIB_SHAPE* line4 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line4 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line4, false ); line4->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line4->AddPoint( { schIUScale.MilsToIU( -40 ), schIUScale.MilsToIU( -160 ) } ); line4->AddPoint( { schIUScale.MilsToIU( 40 ), schIUScale.MilsToIU( -160 ) } ); - LIB_SHAPE* line5 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line5 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line5, false ); line5->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line5->AddPoint( { schIUScale.MilsToIU( -10 ), schIUScale.MilsToIU( -190 ) } ); @@ -3060,7 +3058,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ } else if( aStyle == ASCH_POWER_PORT_STYLE::SIGNAL_GROUND ) { - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2, false ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -100 ) } ); @@ -3070,7 +3068,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ } else if( aStyle == ASCH_POWER_PORT_STYLE::EARTH ) { - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2, false ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -150 ), schIUScale.MilsToIU( -200 ) } ); @@ -3078,7 +3076,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ line2->AddPoint( { schIUScale.MilsToIU( 100 ), schIUScale.MilsToIU( -100 ) } ); line2->AddPoint( { schIUScale.MilsToIU( 50 ), schIUScale.MilsToIU( -200 ) } ); - LIB_SHAPE* line3 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line3 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line3, false ); line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line3->AddPoint( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -100 ) } ); @@ -3086,7 +3084,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ } else // ASCH_POWER_PORT_STYLE::GOST_ARROW { - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2, false ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -25 ), schIUScale.MilsToIU( -50 ) } ); @@ -3101,25 +3099,25 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ else if( aStyle == ASCH_POWER_PORT_STYLE::GOST_POWER_GROUND || aStyle == ASCH_POWER_PORT_STYLE::GOST_EARTH ) { - LIB_SHAPE* line1 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line1 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line1, false ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, schIUScale.MilsToIU( -160 ) } ); - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2, false ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -160 ) } ); line2->AddPoint( { schIUScale.MilsToIU( 100 ), schIUScale.MilsToIU( -160 ) } ); - LIB_SHAPE* line3 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line3 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line3, false ); line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line3->AddPoint( { schIUScale.MilsToIU( -60 ), schIUScale.MilsToIU( -200 ) } ); line3->AddPoint( { schIUScale.MilsToIU( 60 ), schIUScale.MilsToIU( -200 ) } ); - LIB_SHAPE* line4 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line4 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line4, false ); line4->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line4->AddPoint( { schIUScale.MilsToIU( -20 ), schIUScale.MilsToIU( -240 ) } ); @@ -3128,7 +3126,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ if( aStyle == ASCH_POWER_PORT_STYLE::GOST_POWER_GROUND ) return { 0, schIUScale.MilsToIU( 300 ) }; - LIB_SHAPE* circle = new LIB_SHAPE( aKsymbol, SHAPE_T::CIRCLE ); + SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE, LAYER_DEVICE ); aKsymbol->AddDrawItem( circle, false ); circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); circle->SetPosition( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -160 ) } ); @@ -3138,13 +3136,13 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ } else if( aStyle == ASCH_POWER_PORT_STYLE::GOST_BAR ) { - LIB_SHAPE* line1 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line1 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line1, false ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, schIUScale.MilsToIU( -200 ) } ); - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2, false ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -200 ) } ); @@ -3160,13 +3158,13 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_ RPT_SEVERITY_WARNING ); } - LIB_SHAPE* line1 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line1 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line1, false ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, schIUScale.MilsToIU( -100 ) } ); - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2, false ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -50 ), schIUScale.MilsToIU( -100 ) } ); diff --git a/eeschema/sch_io/altium/sch_io_altium.h b/eeschema/sch_io/altium/sch_io_altium.h index 956c3daec5..5b076f01e6 100644 --- a/eeschema/sch_io/altium/sch_io_altium.h +++ b/eeschema/sch_io/altium/sch_io_altium.h @@ -26,6 +26,7 @@ #define _SCH_IO_ALTIUM_H_ #include +#include #include #include #include diff --git a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp index 206c1816d0..d37d586851 100644 --- a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -1621,7 +1620,8 @@ const LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef( const SYMDEF_ID& aSymd } else { - LIB_SHAPE* shape = new LIB_SHAPE( kiSym.get(), SHAPE_T::POLY ); + SCH_SHAPE* shape = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); + shape->SetPolyShape( fig.Shape.ConvertToPolySet( [&]( const VECTOR2I& aPt ) { @@ -1989,7 +1989,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices( const std::vect { cur = &aCadstarVertices.at( i ); - LIB_SHAPE* shape = nullptr; + SCH_SHAPE* shape = nullptr; bool cw = false; VECTOR2I startPoint = getKiCadLibraryPoint( prev->End, aSymbolOrigin ); VECTOR2I endPoint = getKiCadLibraryPoint( cur->End, aSymbolOrigin ); @@ -2009,7 +2009,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices( const std::vect switch( cur->Type ) { case VERTEX_TYPE::POINT: - shape = new LIB_SHAPE( aSymbol, SHAPE_T::POLY ); + shape = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); shape->AddPoint( startPoint ); shape->AddPoint( endPoint ); break; @@ -2021,7 +2021,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices( const std::vect case VERTEX_TYPE::ANTICLOCKWISE_SEMICIRCLE: case VERTEX_TYPE::ANTICLOCKWISE_ARC: - shape = new LIB_SHAPE( aSymbol, SHAPE_T::ARC ); + shape = new SCH_SHAPE( SHAPE_T::ARC, LAYER_DEVICE ); shape->SetPosition( centerPoint ); @@ -2374,11 +2374,11 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadShapeVertices( const std::vector& a "First vertex should always be a point vertex" ); auto pointTransform = - [&]( const VECTOR2I& aV ) - { - return applyTransform( getKiCadPoint( aV ), aMoveVector, aRotation, - aScalingFactor, aTransformCentre, aMirrorInvert ); - }; + [&]( const VECTOR2I& aV ) + { + return applyTransform( getKiCadPoint( aV ), aMoveVector, aRotation, + aScalingFactor, aTransformCentre, aMirrorInvert ); + }; for( size_t ii = 1; ii < aCadstarVertices.size(); ii++ ) { @@ -2396,12 +2396,12 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadShapeVertices( const std::vector& a { SHAPE_ARC tempArc = cur->BuildArc( transformedStartPoint, pointTransform ); - SCH_SHAPE* arcShape = new SCH_SHAPE( SHAPE_T::ARC, lineWidth ); + SCH_SHAPE* arcShape = new SCH_SHAPE( SHAPE_T::ARC, LAYER_NOTES, lineWidth ); arcShape->SetArcGeometry( tempArc.GetP0(), tempArc.GetArcMid(), tempArc.GetP1() ); loadItemOntoKiCadSheet( aCadstarSheetID, arcShape ); - } break; + } case VERTEX_TYPE::POINT: { @@ -2415,14 +2415,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadShapeVertices( const std::vector& a segment->SetEndPoint( transformedEndPoint ); loadItemOntoKiCadSheet( aCadstarSheetID, segment ); - } break; + } default: wxFAIL_MSG( "Unknown CADSTAR Vertex type" ); } - prev = cur; } } @@ -3209,9 +3208,9 @@ LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart( const LIB_SYMBOL* aSym { switch( item.Type() ) { - case KICAD_T::LIB_SHAPE_T: + case KICAD_T::SCH_SHAPE_T: { - LIB_SHAPE& shape = static_cast( item ); + SCH_SHAPE& shape = static_cast( item ); if( shape.GetShape() == SHAPE_T::ARC ) { @@ -3268,11 +3267,11 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int // Note: Need the custom comparison function to ensure the map is sorted correctly std::map uniqueSegments( compLambda ); - LIB_ITEMS_CONTAINER::ITERATOR shapeIt = aSymbolToFix->GetDrawItems().begin( LIB_SHAPE_T ); + LIB_ITEMS_CONTAINER::ITERATOR shapeIt = aSymbolToFix->GetDrawItems().begin( SCH_SHAPE_T ); - for( ; shapeIt != aSymbolToFix->GetDrawItems().end( LIB_SHAPE_T ); ++shapeIt ) + for( ; shapeIt != aSymbolToFix->GetDrawItems().end( SCH_SHAPE_T ); ++shapeIt ) { - LIB_SHAPE& shape = static_cast( *shapeIt ); + SCH_SHAPE& shape = static_cast( *shapeIt ); if( aGateNumber > 0 && shape.GetUnit() != aGateNumber ) continue; diff --git a/eeschema/sch_io/eagle/sch_io_eagle.cpp b/eeschema/sch_io/eagle/sch_io_eagle.cpp index a97d74717b..5fdc4649ef 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.cpp +++ b/eeschema/sch_io/eagle/sch_io_eagle.cpp @@ -36,11 +36,8 @@ #include #include -#include #include #include -#include -#include #include #include #include @@ -2151,7 +2148,7 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptrAddDrawItem( loadSymbolCircle( aSymbol, currentNode, aGateNumber ) ); + aSymbol->AddDrawItem( loadSymbolCircle( currentNode, aGateNumber ) ); } else if( nodeName == wxT( "pin" ) ) { @@ -2215,11 +2212,11 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptrAddDrawItem( loadSymbolPolyLine( aSymbol, currentNode, aGateNumber ) ); + aSymbol->AddDrawItem( loadSymbolPolyLine( currentNode, aGateNumber ) ); } else if( nodeName == wxT( "rectangle" ) ) { - aSymbol->AddDrawItem( loadSymbolRectangle( aSymbol, currentNode, aGateNumber ) ); + aSymbol->AddDrawItem( loadSymbolRectangle( currentNode, aGateNumber ) ); } else if( nodeName == wxT( "text" ) ) { @@ -2250,7 +2247,7 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptrAddDrawItem( loadSymbolWire( aSymbol, currentNode, aGateNumber ) ); + aSymbol->AddDrawItem( loadSymbolWire( currentNode, aGateNumber ) ); } else if( nodeName == wxT( "frame" ) ) { @@ -2288,12 +2285,11 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr& aSymbol, - wxXmlNode* aCircleNode, int aGateNumber ) +SCH_SHAPE* SCH_IO_EAGLE::loadSymbolCircle( wxXmlNode* aCircleNode, int aGateNumber ) { // Parse the circle properties ECIRCLE c( aCircleNode ); - LIB_SHAPE* circle = new LIB_SHAPE( aSymbol.get(), SHAPE_T::CIRCLE ); + SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE, LAYER_DEVICE ); VECTOR2I center( c.x.ToSchUnits(), c.y.ToSchUnits() ); circle->SetPosition( center ); @@ -2305,11 +2301,10 @@ LIB_SHAPE* SCH_IO_EAGLE::loadSymbolCircle( std::unique_ptr& aSymbol, } -LIB_SHAPE* SCH_IO_EAGLE::loadSymbolRectangle( std::unique_ptr& aSymbol, - wxXmlNode* aRectNode, int aGateNumber ) +SCH_SHAPE* SCH_IO_EAGLE::loadSymbolRectangle( wxXmlNode* aRectNode, int aGateNumber ) { ERECT rect( aRectNode ); - LIB_SHAPE* rectangle = new LIB_SHAPE( aSymbol.get(), SHAPE_T::RECTANGLE ); + SCH_SHAPE* rectangle = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ); rectangle->SetPosition( VECTOR2I( rect.x1.ToSchUnits(), rect.y1.ToSchUnits() ) ); rectangle->SetEnd( VECTOR2I( rect.x2.ToSchUnits(), rect.y2.ToSchUnits() ) ); @@ -2336,8 +2331,7 @@ LIB_SHAPE* SCH_IO_EAGLE::loadSymbolRectangle( std::unique_ptr& aSymb } -SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr& aSymbol, - wxXmlNode* aWireNode, int aGateNumber ) +SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( wxXmlNode* aWireNode, int aGateNumber ) { EWIRE ewire = EWIRE( aWireNode ); @@ -2354,7 +2348,7 @@ SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr& aSymbol, // if the wire is an arc if( ewire.curve ) { - LIB_SHAPE* arc = new LIB_SHAPE( aSymbol.get(), SHAPE_T::ARC ); + SCH_SHAPE* arc = new SCH_SHAPE( SHAPE_T::ARC, LAYER_DEVICE ); VECTOR2I center = ConvertArcCenter( begin, end, *ewire.curve * -1 ); double radius = sqrt( ( ( center.x - begin.x ) * ( center.x - begin.x ) ) + ( ( center.y - begin.y ) * ( center.y - begin.y ) ) ); @@ -2382,7 +2376,7 @@ SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr& aSymbol, } else { - LIB_SHAPE* poly = new LIB_SHAPE( aSymbol.get(), SHAPE_T::POLY ); + SCH_SHAPE* poly = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); poly->AddPoint( begin ); poly->AddPoint( end ); @@ -2394,10 +2388,9 @@ SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr& aSymbol, } -LIB_SHAPE* SCH_IO_EAGLE::loadSymbolPolyLine( std::unique_ptr& aSymbol, - wxXmlNode* aPolygonNode, int aGateNumber ) +SCH_SHAPE* SCH_IO_EAGLE::loadSymbolPolyLine( wxXmlNode* aPolygonNode, int aGateNumber ) { - LIB_SHAPE* poly = new LIB_SHAPE( aSymbol.get(), SHAPE_T::POLY ); + SCH_SHAPE* poly = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); EPOLYGON epoly( aPolygonNode ); wxXmlNode* vertex = aPolygonNode->GetChildren(); VECTOR2I pt, prev_pt; @@ -2559,7 +2552,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector yMax ) std::swap( yMin, yMax ); - LIB_SHAPE* lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY ); + SCH_SHAPE* lines = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); lines->AddPoint( VECTOR2I( xMin, yMin ) ); lines->AddPoint( VECTOR2I( xMax, yMin ) ); lines->AddPoint( VECTOR2I( xMax, yMax ) ); @@ -2569,7 +2562,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorAddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ), yMin + schIUScale.MilsToIU( 150 ) ) ); lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ), @@ -2587,7 +2580,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorAddPoint( VECTOR2I( x1, newY ) ); lines->AddPoint( VECTOR2I( x2, newY ) ); aItems.push_back( lines ); @@ -2609,7 +2602,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorAddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ), yMin + schIUScale.MilsToIU( 150 ) ) ); lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ), @@ -2627,7 +2620,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorAddPoint( VECTOR2I( x1, newY ) ); lines->AddPoint( VECTOR2I( x2, newY ) ); aItems.push_back( lines ); @@ -2649,7 +2642,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorAddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ), yMax - schIUScale.MilsToIU( 150 ) ) ); lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ), @@ -2667,7 +2660,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorAddPoint( VECTOR2I( newX, y1 ) ); lines->AddPoint( VECTOR2I( newX, y2 ) ); aItems.push_back( lines ); @@ -2689,7 +2682,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorAddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ), yMin + schIUScale.MilsToIU( 150 ) ) ); lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ), @@ -2707,7 +2700,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorAddPoint( VECTOR2I( newX, y1 ) ); lines->AddPoint( VECTOR2I( newX, y2 ) ); aItems.push_back( lines ); diff --git a/eeschema/sch_io/eagle/sch_io_eagle.h b/eeschema/sch_io/eagle/sch_io_eagle.h index 3f6d090fa2..286c1a1b25 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.h +++ b/eeschema/sch_io/eagle/sch_io_eagle.h @@ -51,11 +51,7 @@ class SCH_FIELD; class STRING_UTF8_MAP; class LIB_SYMBOL; class SYMBOL_LIB; -class LIB_SHAPE; -class LIB_RECTANGLE; -class LIB_POLYLINE; class LIB_PIN; -class LIB_TEXT; class wxXmlNode; @@ -156,14 +152,10 @@ private: bool loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr& aSymbol, EDEVICE* aDevice, int aGateNumber, const wxString& aGateName ); - LIB_SHAPE* loadSymbolCircle( std::unique_ptr& aSymbol, wxXmlNode* aCircleNode, - int aGateNumber ); - LIB_SHAPE* loadSymbolRectangle( std::unique_ptr& aSymbol, wxXmlNode* aRectNode, - int aGateNumber ); - LIB_SHAPE* loadSymbolPolyLine( std::unique_ptr& aSymbol, - wxXmlNode* aPolygonNode, int aGateNumber ); - SCH_ITEM* loadSymbolWire( std::unique_ptr& aSymbol, wxXmlNode* aWireNode, - int aGateNumber ); + SCH_SHAPE* loadSymbolCircle( wxXmlNode* aCircleNode, int aGateNumber ); + SCH_SHAPE* loadSymbolRectangle( wxXmlNode* aRectNode, int aGateNumber ); + SCH_SHAPE* loadSymbolPolyLine( wxXmlNode* aPolygonNode, int aGateNumber ); + SCH_ITEM* loadSymbolWire( wxXmlNode* aWireNode, int aGateNumber ); LIB_PIN* loadPin( std::unique_ptr& aSymbol, wxXmlNode*, EPIN* epin, int aGateNumber ); SCH_TEXT* loadSymbolText( wxXmlNode* aLibText, int aGateNumber ); diff --git a/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp b/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp index 19ff2bfa59..62b00c4155 100644 --- a/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp +++ b/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp @@ -27,20 +27,16 @@ #include #include #include -#include #include -#include #include #include #include #include #include #include -#include #include #include #include -#include #include #include #include @@ -179,7 +175,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F { if( aStyle == EASYEDA::POWER_FLAG_STYLE::CIRCLE || aStyle == EASYEDA::POWER_FLAG_STYLE::ARROW ) { - LIB_SHAPE* line1 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line1 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line1 ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->AddPoint( { 0, 0 } ); @@ -187,7 +183,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F if( aStyle == EASYEDA::POWER_FLAG_STYLE::CIRCLE ) { - LIB_SHAPE* circle = new LIB_SHAPE( aKsymbol, SHAPE_T::CIRCLE ); + SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE, LAYER_DEVICE ); aKsymbol->AddDrawItem( circle ); circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) ); circle->SetPosition( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -75 ) } ); @@ -195,7 +191,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F } else { - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2 ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -25 ), schIUScale.MilsToIU( -50 ) } ); @@ -208,13 +204,13 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F } else if( aStyle == EASYEDA::POWER_FLAG_STYLE::WAVE ) { - LIB_SHAPE* line = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line ); line->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line->AddPoint( { 0, 0 } ); line->AddPoint( { 0, schIUScale.MilsToIU( -72 ) } ); - LIB_SHAPE* bezier = new LIB_SHAPE( aKsymbol, SHAPE_T::BEZIER ); + SCH_SHAPE* bezier = new SCH_SHAPE( SHAPE_T::BEZIER, LAYER_DEVICE ); aKsymbol->AddDrawItem( bezier ); bezier->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) ); bezier->AddPoint( { schIUScale.MilsToIU( 30 ), schIUScale.MilsToIU( -50 ) } ); @@ -229,7 +225,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F || aStyle == EASYEDA::POWER_FLAG_STYLE::EARTH || aStyle == EASYEDA::POWER_FLAG_STYLE::GOST_ARROW ) { - LIB_SHAPE* line1 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line1 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line1 ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->AddPoint( { 0, 0 } ); @@ -237,25 +233,25 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F if( aStyle == EASYEDA::POWER_FLAG_STYLE::POWER_GROUND ) { - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2 ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -100 ) } ); line2->AddPoint( { schIUScale.MilsToIU( 100 ), schIUScale.MilsToIU( -100 ) } ); - LIB_SHAPE* line3 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line3 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line3 ); line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line3->AddPoint( { schIUScale.MilsToIU( -70 ), schIUScale.MilsToIU( -120 ) } ); line3->AddPoint( { schIUScale.MilsToIU( 70 ), schIUScale.MilsToIU( -120 ) } ); - LIB_SHAPE* line4 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line4 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line4 ); line4->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line4->AddPoint( { schIUScale.MilsToIU( -40 ), schIUScale.MilsToIU( -140 ) } ); line4->AddPoint( { schIUScale.MilsToIU( 40 ), schIUScale.MilsToIU( -140 ) } ); - LIB_SHAPE* line5 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line5 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line5 ); line5->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line5->AddPoint( { schIUScale.MilsToIU( -10 ), schIUScale.MilsToIU( -160 ) } ); @@ -263,7 +259,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F } else if( aStyle == EASYEDA::POWER_FLAG_STYLE::SIGNAL_GROUND ) { - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2 ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -100 ) } ); @@ -273,7 +269,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F } else if( aStyle == EASYEDA::POWER_FLAG_STYLE::EARTH ) { - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2 ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -150 ), schIUScale.MilsToIU( -200 ) } ); @@ -281,7 +277,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F line2->AddPoint( { schIUScale.MilsToIU( 100 ), schIUScale.MilsToIU( -100 ) } ); line2->AddPoint( { schIUScale.MilsToIU( 50 ), schIUScale.MilsToIU( -200 ) } ); - LIB_SHAPE* line3 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line3 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line3 ); line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line3->AddPoint( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -100 ) } ); @@ -289,7 +285,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F } else // EASYEDA::POWER_FLAG_STYLE::GOST_ARROW { - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2 ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -25 ), schIUScale.MilsToIU( -50 ) } ); @@ -304,25 +300,25 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F else if( aStyle == EASYEDA::POWER_FLAG_STYLE::GOST_POWER_GROUND || aStyle == EASYEDA::POWER_FLAG_STYLE::GOST_EARTH ) { - LIB_SHAPE* line1 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line1 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line1 ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, schIUScale.MilsToIU( -160 ) } ); - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2 ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -160 ) } ); line2->AddPoint( { schIUScale.MilsToIU( 100 ), schIUScale.MilsToIU( -160 ) } ); - LIB_SHAPE* line3 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line3 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line3 ); line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line3->AddPoint( { schIUScale.MilsToIU( -60 ), schIUScale.MilsToIU( -200 ) } ); line3->AddPoint( { schIUScale.MilsToIU( 60 ), schIUScale.MilsToIU( -200 ) } ); - LIB_SHAPE* line4 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line4 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line4 ); line4->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line4->AddPoint( { schIUScale.MilsToIU( -20 ), schIUScale.MilsToIU( -240 ) } ); @@ -331,7 +327,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F if( aStyle == EASYEDA::POWER_FLAG_STYLE::GOST_POWER_GROUND ) return { 0, schIUScale.MilsToIU( 300 ) }; - LIB_SHAPE* circle = new LIB_SHAPE( aKsymbol, SHAPE_T::CIRCLE ); + SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE, LAYER_DEVICE ); aKsymbol->AddDrawItem( circle ); circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); circle->SetPosition( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -160 ) } ); @@ -341,13 +337,13 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F } else if( aStyle == EASYEDA::POWER_FLAG_STYLE::GOST_BAR ) { - LIB_SHAPE* line1 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line1 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line1 ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, schIUScale.MilsToIU( -200 ) } ); - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2 ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -200 ) } ); @@ -363,13 +359,13 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F RPT_SEVERITY_WARNING ); } - LIB_SHAPE* line1 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line1 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line1 ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, schIUScale.MilsToIU( -100 ) } ); - LIB_SHAPE* line2 = new LIB_SHAPE( aKsymbol, SHAPE_T::POLY ); + SCH_SHAPE* line2 = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); aKsymbol->AddDrawItem( line2 ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->AddPoint( { schIUScale.MilsToIU( -50 ), schIUScale.MilsToIU( -100 ) } ); @@ -406,7 +402,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol RelPosSym( VECTOR2I( Convert( ptArr[i - 1] ), Convert( ptArr[i] ) ) ) ); } - std::unique_ptr line = std::make_unique( aSymbol, SHAPE_T::POLY ); + auto line = std::make_unique( SHAPE_T::POLY, LAYER_DEVICE ); if( elType == wxS( "PG" ) ) chain.SetClosed( true ); @@ -449,8 +445,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol for( SHAPE_LINE_CHAIN outline : lineChains ) { - std::unique_ptr shape = - std::make_unique( aSymbol, SHAPE_T::POLY ); + auto shape = std::make_unique( SHAPE_T::POLY, LAYER_DEVICE ); outline.Mirror( false, true ); @@ -631,7 +626,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol if( cw ) std::swap( start, end ); - std::unique_ptr shape = std::make_unique( aSymbol, SHAPE_T::ARC ); + auto shape = std::make_unique( SHAPE_T::ARC, LAYER_DEVICE ); shape->SetStart( RelPosSym( start ) ); shape->SetEnd( RelPosSym( end ) ); @@ -669,8 +664,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol //if( cr.x == 0 ) { - std::unique_ptr rect = - std::make_unique( aSymbol, SHAPE_T::RECTANGLE ); + auto rect = std::make_unique( SHAPE_T::RECTANGLE, LAYER_DEVICE ); rect->SetStart( RelPosSym( start ) ); rect->SetEnd( RelPosSym( start + size ) ); @@ -694,8 +688,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol } else if( elType == wxS( "E" ) ) { - std::unique_ptr circle = - std::make_unique( aSymbol, SHAPE_T::CIRCLE ); + auto circle = std::make_unique( SHAPE_T::CIRCLE, LAYER_DEVICE ); VECTOR2D center( Convert( arr[1] ), Convert( arr[2] ) ); VECTOR2D radius( Convert( arr[3] ), Convert( arr[4] ) ); // TODO: corner radius @@ -755,8 +748,8 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol // M360,290h10 or M 420 300 h -5 wxString lineData = pinPathColorParts[0]; - wxRegEx regex( - wxS( "^M\\s*([-\\d.]+)[,\\s]([-\\d.]+)\\s*([h|v])\\s*([-\\d.]+)\\s*$" ) ); + wxRegEx regex( wxS( "^M\\s*([-\\d.]+)[,\\s]([-\\d.]+)\\s*([h|v])\\s*([-\\d.]+)\\s*$" ) ); + if( regex.Matches( lineData ) ) { startPoint.x = Convert( regex.GetMatch( lineData, 1 ) ); @@ -816,8 +809,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol { VECTOR2D dotPos( Convert( dotParts[1] ), Convert( dotParts[2] ) ); - std::unique_ptr circle = - std::make_unique( aSymbol, SHAPE_T::CIRCLE ); + auto circle = std::make_unique( SHAPE_T::CIRCLE, LAYER_DEVICE ); circle->SetCenter( RelPosSym( dotPos ) ); circle->SetEnd( RelPosSym( @@ -835,8 +827,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol for( SHAPE_LINE_CHAIN outline : lineChains ) { - std::unique_ptr shape = - std::make_unique( aSymbol, SHAPE_T::POLY ); + auto shape = std::make_unique( SHAPE_T::POLY, LAYER_DEVICE ); outline.Mirror( false, true ); diff --git a/eeschema/sch_io/easyeda/sch_easyeda_parser.h b/eeschema/sch_io/easyeda/sch_easyeda_parser.h index 19bb1adbee..e0dfddfddb 100644 --- a/eeschema/sch_io/easyeda/sch_easyeda_parser.h +++ b/eeschema/sch_io/easyeda/sch_easyeda_parser.h @@ -29,19 +29,9 @@ #include #include -#include -#include -#include -#include class EDA_TEXT; -class LIB_SHAPE; -class LIB_PIN; -class SCH_LABEL_BASE; -class SCH_SYMBOL; -class SCH_TEXT; -class SCH_SHAPE; class SCH_EASYEDA_PARSER: public EASYEDA_PARSER_BASE { diff --git a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp index 78f1ec7a96..de44d36fe6 100644 --- a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp +++ b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp @@ -30,16 +30,13 @@ #include #include #include -#include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -429,8 +426,7 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector rect = - std::make_unique( ksymbol, SHAPE_T::RECTANGLE ); + auto rect = std::make_unique( SHAPE_T::RECTANGLE, LAYER_DEVICE ); rect->SetStart( ScalePosSym( start ) ); rect->SetEnd( ScalePosSym( end ) ); @@ -446,8 +442,7 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector circle = - std::make_unique( ksymbol, SHAPE_T::CIRCLE ); + auto circle = std::make_unique( SHAPE_T::CIRCLE, LAYER_DEVICE ); circle->SetCenter( ScalePosSym( center ) ); circle->SetEnd( circle->GetCenter() + VECTOR2I( ScaleSize( radius ), 0 ) ); @@ -470,7 +465,7 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector shape = std::make_unique( ksymbol, SHAPE_T::ARC ); + auto shape = std::make_unique( SHAPE_T::ARC, LAYER_DEVICE ); shape->SetStart( kstart ); shape->SetEnd( kend ); @@ -492,13 +487,10 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector points = line.at( 2 ); wxString styleStr = line.at( 4 ); - std::unique_ptr shape = - std::make_unique( ksymbol, SHAPE_T::POLY ); + auto shape = std::make_unique( SHAPE_T::POLY, LAYER_DEVICE ); for( size_t i = 1; i < points.size(); i += 2 ) - { shape->AddPoint( ScalePosSym( VECTOR2D( points[i - 1], points[i] ) ) ); - } shape->SetUnit( currentUnit ); ApplyLineStyle( lineStyles, shape, styleStr ); diff --git a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.h b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.h index d4ea8b6786..10533f2331 100644 --- a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.h +++ b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.h @@ -30,17 +30,11 @@ #include #include #include -#include #include class EDA_TEXT; -class LIB_SHAPE; -class LIB_PIN; -class SCH_LABEL_BASE; class SCH_SYMBOL; -class SCH_TEXT; -class SCH_SHAPE; namespace EASYEDAPRO { diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp index 4d58d8e14f..9ea1a6e3b4 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include @@ -712,11 +712,11 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDrawEntries( std::unique_ptr switch( line[0] ) { case 'A': // Arc - aSymbol->AddDrawItem( loadArc( aSymbol, aReader ), false ); + aSymbol->AddDrawItem( loadArc( aReader ), false ); break; case 'C': // Circle - aSymbol->AddDrawItem( loadCircle( aSymbol, aReader ), false ); + aSymbol->AddDrawItem( loadCircle( aReader ), false ); break; case 'T': // Text @@ -724,7 +724,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDrawEntries( std::unique_ptr break; case 'S': // Square - aSymbol->AddDrawItem( loadRect( aSymbol, aReader ), false ); + aSymbol->AddDrawItem( loadRect( aReader ), false ); break; case 'X': // Pin Description @@ -732,11 +732,11 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDrawEntries( std::unique_ptr break; case 'P': // Polyline - aSymbol->AddDrawItem( loadPolyLine( aSymbol, aReader ), false ); + aSymbol->AddDrawItem( loadPolyLine( aReader ), false ); break; case 'B': // Bezier Curves - aSymbol->AddDrawItem( loadBezier( aSymbol, aReader ), false ); + aSymbol->AddDrawItem( loadBezier( aReader ), false ); break; case '#': // Comment @@ -833,14 +833,13 @@ static bool MapAnglesV6( int* aAngle1, int* aAngle2 ) } -LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc( std::unique_ptr& aSymbol, - LINE_READER& aReader ) +SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc( LINE_READER& aReader ) { const char* line = aReader.Line(); wxCHECK_MSG( strCompare( "A", line, &line ), nullptr, "Invalid arc definition" ); - LIB_SHAPE* arc = new LIB_SHAPE( aSymbol.get(), SHAPE_T::ARC ); + SCH_SHAPE* arc = new SCH_SHAPE( SHAPE_T::ARC, LAYER_DEVICE ); VECTOR2I center; @@ -915,14 +914,13 @@ LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc( std::unique_ptr& } -LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadCircle( std::unique_ptr& aSymbol, - LINE_READER& aReader ) +SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadCircle( LINE_READER& aReader ) { const char* line = aReader.Line(); wxCHECK_MSG( strCompare( "C", line, &line ), nullptr, "Invalid circle definition" ); - LIB_SHAPE* circle = new LIB_SHAPE( aSymbol.get(), SHAPE_T::CIRCLE ); + SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE, LAYER_DEVICE ); VECTOR2I center; @@ -953,7 +951,7 @@ SCH_TEXT* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText( LINE_READER& aReader, { const char* line = aReader.Line(); - wxCHECK_MSG( strCompare( "T", line, &line ), nullptr, "Invalid LIB_TEXT definition" ); + wxCHECK_MSG( strCompare( "T", line, &line ), nullptr, "Invalid SCH_TEXT definition" ); double angleInTenths; VECTOR2I center; @@ -1040,14 +1038,13 @@ SCH_TEXT* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText( LINE_READER& aReader, } -LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadRect( std::unique_ptr& aSymbol, - LINE_READER& aReader ) +SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadRect( LINE_READER& aReader ) { const char* line = aReader.Line(); wxCHECK_MSG( strCompare( "S", line, &line ), nullptr, "Invalid rectangle definition" ); - LIB_SHAPE* rectangle = new LIB_SHAPE( aSymbol.get(), SHAPE_T::RECTANGLE ); + SCH_SHAPE* rectangle = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ); VECTOR2I pos; @@ -1299,14 +1296,13 @@ LIB_PIN* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin( std::unique_ptr& aS } -LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPolyLine( std::unique_ptr& aSymbol, - LINE_READER& aReader ) +SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPolyLine( LINE_READER& aReader ) { const char* line = aReader.Line(); wxCHECK_MSG( strCompare( "P", line, &line ), nullptr, "Invalid poly definition" ); - LIB_SHAPE* polyLine = new LIB_SHAPE( aSymbol.get(), SHAPE_T::POLY ); + SCH_SHAPE* polyLine = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); int points = parseInt( aReader, line, &line ); polyLine->SetUnit( parseInt( aReader, line, &line ) ); @@ -1333,8 +1329,7 @@ LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPolyLine( std::unique_ptr& aSymbol, - LINE_READER& aReader ) +SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadBezier( LINE_READER& aReader ) { const char* line = aReader.Line(); @@ -1344,7 +1339,7 @@ LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadBezier( std::unique_ptrSetUnit( parseInt( aReader, line, &line ) ); bezier->SetBodyStyle( parseInt( aReader, line, &line ) ); @@ -1571,11 +1566,17 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMA { switch( item.Type() ) { - case LIB_PIN_T: savePin( static_cast( &item ), aFormatter ); break; - case SCH_TEXT_T: saveText( static_cast( &item ), aFormatter ); break; - case LIB_SHAPE_T: + case LIB_PIN_T: + savePin( static_cast( &item ), aFormatter ); + + break; + case SCH_TEXT_T: + saveText( static_cast( &item ), aFormatter ); + break; + + case SCH_SHAPE_T: { - LIB_SHAPE& shape = static_cast( item ); + SCH_SHAPE& shape = static_cast( item ); switch( shape.GetShape() ) { @@ -1586,8 +1587,12 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMA case SHAPE_T::RECTANGLE: saveRectangle( &shape, aFormatter ); break; default: break; } + + break; } - default: break; + + default: + break; } } @@ -1598,7 +1603,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMA } -void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveArc( LIB_SHAPE* aArc, OUTPUTFORMATTER& aFormatter ) +void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveArc( SCH_SHAPE* aArc, OUTPUTFORMATTER& aFormatter ) { wxCHECK_RET( aArc && aArc->GetShape() == SHAPE_T::ARC, "Invalid ARC object." ); @@ -1625,7 +1630,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveArc( LIB_SHAPE* aArc, OUTPUTFORMATTER& a } -void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveBezier( LIB_SHAPE* aBezier, OUTPUTFORMATTER& aFormatter ) +void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveBezier( SCH_SHAPE* aBezier, OUTPUTFORMATTER& aFormatter ) { wxCHECK_RET( aBezier && aBezier->GetShape() == SHAPE_T::BEZIER, "Invalid BEZIER object." ); @@ -1648,7 +1653,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveBezier( LIB_SHAPE* aBezier, OUTPUTFORMAT } -void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveCircle( LIB_SHAPE* aCircle, OUTPUTFORMATTER& aFormatter ) +void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveCircle( SCH_SHAPE* aCircle, OUTPUTFORMATTER& aFormatter ) { wxCHECK_RET( aCircle && aCircle->GetShape() == SHAPE_T::CIRCLE, "Invalid CIRCLE object." ); @@ -1777,7 +1782,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::savePin( const LIB_PIN* aPin, OUTPUTFORMATTE } -void SCH_IO_KICAD_LEGACY_LIB_CACHE::savePolyLine( LIB_SHAPE* aPolyLine, +void SCH_IO_KICAD_LEGACY_LIB_CACHE::savePolyLine( SCH_SHAPE* aPolyLine, OUTPUTFORMATTER& aFormatter ) { wxCHECK_RET( aPolyLine && aPolyLine->GetShape() == SHAPE_T::POLY, "Invalid POLY object." ); @@ -1795,7 +1800,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::savePolyLine( LIB_SHAPE* aPolyLine, } -void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveRectangle( LIB_SHAPE* aRectangle, +void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveRectangle( SCH_SHAPE* aRectangle, OUTPUTFORMATTER& aFormatter ) { wxCHECK_RET( aRectangle && aRectangle->GetShape() == SHAPE_T::RECTANGLE, diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.h b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.h index 63dc1e28ae..46ea2d3480 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.h +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.h @@ -30,8 +30,8 @@ class FILE_LINE_READER; class LIB_PIN; -class LIB_SHAPE; -class LIB_TEXT; +class SCH_SHAPE; +class SCH_TEXT; class LINE_READER; class SCH_IO_KICAD_LEGACY; @@ -73,24 +73,24 @@ private: static void loadFootprintFilters( std::unique_ptr& aSymbol, LINE_READER& aReader ); void loadDocs(); - static LIB_SHAPE* loadArc( std::unique_ptr& aSymbol, LINE_READER& aReader ); - static LIB_SHAPE* loadCircle( std::unique_ptr& aSymbol, LINE_READER& aReader ); + static SCH_SHAPE* loadArc( LINE_READER& aReader ); + static SCH_SHAPE* loadCircle( LINE_READER& aReader ); static SCH_TEXT* loadText( LINE_READER& aReader, int aMajorVersion, int aMinorVersion ); - static LIB_SHAPE* loadRect( std::unique_ptr& aSymbol, LINE_READER& aReader ); + static SCH_SHAPE* loadRect( LINE_READER& aReader ); static LIB_PIN* loadPin( std::unique_ptr& aSymbol, LINE_READER& aReader ); - static LIB_SHAPE* loadPolyLine( std::unique_ptr& aSymbol, LINE_READER& aReader ); - static LIB_SHAPE* loadBezier( std::unique_ptr& aSymbol, LINE_READER& aReader ); + static SCH_SHAPE* loadPolyLine( LINE_READER& aReader ); + static SCH_SHAPE* loadBezier( LINE_READER& aReader ); static FILL_T parseFillMode( LINE_READER& aReader, const char* aLine, const char** aOutput ); void saveDocFile(); - static void saveArc( LIB_SHAPE* aArc, OUTPUTFORMATTER& aFormatter ); - static void saveBezier( LIB_SHAPE* aBezier, OUTPUTFORMATTER& aFormatter ); - static void saveCircle( LIB_SHAPE* aCircle, OUTPUTFORMATTER& aFormatter ); + static void saveArc( SCH_SHAPE* aArc, OUTPUTFORMATTER& aFormatter ); + static void saveBezier( SCH_SHAPE* aBezier, OUTPUTFORMATTER& aFormatter ); + static void saveCircle( SCH_SHAPE* aCircle, OUTPUTFORMATTER& aFormatter ); static void saveField( const SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter ); static void savePin( const LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter ); - static void savePolyLine( LIB_SHAPE* aPolyLine, OUTPUTFORMATTER& aFormatter ); - static void saveRectangle( LIB_SHAPE* aRectangle, OUTPUTFORMATTER& aFormatter ); + static void savePolyLine( SCH_SHAPE* aPolyLine, OUTPUTFORMATTER& aFormatter ); + static void saveRectangle( SCH_SHAPE* aRectangle, OUTPUTFORMATTER& aFormatter ); static void saveText( const SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter ); int m_versionMajor; diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp index 7c4b45c780..1bb9023d89 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp @@ -22,9 +22,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include #include @@ -333,9 +333,9 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFO switch( aItem->Type() ) { - case LIB_SHAPE_T: + case SCH_SHAPE_T: { - LIB_SHAPE* shape = static_cast( aItem ); + SCH_SHAPE* shape = static_cast( aItem ); STROKE_PARAMS stroke = shape->GetStroke(); FILL_T fillMode = shape->GetFillMode(); COLOR4D fillColor = shape->GetFillColor(); @@ -378,8 +378,8 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFO saveText( static_cast( aItem ), aFormatter, aNestLevel ); break; - case LIB_TEXTBOX_T: - saveTextBox( static_cast( aItem ), aFormatter, aNestLevel ); + case SCH_TEXTBOX_T: + saveTextBox( static_cast( aItem ), aFormatter, aNestLevel ); break; default: @@ -489,10 +489,10 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveText( SCH_TEXT* aText, OUTPUTFORMATTER& a } -void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveTextBox( LIB_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter, +void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveTextBox( SCH_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter, int aNestLevel ) { - wxCHECK_RET( aTextBox && aTextBox->Type() == LIB_TEXTBOX_T, "Invalid LIB_TEXTBOX object." ); + wxCHECK_RET( aTextBox && aTextBox->Type() == SCH_TEXTBOX_T, "Invalid SCH_TEXTBOX object." ); aFormatter.Print( aNestLevel, "(text_box%s %s\n", aTextBox->IsPrivate() ? " private" : "", diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h index 087ec5eb35..8f08f1e411 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h @@ -27,7 +27,7 @@ class FILE_LINE_READER; class LIB_PIN; class SCH_TEXT; -class LIB_TEXTBOX; +class SCH_TEXTBOX; class LINE_READER; class SCH_IO_KICAD_SEXPR; @@ -67,7 +67,7 @@ private: static void saveField( SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter, int aNestLevel ); static void savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); static void saveText( SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); - static void saveTextBox( LIB_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter, + static void saveTextBox( SCH_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); static void saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter, diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp index 6c19e283e7..863a5d42e0 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp @@ -36,9 +36,7 @@ #include #include -#include #include -#include #include // KiROUND, Clamp #include #include @@ -552,15 +550,15 @@ SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem() switch( CurTok() ) { case T_arc: - return parseArc(); + return parseSymbolArc(); break; case T_bezier: - return parseBezier(); + return parseSymbolBezier(); break; case T_circle: - return parseCircle(); + return parseSymbolCircle(); break; case T_pin: @@ -568,11 +566,11 @@ SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem() break; case T_polyline: - return parsePolyLine(); + return parseSymbolPolyLine(); break; case T_rectangle: - return parseRectangle(); + return parseSymbolRectangle(); break; case T_text: @@ -580,7 +578,7 @@ SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem() break; case T_text_box: - return parseTextBox(); + return parseSymbolTextBox(); break; default: @@ -1083,7 +1081,7 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr } -LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseArc() +SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolArc() { wxCHECK_MSG( CurTok() == T_arc, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as an arc." ) ); @@ -1102,7 +1100,7 @@ LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseArc() EDA_ANGLE endAngle = ANGLE_90; bool hasAngles = false; - std::unique_ptr arc = std::make_unique( nullptr, SHAPE_T::ARC ); + std::unique_ptr arc = std::make_unique( SHAPE_T::ARC, LAYER_DEVICE ); arc->SetUnit( m_unit ); arc->SetBodyStyle( m_bodyStyle ); @@ -1270,7 +1268,7 @@ LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseArc() } -LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseBezier() +SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolBezier() { wxCHECK_MSG( CurTok() == T_bezier, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a bezier." ) ); @@ -1279,7 +1277,7 @@ LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseBezier() STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT ); FILL_PARAMS fill; - std::unique_ptr bezier = std::make_unique( nullptr, SHAPE_T::BEZIER ); + std::unique_ptr bezier = std::make_unique( SHAPE_T::BEZIER, LAYER_DEVICE ); bezier->SetUnit( m_unit ); bezier->SetBodyStyle( m_bodyStyle ); @@ -1351,7 +1349,7 @@ LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseBezier() } -LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseCircle() +SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolCircle() { wxCHECK_MSG( CurTok() == T_circle, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a circle." ) ); @@ -1362,7 +1360,7 @@ LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseCircle() STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT ); FILL_PARAMS fill; - std::unique_ptr circle = std::make_unique( nullptr, SHAPE_T::CIRCLE ); + std::unique_ptr circle = std::make_unique( SHAPE_T::CIRCLE, LAYER_DEVICE ); circle->SetUnit( m_unit ); circle->SetBodyStyle( m_bodyStyle ); @@ -1627,7 +1625,7 @@ LIB_PIN* SCH_IO_KICAD_SEXPR_PARSER::parsePin() } -LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parsePolyLine() +SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolPolyLine() { wxCHECK_MSG( CurTok() == T_polyline, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a poly." ) ); @@ -1635,7 +1633,7 @@ LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parsePolyLine() T token; STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT ); FILL_PARAMS fill; - std::unique_ptr poly = std::make_unique( nullptr, SHAPE_T::POLY ); + std::unique_ptr poly = std::make_unique( SHAPE_T::POLY, LAYER_DEVICE ); poly->SetUnit( m_unit ); poly->SetBodyStyle( m_bodyStyle ); @@ -1695,7 +1693,7 @@ LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parsePolyLine() } -LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseRectangle() +SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolRectangle() { wxCHECK_MSG( CurTok() == T_rectangle, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a rectangle." ) ); @@ -1703,7 +1701,7 @@ LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseRectangle() T token; STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT ); FILL_PARAMS fill; - std::unique_ptr rectangle = std::make_unique( nullptr, SHAPE_T::RECTANGLE ); + auto rectangle = std::make_unique( SHAPE_T::RECTANGLE, LAYER_DEVICE ); rectangle->SetUnit( m_unit ); rectangle->SetBodyStyle( m_bodyStyle ); @@ -1811,7 +1809,7 @@ SCH_TEXT* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolText() } -LIB_TEXTBOX* SCH_IO_KICAD_SEXPR_PARSER::parseTextBox() +SCH_TEXTBOX* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolTextBox() { wxCHECK_MSG( CurTok() == T_text_box, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a text box." ) ); @@ -1830,7 +1828,7 @@ LIB_TEXTBOX* SCH_IO_KICAD_SEXPR_PARSER::parseTextBox() bool foundSize = false; bool foundMargins = false; - std::unique_ptr textBox = std::make_unique( nullptr ); + std::unique_ptr textBox = std::make_unique( LAYER_DEVICE ); textBox->SetUnit( m_unit ); textBox->SetBodyStyle( m_bodyStyle ); @@ -3618,9 +3616,8 @@ SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSchPolyLine() T token; STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT ); FILL_PARAMS fill; - int layer = LAYER_NOTES; - std::unique_ptr polyline = std::make_unique( SHAPE_T::POLY, layer ); + std::unique_ptr polyline = std::make_unique( SHAPE_T::POLY, LAYER_NOTES ); for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h index 22032a0670..471d01c523 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h @@ -37,9 +37,7 @@ #include // For some default values -class LIB_SHAPE; class LIB_PIN; -class LIB_TEXTBOX; class PAGE_INFO; class SCH_BITMAP; class SCH_BUS_WIRE_ENTRY; @@ -195,14 +193,14 @@ private: SCH_FIELD* parseProperty( std::unique_ptr& aSymbol ); - LIB_SHAPE* parseArc(); - LIB_SHAPE* parseBezier(); - LIB_SHAPE* parseCircle(); + SCH_SHAPE* parseSymbolArc(); + SCH_SHAPE* parseSymbolBezier(); + SCH_SHAPE* parseSymbolCircle(); LIB_PIN* parsePin(); - LIB_SHAPE* parsePolyLine(); - LIB_SHAPE* parseRectangle(); + SCH_SHAPE* parseSymbolPolyLine(); + SCH_SHAPE* parseSymbolRectangle(); SCH_TEXT* parseSymbolText(); - LIB_TEXTBOX* parseTextBox(); + SCH_TEXTBOX* parseSymbolTextBox(); void parsePAGE_INFO( PAGE_INFO& aPageInfo ); void parseTITLE_BLOCK( TITLE_BLOCK& aTitleBlock ); diff --git a/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp b/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp index 2b1f2d3f13..e5f53d410a 100644 --- a/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp +++ b/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp @@ -26,12 +26,8 @@ #include #include -#include #include -#include -#include #include -#include #include #include #include @@ -109,7 +105,7 @@ void SCH_IO_LTSPICE_PARSER::readIncludes( std::vector void SCH_IO_LTSPICE_PARSER::CreateLines( LIB_SYMBOL* aSymbol, LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, - int aIndex, LIB_SHAPE* shape ) + int aIndex, SCH_SHAPE* shape ) { LTSPICE_SCHEMATIC::LINE& lt_line = aLTSymbol.Lines[aIndex]; @@ -280,7 +276,7 @@ void SCH_IO_LTSPICE_PARSER::CreateSymbol( LTSPICE_SCHEMATIC::LT_SYMBOL& aLtSymbo { for( int j = 0; j < (int) aLtSymbol.Lines.size(); j++ ) { - LIB_SHAPE* line = new LIB_SHAPE( aLibSymbol, SHAPE_T::POLY ); + SCH_SHAPE* line = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE ); CreateLines( aLibSymbol, aLtSymbol, j, line ); aLibSymbol->AddDrawItem( line ); @@ -288,7 +284,7 @@ void SCH_IO_LTSPICE_PARSER::CreateSymbol( LTSPICE_SCHEMATIC::LT_SYMBOL& aLtSymbo for( int j = 0; j < (int) aLtSymbol.Circles.size(); j++ ) { - LIB_SHAPE* circle = new LIB_SHAPE( aLibSymbol, SHAPE_T::CIRCLE ); + SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE, LAYER_DEVICE ); CreateCircle( aLtSymbol, j, circle ); aLibSymbol->AddDrawItem( circle ); @@ -296,7 +292,7 @@ void SCH_IO_LTSPICE_PARSER::CreateSymbol( LTSPICE_SCHEMATIC::LT_SYMBOL& aLtSymbo for( int j = 0; j < (int) aLtSymbol.Arcs.size(); j++ ) { - LIB_SHAPE* arc = new LIB_SHAPE( aLibSymbol, SHAPE_T::ARC ); + SCH_SHAPE* arc = new SCH_SHAPE( SHAPE_T::ARC, LAYER_DEVICE ); CreateArc( aLtSymbol, j, arc ); aLibSymbol->AddDrawItem( arc ); @@ -304,7 +300,7 @@ void SCH_IO_LTSPICE_PARSER::CreateSymbol( LTSPICE_SCHEMATIC::LT_SYMBOL& aLtSymbo for( int j = 0; j < (int) aLtSymbol.Rectangles.size(); j++ ) { - LIB_SHAPE* rectangle = new LIB_SHAPE( aLibSymbol, SHAPE_T::RECTANGLE ); + SCH_SHAPE* rectangle = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ); CreateRect( aLtSymbol, j, rectangle ); aLibSymbol->AddDrawItem( rectangle ); @@ -822,7 +818,7 @@ SCH_SYMBOL* SCH_IO_LTSPICE_PARSER::CreatePowerSymbol( const VECTOR2I& aOffset, std::vector& aWires ) { LIB_SYMBOL* lib_symbol = new LIB_SYMBOL( wxS( "GND" ) ); - LIB_SHAPE* shape = new LIB_SHAPE( lib_symbol, SHAPE_T::POLY ); + SCH_SHAPE* shape = new SCH_SHAPE( SHAPE_T::POLY,LAYER_DEVICE ); shape->AddPoint( ToInvertedKicadCoords( { 16, 0 } ) ); shape->AddPoint( ToInvertedKicadCoords( { -16, 0 } ) ); @@ -1245,7 +1241,7 @@ void SCH_IO_LTSPICE_PARSER::CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbo void SCH_IO_LTSPICE_PARSER::CreateRect( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, - LIB_SHAPE* aRectangle ) + SCH_SHAPE* aRectangle ) { LTSPICE_SCHEMATIC::RECTANGLE& lt_rect = aLTSymbol.Rectangles[aIndex]; @@ -1330,7 +1326,7 @@ void SCH_IO_LTSPICE_PARSER::CreatePin( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, void SCH_IO_LTSPICE_PARSER::CreateArc( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, - LIB_SHAPE* aArc ) + SCH_SHAPE* aArc ) { LTSPICE_SCHEMATIC::ARC& lt_arc = aLTSymbol.Arcs[aIndex]; @@ -1380,7 +1376,7 @@ void SCH_IO_LTSPICE_PARSER::CreateCircle( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbo void SCH_IO_LTSPICE_PARSER::CreateCircle( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, - LIB_SHAPE* aCircle ) + SCH_SHAPE* aCircle ) { LTSPICE_SCHEMATIC::CIRCLE& lt_circle = aLTSymbol.Circles[aIndex]; diff --git a/eeschema/sch_io/ltspice/sch_io_ltspice_parser.h b/eeschema/sch_io/ltspice/sch_io_ltspice_parser.h index 8fc4699bce..d42827a5e4 100644 --- a/eeschema/sch_io/ltspice/sch_io_ltspice_parser.h +++ b/eeschema/sch_io/ltspice/sch_io_ltspice_parser.h @@ -30,13 +30,11 @@ #include #include #include -#include #include #include class EDA_TEXT; -class LIB_SHAPE; class LIB_PIN; class SCH_LABEL_BASE; class SCH_SYMBOL; @@ -109,7 +107,7 @@ public: * @param aIndex index. */ void CreateLines( LIB_SYMBOL* aSymbol, LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, - LIB_SHAPE* aShape ); + SCH_SHAPE* aShape ); /** * Method for plotting Schematic Lines from Asy files @@ -244,7 +242,7 @@ public: /** * Create a symbol rect. */ - void CreateRect( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, LIB_SHAPE* aRectangle ); + void CreateRect( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, SCH_SHAPE* aRectangle ); /** * Create a schematic rect. @@ -259,7 +257,7 @@ public: /** * Create a symbol arc. */ - void CreateArc( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, LIB_SHAPE* aArc ); + void CreateArc( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, SCH_SHAPE* aArc ); /** * Create a schematic arc. @@ -269,7 +267,7 @@ public: /** * Create a symbol circle. */ - void CreateCircle( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, LIB_SHAPE* aCircle ); + void CreateCircle( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, SCH_SHAPE* aCircle ); /** * Create a schematic circle. diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 43efd886e5..6321cdc70d 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -25,18 +25,14 @@ */ -#include #include -#include #include #include #include #include #include #include -#include #include -#include #include #include #include @@ -46,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -60,10 +57,8 @@ #include #include #include -#include #include #include "sch_painter.h" -#include "sch_shape.h" #include "common.h" @@ -83,7 +78,7 @@ std::vector SCH_PAINTER::g_ScaledSelectionTypes = { SCH_BUS_WIRE_ENTRY_T, SCH_BUS_BUS_ENTRY_T, SCH_LINE_T, - LIB_SHAPE_T, SCH_SHAPE_T, + SCH_SHAPE_T, SCH_BITMAP_T, SCH_TEXT_T, SCH_GLOBAL_LABEL_T, @@ -118,16 +113,15 @@ static LIB_SYMBOL* dummy() { symbol = new LIB_SYMBOL( wxEmptyString ); - LIB_SHAPE* square = new LIB_SHAPE( symbol, SHAPE_T::RECTANGLE ); + SCH_SHAPE* square = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ); square->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) ); square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) ); + symbol->AddDrawItem( square ); SCH_TEXT* text = new SCH_TEXT( { 0, 0 }, wxT( "??" ), LAYER_DEVICE ); text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) ); - - symbol->AddDrawItem( square ); symbol->AddDrawItem( text ); } @@ -136,10 +130,11 @@ static LIB_SYMBOL* dummy() SCH_PAINTER::SCH_PAINTER( GAL* aGal ) : - KIGFX::PAINTER( aGal ), - m_schematic( nullptr ) + KIGFX::PAINTER( aGal ), + m_schematic( nullptr ) { } + bool SCH_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) { const EDA_ITEM* item = dynamic_cast( aItem ); @@ -183,16 +178,10 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed ) case LIB_SYMBOL_T: draw( static_cast( aItem ), aLayer ); break; - case LIB_SHAPE_T: - draw( static_cast( aItem ), aLayer, aDimmed ); - break; case LIB_PIN_T: drawBoundingBox = false; draw( static_cast( aItem ), aLayer, aDimmed ); break; - case LIB_TEXTBOX_T: - draw( static_cast( aItem ), aLayer, aDimmed ); - break; case SCH_SYMBOL_T: draw( static_cast( aItem ), aLayer ); break; @@ -203,16 +192,16 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed ) draw( static_cast( aItem ), aLayer ); break; case SCH_SHAPE_T: - draw( static_cast( aItem ), aLayer ); + draw( static_cast( aItem ), aLayer, aDimmed ); break; case SCH_TEXT_T: draw( static_cast( aItem ), aLayer, aDimmed ); break; case SCH_TEXTBOX_T: - draw( static_cast( aItem ), aLayer ); + draw( static_cast( aItem ), aLayer, aDimmed ); break; case SCH_TABLE_T: - draw( static_cast( aItem ), aLayer ); + draw( static_cast( aItem ), aLayer, aDimmed ); break; case SCH_LABEL_T: draw( static_cast( aItem ), aLayer ); @@ -358,7 +347,7 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr { const SCH_SHAPE* shape = static_cast( aItem ); - if( aLayer == LAYER_NOTES_BACKGROUND ) + if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) color = shape->GetFillColor(); else color = shape->GetStroke().GetColor(); @@ -368,15 +357,6 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr if( color == COLOR4D::UNSPECIFIED ) color = m_schSettings.GetLayerColor( LAYER_NOTES ); } - else if( aItem->Type() == LIB_SHAPE_T ) - { - const LIB_SHAPE* shape = static_cast( aItem ); - - if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) - color = shape->GetFillColor(); - else - color = shape->GetStroke().GetColor(); - } else if( aItem->IsType( { SCH_LABEL_LOCATE_ANY_T } ) ) { color = static_cast( aItem )->GetLabelColor(); @@ -389,15 +369,6 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr { const SCH_TEXTBOX* textBox = dynamic_cast( aItem ); - if( aLayer == LAYER_NOTES_BACKGROUND ) - color = textBox->GetFillColor(); - else - color = textBox->GetTextColor(); - } - else if( aItem->Type() == LIB_TEXTBOX_T ) - { - const LIB_TEXTBOX* textBox = static_cast( aItem ); - if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) color = textBox->GetFillColor(); else @@ -511,10 +482,6 @@ float SCH_PAINTER::getTextThickness( const EDA_ITEM* aItem ) const pen = static_cast( aItem )->GetEffectiveTextPenWidth( pen ); break; - case LIB_TEXTBOX_T: - pen = std::max( pen, static_cast( aItem )->GetEffectiveTextPenWidth() ); - break; - default: UNIMPLEMENTED_FOR( aItem->GetClass() ); } @@ -533,10 +500,10 @@ int SCH_PAINTER::getOperatingPointTextSize() const } -static VECTOR2D mapCoords( const VECTOR2D& aCoord ) -{ - return VECTOR2D( aCoord.x, -aCoord.y ); -} +// +// TODO: nuke symbol editor's upside-down coordinate system +// +#define MAP_COORDS( aCoord ) VECTOR2D( aCoord.x, invertY ? -aCoord.y : aCoord.y ) static bool isFieldsLayer( int aLayer ) @@ -632,7 +599,8 @@ void SCH_PAINTER::knockoutText( const wxString& aText, const VECTOR2D& aPosition void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition, - const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics ) + const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics, + bool invertY ) { KIFONT::FONT* font = aAttrs.m_Font; @@ -666,12 +634,12 @@ void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition, box.Inflate( 0, aAttrs.m_StrokeWidth * 2 ); box.Normalize(); // Make h and v sizes always >= 0 - box = box.GetBoundingBoxRotated( (VECTOR2I) aPosition, aAttrs.m_Angle ); + box = box.GetBoundingBoxRotated( aPosition, aAttrs.m_Angle ); box.RevertYAxis(); m_gal->SetIsFill( true ); m_gal->SetIsStroke( false ); - m_gal->DrawRectangle( mapCoords( box.GetOrigin() ), mapCoords( box.GetEnd() ) ); + m_gal->DrawRectangle( MAP_COORDS( box.GetOrigin() ), MAP_COORDS( box.GetEnd() ) ); } @@ -824,275 +792,6 @@ bool SCH_PAINTER::setDeviceColors( const SCH_ITEM* aItem, int aLayer, bool aDimm } -void SCH_PAINTER::draw( const LIB_SHAPE* aShape, int aLayer, bool aDimmed ) -{ - if( !isUnitAndConversionShown( aShape ) ) - return; - - if( aShape->IsPrivate() && !m_schSettings.m_IsSymbolEditor ) - return; - - if( !setDeviceColors( aShape, aLayer, aDimmed ) ) - return; - - bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; - LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle(); - COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows, aDimmed ); - - auto drawShape = - [&]( const LIB_SHAPE* shape ) - { - switch( shape->GetShape() ) - { - case SHAPE_T::ARC: - { - VECTOR2D start = mapCoords( shape->GetStart() ); - VECTOR2D mid = mapCoords( shape->GetArcMid() ); - VECTOR2D end = mapCoords( shape->GetEnd() ); - VECTOR2D center = CalcArcCenter( start, mid, end ); - - EDA_ANGLE startAngle( start - center ); - EDA_ANGLE midAngle( mid - center ); - EDA_ANGLE endAngle( end - center ); - - EDA_ANGLE angle1 = midAngle - startAngle; - EDA_ANGLE angle2 = endAngle - midAngle; - - EDA_ANGLE angle = angle1.Normalize180() + angle2.Normalize180(); - - m_gal->DrawArc( center, ( start - center ).EuclideanNorm(), startAngle, angle ); - } - break; - - case SHAPE_T::CIRCLE: - m_gal->DrawCircle( mapCoords( shape->GetPosition() ), shape->GetRadius() ); - break; - - case SHAPE_T::RECTANGLE: - m_gal->DrawRectangle( mapCoords( shape->GetPosition() ), - mapCoords( shape->GetEnd() ) ); - break; - - case SHAPE_T::POLY: - { - const SHAPE_LINE_CHAIN poly = shape->GetPolyShape().Outline( 0 ); - std::deque mappedPts; - - for( const VECTOR2I& pt : poly.CPoints() ) - mappedPts.push_back( mapCoords( pt ) ); - - m_gal->DrawPolygon( mappedPts ); - } - break; - - case SHAPE_T::BEZIER: - { - m_gal->DrawCurve( - mapCoords( shape->GetStart() ), mapCoords( shape->GetBezierC1() ), - mapCoords( shape->GetBezierC2() ), mapCoords( shape->GetEnd() ) ); - } - break; - - default: - UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); - } - }; - - if( aLayer == LAYER_SELECTION_SHADOWS ) - { - if( eeconfig()->m_Selection.fill_shapes ) - { - // Consider a NAND gate. We have no idea which side of the arc is "inside" - // so we can't reliably fill. - if( aShape->GetShape() == SHAPE_T::ARC ) - m_gal->SetIsFill( aShape->IsFilled() ); - else - m_gal->SetIsFill( true ); - } - else - { - m_gal->SetIsStroke( true ); - m_gal->SetIsFill( false ); - m_gal->SetLineWidth( getLineWidth( aShape, true ) ); - m_gal->SetStrokeColor( color ); - } - - drawShape( aShape ); - } - else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) - { - // Do not fill the shape in B&W print mode, to avoid to visible items - // inside the shape - if( aShape->GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR - && !m_schSettings.PrintBlackAndWhiteReq() ) - { - m_gal->SetIsFill( true ); - m_gal->SetIsStroke( false ); - drawShape( aShape ); - } - } - else if( aLayer == LAYER_DEVICE || aLayer == LAYER_PRIVATE_NOTES ) - { - float lineWidth = getLineWidth( aShape, drawingShadows ); - - if( lineWidth > 0 ) - { - m_gal->SetIsFill( false ); - m_gal->SetIsStroke( true ); - m_gal->SetLineWidth( lineWidth ); - m_gal->SetStrokeColor( color ); - - if( lineStyle <= LINE_STYLE::FIRST_TYPE || drawingShadows ) - { - drawShape( aShape ); - } - else - { - std::vector shapes = aShape->MakeEffectiveShapes( true ); - - for( SHAPE* shape : shapes ) - { - STROKE_PARAMS::Stroke( shape, lineStyle, KiROUND( lineWidth ), &m_schSettings, - [&]( const VECTOR2I& a, const VECTOR2I& b ) - { - // DrawLine has problem with 0 length lines so enforce minimum - if( a == b ) - m_gal->DrawLine( mapCoords( a+1 ), mapCoords( b ) ); - else - m_gal->DrawLine( mapCoords( a ), mapCoords( b ) ); - } ); - } - - for( SHAPE* shape : shapes ) - delete shape; - } - } - - if( aShape->GetFillMode() == FILL_T::FILLED_SHAPE - || aShape->GetFillMode() == FILL_T::FILLED_WITH_COLOR ) - { - m_gal->SetIsFill( true ); - m_gal->SetIsStroke( false ); - drawShape( aShape ); - } - } -} - - -void SCH_PAINTER::draw( const LIB_TEXTBOX* aTextBox, int aLayer, bool aDimmed ) -{ - if( !isUnitAndConversionShown( aTextBox ) ) - return; - - if( aTextBox->IsPrivate() && !m_schSettings.m_IsSymbolEditor ) - return; - - bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; - - if( drawingShadows && !( aTextBox->IsBrightened() || aTextBox->IsSelected() ) ) - return; - - COLOR4D bg = m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ); - COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows, aDimmed ); - float borderWidth = getLineWidth( aTextBox, drawingShadows ); - - auto drawText = - [&]() - { - wxString shownText = aTextBox->GetShownText( true ); - TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes(); - - attrs.m_Angle = aTextBox->GetDrawRotation(); - attrs.m_StrokeWidth = KiROUND( getTextThickness( aTextBox ) ); - - strokeText( shownText, aTextBox->GetDrawPos(), attrs, aTextBox->GetFontMetrics() ); - }; - - m_gal->SetStrokeColor( color ); - m_gal->SetFillColor( color ); - - if( aLayer == LAYER_SELECTION_SHADOWS ) - { - m_gal->SetIsFill( true ); - m_gal->SetIsStroke( false ); - m_gal->SetLineWidth( borderWidth ); - - m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ), - mapCoords( aTextBox->GetEnd() ) ); - } - else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) - { - if( aTextBox->IsFilled() ) - { - m_gal->SetIsFill( true ); - m_gal->SetIsStroke( false ); - m_gal->SetLineWidth( borderWidth ); - - m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ), - mapCoords( aTextBox->GetEnd() ) ); - } - } - else if( aLayer == LAYER_DEVICE || aLayer == LAYER_PRIVATE_NOTES ) - { - drawText(); - - if( borderWidth > 0 ) - { - COLOR4D borderColor = aTextBox->GetStroke().GetColor(); - LINE_STYLE borderStyle = aTextBox->GetStroke().GetLineStyle(); - double transparency = aTextBox->GetForcedTransparency(); - - if( m_schSettings.m_OverrideItemColors || aTextBox->IsBrightened() - || borderColor == COLOR4D::UNSPECIFIED ) - { - borderColor = m_schSettings.GetLayerColor( aLayer ); - } - - if( transparency > 0.0 ) - borderColor = borderColor.WithAlpha( borderColor.a * ( 1.0 - transparency ) ); - - if( aDimmed ) - { - borderColor = borderColor.Mix( bg, 0.5f ); - borderColor.Desaturate( ); - } - - m_gal->SetIsFill( false ); - m_gal->SetIsStroke( true ); - m_gal->SetStrokeColor( borderColor ); - m_gal->SetLineWidth( borderWidth ); - - if( borderStyle <= LINE_STYLE::FIRST_TYPE || drawingShadows ) - { - m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ), - mapCoords( aTextBox->GetEnd() ) ); - } - else - { - std::vector shapes = aTextBox->MakeEffectiveShapes( true ); - - for( SHAPE* shape : shapes ) - { - STROKE_PARAMS::Stroke( shape, borderStyle, KiROUND( borderWidth ), - &m_schSettings, - [&]( const VECTOR2I& a, const VECTOR2I& b ) - { - // DrawLine has problem with 0 length lines so enforce minimum - if( a == b ) - m_gal->DrawLine( mapCoords( a+1 ), mapCoords( b ) ); - else - m_gal->DrawLine( mapCoords( a ), mapCoords( b ) ); - } ); - } - - for( SHAPE* shape : shapes ) - delete shape; - } - } - } -} - - int SCH_PAINTER::internalPinDecoSize( const LIB_PIN &aPin ) { if( m_schSettings.m_PinSymbolSize > 0 ) @@ -1143,11 +842,12 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed ) bool drawingDangling = aLayer == LAYER_DANGLING; bool drawingOP = aLayer == LAYER_OP_CURRENTS; bool isDangling = m_schSettings.m_IsSymbolEditor || aPin->HasFlag( IS_DANGLING ); + bool invertY = true; if( drawingShadows && !( aPin->IsBrightened() || aPin->IsSelected() ) ) return; - VECTOR2I pos = mapCoords( aPin->GetPosition() ); + VECTOR2I pos = MAP_COORDS( aPin->GetPosition() ); COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows, aDimmed ); if( !aPin->IsVisible() ) @@ -1520,7 +1220,7 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed ) } else if( drawingShadows ) { - boxText( text[i], aPos, attrs, aPin->GetFontMetrics() ); + boxText( text[i], aPos, attrs, aPin->GetFontMetrics(), invertY ); } else if( nonCached( aPin ) && renderTextAsBitmap ) { @@ -1798,8 +1498,14 @@ void SCH_PAINTER::draw( const SCH_LINE* aLine, int aLayer ) } -void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) +void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer, bool aDimmed ) { + if( !isUnitAndConversionShown( aShape ) ) + return; + + if( aShape->IsPrivate() && !m_schSettings.m_IsSymbolEditor ) + return; + bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; if( m_schSettings.IsPrinting() && drawingShadows ) @@ -1807,6 +1513,7 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) LINE_STYLE lineStyle = aShape->GetEffectiveLineStyle(); COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows ); + bool invertY = aShape->GetLayer() == LAYER_DEVICE; if( drawingShadows && !( aShape->IsBrightened() || aShape->IsSelected() ) ) return; @@ -1818,38 +1525,51 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) { case SHAPE_T::ARC: { - EDA_ANGLE startAngle; - EDA_ANGLE endAngle; - aShape->CalcArcAngles( startAngle, endAngle ); + VECTOR2D start = MAP_COORDS( shape->GetStart() ); + VECTOR2D mid = MAP_COORDS( shape->GetArcMid() ); + VECTOR2D end = MAP_COORDS( shape->GetEnd() ); + VECTOR2D center = CalcArcCenter( start, mid, end ); - m_gal->DrawArc( aShape->GetCenter(), aShape->GetRadius(), startAngle, - endAngle - startAngle ); + EDA_ANGLE startAngle( start - center ); + EDA_ANGLE midAngle( mid - center ); + EDA_ANGLE endAngle( end - center ); + + EDA_ANGLE angle1 = midAngle - startAngle; + EDA_ANGLE angle2 = endAngle - midAngle; + + EDA_ANGLE angle = angle1.Normalize180() + angle2.Normalize180(); + + m_gal->DrawArc( center, ( start - center ).EuclideanNorm(), startAngle, angle ); break; } case SHAPE_T::CIRCLE: - m_gal->DrawCircle( shape->GetPosition(), shape->GetRadius() ); + m_gal->DrawCircle( MAP_COORDS( shape->GetPosition() ), shape->GetRadius() ); break; case SHAPE_T::RECTANGLE: - m_gal->DrawRectangle( shape->GetPosition(), shape->GetEnd() ); + m_gal->DrawRectangle( MAP_COORDS( shape->GetPosition() ), + MAP_COORDS( shape->GetEnd() ) ); break; case SHAPE_T::POLY: { - std::deque pts; + const SHAPE_LINE_CHAIN poly = shape->GetPolyShape().Outline( 0 ); + std::deque mappedPts; - for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() ) - pts.push_back( pt ); + for( const VECTOR2I& pt : poly.CPoints() ) + mappedPts.push_back( MAP_COORDS( pt ) ); - m_gal->DrawPolygon( pts ); + m_gal->DrawPolygon( mappedPts ); break; } case SHAPE_T::BEZIER: { - m_gal->DrawCurve( shape->GetStart(), shape->GetBezierC1(), shape->GetBezierC2(), - shape->GetEnd() ); + m_gal->DrawCurve( MAP_COORDS( shape->GetStart() ), + MAP_COORDS( shape->GetBezierC1() ), + MAP_COORDS( shape->GetBezierC2() ), + MAP_COORDS( shape->GetEnd() ) ); break; } @@ -1882,7 +1602,7 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) drawShape( aShape ); } - else if( aLayer == LAYER_NOTES_BACKGROUND ) + else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) { // Do not fill the shape in B&W print mode, to avoid to visible items inside the shape if( aShape->IsFilled() && !m_schSettings.PrintBlackAndWhiteReq() ) @@ -1894,7 +1614,7 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) drawShape( aShape ); } } - else if( aLayer == LAYER_NOTES ) + else if( aLayer == LAYER_DEVICE || aLayer == LAYER_NOTES || aLayer == LAYER_PRIVATE_NOTES ) { float lineWidth = getLineWidth( aShape, drawingShadows ); @@ -1916,13 +1636,13 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) for( SHAPE* shape : shapes ) { STROKE_PARAMS::Stroke( shape, lineStyle, KiROUND( lineWidth ), &m_schSettings, - [&]( const VECTOR2I& a, const VECTOR2I& b ) + [this, invertY]( const VECTOR2I& a, const VECTOR2I& b ) { // DrawLine has problem with 0 length lines so enforce minimum if( a == b ) - m_gal->DrawLine( a+1, b ); + m_gal->DrawLine( MAP_COORDS( (a+1) ), MAP_COORDS( b ) ); else - m_gal->DrawLine( a, b ); + m_gal->DrawLine( MAP_COORDS( a ), MAP_COORDS( b ) ); } ); } @@ -1988,6 +1708,7 @@ void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer, bool aDimmed ) VECTOR2I text_offset = aText->GetSchematicTextOffset( &m_schSettings ); TEXT_ATTRIBUTES attrs = aText->GetAttributes(); KIFONT::FONT* font = getFont( aText ); + bool invertY = aText->GetLayer() == LAYER_DEVICE; attrs.m_Angle = aText->GetDrawRotation(); attrs.m_StrokeWidth = KiROUND( getTextThickness( aText ) ); @@ -2000,7 +1721,7 @@ void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer, bool aDimmed ) m_gal->SetIsStroke( false ); m_gal->SetIsFill( true ); - m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) ); + m_gal->DrawRectangle( MAP_COORDS( bBox.GetPosition() ), MAP_COORDS( bBox.GetEnd() ) ); } else if( aText->GetLayer() == LAYER_DEVICE ) { @@ -2141,7 +1862,7 @@ void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer, bool aDimmed ) } -void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) +void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer, bool aDimmed ) { if( aTextBox->Type() == SCH_TABLECELL_T ) { @@ -2151,14 +1872,22 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) return; } - bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; + if( !isUnitAndConversionShown( aTextBox ) ) + return; + + if( aTextBox->IsPrivate() && !m_schSettings.m_IsSymbolEditor ) + return; + + bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; if( m_schSettings.IsPrinting() && drawingShadows ) return; - COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows ); + COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows, aDimmed ); + COLOR4D bg = m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ); float borderWidth = getLineWidth( aTextBox, drawingShadows ); KIFONT::FONT* font = getFont( aTextBox ); + bool invertY = aTextBox->GetLayer() == LAYER_DEVICE; auto drawText = [&]() @@ -2204,9 +1933,10 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) m_gal->SetIsStroke( false ); m_gal->SetLineWidth( borderWidth ); - m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() ); + m_gal->DrawRectangle( MAP_COORDS( aTextBox->GetPosition() ), + MAP_COORDS( aTextBox->GetEnd() ) ); } - else if( aLayer == LAYER_NOTES_BACKGROUND ) + else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) { // Do not fill the shape in B&W print mode, to avoid to visible items // inside the shape @@ -2216,10 +1946,11 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) m_gal->SetIsStroke( false ); m_gal->SetLineWidth( borderWidth ); - m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() ); + m_gal->DrawRectangle( MAP_COORDS( aTextBox->GetPosition() ), + MAP_COORDS( aTextBox->GetEnd() ) ); } } - else if( aLayer == LAYER_NOTES ) + else if( aLayer == LAYER_DEVICE || aLayer == LAYER_NOTES || aLayer == LAYER_PRIVATE_NOTES ) { drawText(); @@ -2227,6 +1958,7 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) { COLOR4D borderColor = aTextBox->GetStroke().GetColor(); LINE_STYLE borderStyle = aTextBox->GetEffectiveLineStyle(); + double transparency = aTextBox->GetForcedTransparency(); if( m_schSettings.m_OverrideItemColors || aTextBox->IsBrightened() || borderColor == COLOR4D::UNSPECIFIED ) @@ -2234,6 +1966,15 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) borderColor = m_schSettings.GetLayerColor( aLayer ); } + if( transparency > 0.0 ) + borderColor = borderColor.WithAlpha( borderColor.a * ( 1.0 - transparency ) ); + + if( aDimmed ) + { + borderColor = borderColor.Mix( bg, 0.5f ); + borderColor.Desaturate( ); + } + m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetStrokeColor( borderColor ); @@ -2241,7 +1982,8 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) if( borderStyle <= LINE_STYLE::FIRST_TYPE || drawingShadows ) { - m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() ); + m_gal->DrawRectangle( MAP_COORDS( aTextBox->GetPosition() ), + MAP_COORDS( aTextBox->GetEnd() ) ); } else { @@ -2251,13 +1993,13 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) { STROKE_PARAMS::Stroke( shape, borderStyle, KiROUND( borderWidth ), &m_schSettings, - [&]( const VECTOR2I& a, const VECTOR2I& b ) + [this, invertY]( const VECTOR2I& a, const VECTOR2I& b ) { // DrawLine has problem with 0 length lines so enforce minimum if( a == b ) - m_gal->DrawLine( a+1, b ); + m_gal->DrawLine( MAP_COORDS( (a+1) ), MAP_COORDS( b ) ); else - m_gal->DrawLine( a, b ); + m_gal->DrawLine( MAP_COORDS( a ), MAP_COORDS( b ) ); } ); } @@ -2269,10 +2011,10 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) } -void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer ) +void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer, bool aDimmed ) { for( SCH_TABLECELL* cell : aTable->GetCells() ) - draw( cell, aLayer ); + draw( cell, aLayer, aDimmed ); if( aLayer == LAYER_SELECTION_SHADOWS ) return; @@ -2303,7 +2045,7 @@ void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer ) m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetStrokeColor( color ); - m_gal->SetLineWidth( lineWidth ); + m_gal->SetLineWidth( (float) lineWidth ); }; auto strokeShape = @@ -2490,6 +2232,8 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer ) // Use dummy symbol if the actual couldn't be found (or couldn't be locked). LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ? aSymbol->GetLibSymbolRef().get() : dummy(); + bool invertY = true; + std::vector originalPins; originalSymbol->GetPins( originalPins, unit, bodyStyle ); @@ -2505,7 +2249,7 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer ) for( SCH_ITEM& tempItem : tempSymbol.GetDrawItems() ) { tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED, - tempItem.Move( mapCoords( aSymbol->GetPosition() ) ); + tempItem.Move( MAP_COORDS( aSymbol->GetPosition() ) ); if( tempItem.Type() == SCH_TEXT_T ) { @@ -2514,9 +2258,9 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer ) if( textItem->HasTextVars() ) textItem->SetText( expandLibItemTextVars( textItem->GetText(), aSymbol ) ); } - else if( tempItem.Type() == LIB_TEXTBOX_T ) + else if( tempItem.Type() == SCH_TEXTBOX_T ) { - LIB_TEXTBOX* textboxItem = static_cast( &tempItem ); + SCH_TEXTBOX* textboxItem = static_cast( &tempItem ); if( textboxItem->HasTextVars() ) textboxItem->SetText( expandLibItemTextVars( textboxItem->GetText(), aSymbol ) ); @@ -2679,12 +2423,14 @@ void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer, bool aDimmed ) if( drawingShadows && getFont( aField )->IsOutline() ) { BOX2I shadow_box = bbox; + bool invertY = true; shadow_box.Inflate( KiROUND( getTextThickness( aField ) * 2 ) ); shadow_box.RevertYAxis(); m_gal->SetIsStroke( false ); m_gal->SetIsFill( true ); - m_gal->DrawRectangle( mapCoords( shadow_box.GetPosition() ), mapCoords( shadow_box.GetEnd() ) ); + m_gal->DrawRectangle( MAP_COORDS( shadow_box.GetPosition() ), + MAP_COORDS( shadow_box.GetEnd() ) ); } else { diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 7852ba5388..8529acc5cc 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -34,10 +34,7 @@ class LIB_PIN; -class LIB_SHAPE; class LIB_SYMBOL; -class LIB_TEXT; -class LIB_TEXTBOX; class SCH_SYMBOL; class SCH_FIELD; class SCH_JUNCTION; @@ -84,18 +81,15 @@ private: void drawItemBoundingBox( const EDA_ITEM* aItem ); void draw( const EDA_ITEM*, int, bool aDimmed ); void draw( const LIB_PIN* aPin, int aLayer, bool aDimmed ); - void draw( const LIB_SHAPE* aCircle, int aLayer, bool aDimmed ); void draw( const LIB_SYMBOL* aSymbol, int, bool aDrawFields = true, int aUnit = 0, int aBodyStyle = 0, bool aDimmed = false ); - void draw( const LIB_TEXT* aText, int aLayer, bool aDimmed ); - void draw( const LIB_TEXTBOX* aTextBox, int aLayer, bool aDimmed ); void draw( const SCH_SYMBOL* aSymbol, int aLayer ); + void draw( const SCH_SHAPE* aShape, int aLayer, bool aDimmed ); void draw( const SCH_JUNCTION* aJct, int aLayer ); void draw( const SCH_FIELD* aField, int aLayer, bool aDimmed ); - void draw( const SCH_SHAPE* aShape, int aLayer ); - void draw( const SCH_TEXTBOX* aTextBox, int aLayer ); + void draw( const SCH_TEXTBOX* aTextBox, int aLayer, bool aDimmed ); void draw( const SCH_TEXT* aText, int aLayer, bool aDimmed ); - void draw( const SCH_TABLE* aTable, int aLayer ); + void draw( const SCH_TABLE* aTable, int aLayer, bool aDimmed ); void draw( const SCH_LABEL* aText, int aLayer ); void draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer ); void draw( const SCH_HIERLABEL* aLabel, int aLayer ); @@ -139,7 +133,8 @@ private: void knockoutText( const wxString& aText, const VECTOR2D& aPosition, const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics ); void boxText( const wxString& aText, const VECTOR2D& aPosition, - const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics ); + const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics, + bool aInvertY ); wxString expandLibItemTextVars( const wxString& aSourceText, const SCH_SYMBOL* aSymbolContext ); diff --git a/eeschema/sch_shape.cpp b/eeschema/sch_shape.cpp index e17d3c2e5e..949e7ce031 100644 --- a/eeschema/sch_shape.cpp +++ b/eeschema/sch_shape.cpp @@ -32,14 +32,14 @@ #include #include #include -#include "plotters/plotter.h" -SCH_SHAPE::SCH_SHAPE( SHAPE_T aShape, int aLineWidth, FILL_T aFillType, KICAD_T aType ) : +SCH_SHAPE::SCH_SHAPE( SHAPE_T aShape, SCH_LAYER_ID aLayer, int aLineWidth, FILL_T aFillType, + KICAD_T aType ) : SCH_ITEM( nullptr, aType ), EDA_SHAPE( aShape, aLineWidth, aFillType ) { - SetLayer( LAYER_NOTES ); + SetLayer( aLayer ); } @@ -111,108 +111,175 @@ void SCH_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) } +bool SCH_SHAPE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const +{ + if( m_layer == LAYER_DEVICE ) + return hitTest( DefaultTransform.TransformCoordinate( aPosition ), aAccuracy ); + else + return hitTest( aPosition, aAccuracy ); +} + +bool SCH_SHAPE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const +{ + if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) ) + return false; + + if( m_layer == LAYER_DEVICE ) + return hitTest( DefaultTransform.TransformCoordinate( aRect ), aContained, aAccuracy ); + else + return hitTest( aRect, aContained, aAccuracy ); +} + + void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) { - int pen_size = GetEffectivePenWidth( getRenderSettings( aPlotter ) ); + if( IsPrivate() ) + return; - static std::vector cornerList; + SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); + int pen_size = GetEffectivePenWidth( renderSettings ); + + static std::vector ptList; if( GetShape() == SHAPE_T::POLY ) { - cornerList.clear(); + ptList.clear(); for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() ) - cornerList.push_back( pt ); + { + if( m_layer == LAYER_DEVICE ) + ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset ); + else + ptList.push_back( pt ); + } } + else if( GetShape() == SHAPE_T::BEZIER ) + { + ptList.clear(); + + for( const VECTOR2I& pt : m_bezierPoints ) + { + if( m_layer == LAYER_DEVICE ) + ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset ); + else + ptList.push_back( pt ); + } + } + + COLOR4D color = GetStroke().GetColor(); + COLOR4D bg = renderSettings->GetBackgroundColor(); + LINE_STYLE lineStyle = GetStroke().GetLineStyle(); + FILL_T fill = m_fill; if( aBackground ) { if( !aPlotter->GetColorMode() ) return; - if( IsFilled() ) + switch( m_fill ) { - if( GetFillColor() != COLOR4D::UNSPECIFIED ) - aPlotter->SetColor( GetFillColor() ); - else - aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_NOTES ) ); + case FILL_T::FILLED_SHAPE: + return; - switch( GetShape() ) - { - case SHAPE_T::ARC: - aPlotter->Arc( GetStart(), GetArcMid(), GetEnd(), m_fill, 0 ); - break; - - case SHAPE_T::CIRCLE: - aPlotter->Circle( getCenter(), GetRadius() * 2, m_fill, 0 ); - break; - - case SHAPE_T::RECTANGLE: - aPlotter->Rect( GetStart(), GetEnd(), m_fill, 0 ); - break; - - case SHAPE_T::POLY: - aPlotter->PlotPoly( cornerList, m_fill, 0 ); - break; - - case SHAPE_T::BEZIER: - aPlotter->PlotPoly( m_bezierPoints, m_fill, 0 ); - break; - - default: - UNIMPLEMENTED_FOR( SHAPE_T_asString() ); - } - } - } - else /* if( aForeground ) */ - { - if( aPlotter->GetColorMode() && GetStroke().GetColor() != COLOR4D::UNSPECIFIED ) - aPlotter->SetColor( GetStroke().GetColor() ); - else - aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_NOTES ) ); - - aPlotter->SetCurrentLineWidth( pen_size ); - aPlotter->SetDash( pen_size, GetEffectiveLineStyle() ); - - switch( GetShape() ) - { - case SHAPE_T::ARC: - aPlotter->Arc( GetStart(), GetArcMid(), GetEnd(), FILL_T::NO_FILL, pen_size ); + case FILL_T::FILLED_WITH_COLOR: + color = GetFillColor(); break; - case SHAPE_T::CIRCLE: - aPlotter->Circle( getCenter(), GetRadius() * 2, FILL_T::NO_FILL, pen_size ); - break; - - case SHAPE_T::RECTANGLE: - aPlotter->Rect( GetStart(), GetEnd(), FILL_T::NO_FILL, pen_size ); - break; - - case SHAPE_T::POLY: - aPlotter->PlotPoly( cornerList, FILL_T::NO_FILL, pen_size ); - break; - - case SHAPE_T::BEZIER: - aPlotter->PlotPoly( m_bezierPoints, FILL_T::NO_FILL, pen_size ); + case FILL_T::FILLED_WITH_BG_BODYCOLOR: + color = renderSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND ); break; default: - UNIMPLEMENTED_FOR( SHAPE_T_asString() ); + return; } - aPlotter->SetDash( pen_size, LINE_STYLE::SOLID ); + pen_size = 0; + lineStyle = LINE_STYLE::SOLID; } + else /* if( aForeground ) */ + { + if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) + color = renderSettings->GetLayerColor( m_layer ); + + if( lineStyle == LINE_STYLE::DEFAULT ) + lineStyle = LINE_STYLE::SOLID; + + if( m_fill == FILL_T::FILLED_SHAPE ) + fill = m_fill; + else + fill = FILL_T::NO_FILL; + + pen_size = GetEffectivePenWidth( renderSettings ); + } + + if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() ) + bg = COLOR4D::WHITE; + + if( aDimmed ) + { + color.Desaturate( ); + color = color.Mix( bg, 0.5f ); + } + + aPlotter->SetColor( color ); + aPlotter->SetCurrentLineWidth( pen_size ); + aPlotter->SetDash( pen_size, lineStyle ); + + VECTOR2I start = m_start; + VECTOR2I end = m_end; + VECTOR2I mid, center; + + if( m_layer == LAYER_DEVICE ) + { + start = renderSettings->TransformCoordinate( start ) + aOffset; + end = renderSettings->TransformCoordinate( end ) + aOffset; + } + + switch( GetShape() ) + { + case SHAPE_T::ARC: + mid = GetArcMid(); + + if( m_layer == LAYER_DEVICE ) + mid = renderSettings->TransformCoordinate( mid ) + aOffset; + + aPlotter->Arc( start, mid, end, fill, pen_size ); + break; + + case SHAPE_T::CIRCLE: + center = getCenter(); + + if( m_layer == LAYER_DEVICE ) + center = renderSettings->TransformCoordinate( center ) + aOffset; + + aPlotter->Circle( center, GetRadius() * 2, fill, pen_size ); + break; + + case SHAPE_T::RECTANGLE: + aPlotter->Rect( start, end, fill, pen_size ); + break; + + case SHAPE_T::POLY: + case SHAPE_T::BEZIER: + aPlotter->PlotPoly( ptList, fill, pen_size ); + break; + + default: + UNIMPLEMENTED_FOR( SHAPE_T_asString() ); + } + + aPlotter->SetDash( pen_size, LINE_STYLE::SOLID ); } -int SCH_SHAPE::GetPenWidth() const +int SCH_SHAPE::GetEffectiveWidth() const { - if( m_stroke.GetWidth() > 0 ) - return m_stroke.GetWidth(); + if( GetPenWidth() > 0 ) + return GetPenWidth(); // Historically 0 meant "default width" and negative numbers meant "don't stroke". - if( GetWidth() < 0 ) + if( GetPenWidth() < 0 ) return 0; SCHEMATIC* schematic = Schematic(); @@ -224,32 +291,51 @@ int SCH_SHAPE::GetPenWidth() const } +const BOX2I SCH_SHAPE::GetBoundingBox() const +{ + BOX2I bbox = getBoundingBox(); + + if( m_layer == LAYER_DEVICE ) // TODO: nuke symbol editor's upside-down coordinate system + bbox.RevertYAxis(); + + return bbox; +} + + void SCH_SHAPE::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) { + if( IsPrivate() ) + return; + wxDC* DC = aSettings->GetPrintDC(); COLOR4D color; - unsigned ptCount = 0; - VECTOR2I* buffer = nullptr; + static std::vector ptList; if( GetShape() == SHAPE_T::POLY ) { - SHAPE_LINE_CHAIN poly = m_poly.Outline( 0 ); + ptList.clear(); - ptCount = poly.GetPointCount(); - buffer = new VECTOR2I[ptCount]; - - for( unsigned ii = 0; ii < ptCount; ++ii ) - buffer[ii] = poly.CPoint( ii ); + for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() ) + { + if( m_layer == LAYER_DEVICE ) + ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset ); + else + ptList.push_back( pt ); + } } else if( GetShape() == SHAPE_T::BEZIER ) { - ptCount = m_bezierPoints.size(); - buffer = new VECTOR2I[ptCount]; + ptList.clear(); - for( size_t ii = 0; ii < ptCount; ++ii ) - buffer[ii] = m_bezierPoints[ii]; + for( const VECTOR2I& pt : m_bezierPoints ) + { + if( m_layer == LAYER_DEVICE ) + ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset ); + else + ptList.push_back( pt ); + } } if( GetFillMode() == FILL_T::FILLED_WITH_COLOR ) @@ -274,57 +360,96 @@ void SCH_SHAPE::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit break; case SHAPE_T::POLY: - GRPoly( DC, ptCount, buffer, true, 0, color, color ); + GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, color, color ); break; case SHAPE_T::BEZIER: - GRPoly( DC, ptCount, buffer, true, 0, color, color ); + GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, color, color ); break; default: UNIMPLEMENTED_FOR( SHAPE_T_asString() ); } } - - delete[] buffer; } void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) { + if( IsPrivate() ) + return; + int penWidth = GetEffectivePenWidth( aSettings ); wxDC* DC = aSettings->GetPrintDC(); COLOR4D color = GetStroke().GetColor(); + COLOR4D bg = aSettings->GetBackgroundColor(); if( color == COLOR4D::UNSPECIFIED ) color = aSettings->GetLayerColor( LAYER_NOTES ); - COLOR4D bg = aSettings->GetBackgroundColor(); - if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() ) bg = COLOR4D::WHITE; - unsigned ptCount = 0; - VECTOR2I* buffer = nullptr; + if( aDimmed ) + { + color.Desaturate( ); + color = color.Mix( bg, 0.5f ); + } + + static std::vector ptList; if( GetShape() == SHAPE_T::POLY ) { - SHAPE_LINE_CHAIN poly = m_poly.Outline( 0 ); + ptList.clear(); - ptCount = poly.GetPointCount(); - buffer = new VECTOR2I[ptCount]; - - for( unsigned ii = 0; ii < ptCount; ++ii ) - buffer[ii] = poly.CPoint( ii ); + for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() ) + { + if( m_layer == LAYER_DEVICE ) + ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset ); + else + ptList.push_back( pt ); + } } else if( GetShape() == SHAPE_T::BEZIER ) { - ptCount = m_bezierPoints.size(); - buffer = new VECTOR2I[ptCount]; + ptList.clear(); - for( size_t ii = 0; ii < ptCount; ++ii ) - buffer[ii] = m_bezierPoints[ii]; + for( const VECTOR2I& pt : m_bezierPoints ) + { + if( m_layer == LAYER_DEVICE ) + ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset ); + else + ptList.push_back( pt ); + } + } + + VECTOR2I start = GetStart(); + VECTOR2I end = GetEnd(); + VECTOR2I center = ( GetShape() == SHAPE_T::ARC ) ? getCenter() : VECTOR2I( 0, 0 ); + + if( m_layer == LAYER_DEVICE ) + { + start = aSettings->TransformCoordinate( start ) + aOffset; + end = aSettings->TransformCoordinate( end ) + aOffset; + + if( GetShape() == SHAPE_T::ARC ) + { + center = aSettings->TransformCoordinate( center ) + aOffset; + + EDA_ANGLE t1, t2; + + CalcArcAngles( t1, t2 ); + + // N.B. The order of evaluation is critical here as MapAngles will modify t1, t2 + // and the Normalize routine depends on these modifications for the correct output + bool transformed = aSettings->m_Transform.MapAngles( &t1, &t2 ); + EDA_ANGLE arc_angle = ( t1 - t2 ).Normalize180(); + bool transformed2 = ( arc_angle > ANGLE_0 ) && ( arc_angle < ANGLE_180 ); + + if( transformed == transformed2 ) + std::swap( start, end ); + } } COLOR4D fillColor = COLOR4D::UNSPECIFIED; @@ -333,29 +458,37 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod fillColor = color; else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR ) fillColor = GetFillColor(); + else if( GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR ) + fillColor = aSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND ); if( fillColor != COLOR4D::UNSPECIFIED && !aForceNoFill ) { + if( aDimmed ) + { + fillColor.Desaturate( ); + fillColor = fillColor.Mix( bg, 0.5f ); + } + switch( GetShape() ) { case SHAPE_T::ARC: - GRFilledArc( DC, GetEnd(), GetStart(), getCenter(), 0, fillColor, fillColor ); + GRFilledArc( DC, end, start, center, 0, fillColor, fillColor ); break; case SHAPE_T::CIRCLE: - GRFilledCircle( DC, GetStart(), GetRadius(), 0, fillColor, fillColor ); + GRFilledCircle( DC, start, GetRadius(), 0, fillColor, fillColor ); break; case SHAPE_T::RECTANGLE: - GRFilledRect( DC, GetStart(), GetEnd(), 0, fillColor, fillColor ); + GRFilledRect( DC, start, end, 0, fillColor, fillColor ); break; case SHAPE_T::POLY: - GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor ); + GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, fillColor, fillColor ); break; case SHAPE_T::BEZIER: - GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor ); + GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, fillColor, fillColor ); break; default: @@ -363,6 +496,8 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod } } + penWidth = std::max( penWidth, aSettings->GetMinPenWidth() ); + if( penWidth > 0 ) { if( GetEffectiveLineStyle() == LINE_STYLE::SOLID ) @@ -370,23 +505,23 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod switch( GetShape() ) { case SHAPE_T::ARC: - GRArc( DC, GetEnd(), GetStart(), getCenter(), penWidth, color ); + GRArc( DC, end, start, center, penWidth, color ); break; case SHAPE_T::CIRCLE: - GRCircle( DC, GetStart(), GetRadius(), penWidth, color ); + GRCircle( DC, start, GetRadius(), penWidth, color ); break; case SHAPE_T::RECTANGLE: - GRRect( DC, GetStart(), GetEnd(), penWidth, color ); + GRRect( DC, start, end, penWidth, color ); break; case SHAPE_T::POLY: - GRPoly( DC, ptCount, buffer, false, penWidth, color, color ); + GRPoly( DC, (int) ptList.size(), ptList.data(), false, penWidth, color, color ); break; case SHAPE_T::BEZIER: - GRPoly( DC, ptCount, buffer, false, penWidth, color, color ); + GRPoly( DC, (int) ptList.size(), ptList.data(), false, penWidth, color, color ); break; default: @@ -400,24 +535,34 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod for( SHAPE* shape : shapes ) { STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings, - [&]( const VECTOR2I& a, const VECTOR2I& b ) - { - GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color ); - } ); + [&]( const VECTOR2I& a, const VECTOR2I& b ) + { + if( m_layer == LAYER_DEVICE ) + { + VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset; + VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset; + GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color ); + } + else + { + GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color ); + } + } ); } for( SHAPE* shape : shapes ) delete shape; } } - - delete[] buffer; } void SCH_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { - SCH_ITEM::GetMsgPanelInfo( aFrame, aList ); + if( m_layer == LAYER_DEVICE ) + getSymbolEditorMsgPanelInfo( aFrame, aList ); + else + SCH_ITEM::GetMsgPanelInfo( aFrame, aList ); ShapeGetMsgPanelInfo( aFrame, aList ); } @@ -459,12 +604,12 @@ BITMAPS SCH_SHAPE::GetMenuImage() const { switch( GetShape() ) { - case SHAPE_T::SEGMENT: return BITMAPS::add_line; - case SHAPE_T::ARC: return BITMAPS::add_arc; - case SHAPE_T::CIRCLE: return BITMAPS::add_circle; - case SHAPE_T::RECTANGLE: return BITMAPS::add_rectangle; - case SHAPE_T::POLY: return BITMAPS::add_graphical_segments; - case SHAPE_T::BEZIER: return BITMAPS::add_bezier; + case SHAPE_T::SEGMENT: return BITMAPS::add_line; + case SHAPE_T::ARC: return BITMAPS::add_arc; + case SHAPE_T::CIRCLE: return BITMAPS::add_circle; + case SHAPE_T::RECTANGLE: return BITMAPS::add_rectangle; + case SHAPE_T::POLY: return BITMAPS::add_graphical_segments; + case SHAPE_T::BEZIER: return BITMAPS::add_bezier; default: UNIMPLEMENTED_FOR( SHAPE_T_asString() ); @@ -476,8 +621,15 @@ BITMAPS SCH_SHAPE::GetMenuImage() const void SCH_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const { aCount = 3; - aLayers[0] = LAYER_NOTES; - aLayers[1] = LAYER_NOTES_BACKGROUND; + aLayers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : m_layer; + + if( m_layer == LAYER_PRIVATE_NOTES ) + aLayers[1] = LAYER_NOTES_BACKGROUND; + else if( m_layer == LAYER_DEVICE ) + aLayers[1] = LAYER_DEVICE_BACKGROUND; + else + aLayers[1] = LAYER_NOTES_BACKGROUND; + aLayers[2] = LAYER_SELECTION_SHADOWS; } @@ -505,27 +657,53 @@ bool SCH_SHAPE::operator==( const SCH_ITEM& aOther ) const const SCH_SHAPE& other = static_cast( aOther ); - return EDA_SHAPE::operator==( other ); + return SCH_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other ); } double SCH_SHAPE::Similarity( const SCH_ITEM& aOther ) const { + if( m_Uuid == aOther.m_Uuid ) + return 1.0; + if( aOther.Type() != Type() ) return 0.0; const SCH_SHAPE& other = static_cast( aOther ); - double similarity = EDA_SHAPE::Similarity( other ); + double similarity = SimilarityBase( other ); + + similarity *= EDA_SHAPE::Similarity( other ); return similarity; } +int SCH_SHAPE::compare( const SCH_ITEM& aOther, int aCompareFlags ) const +{ + int retv = SCH_ITEM::compare( aOther, aCompareFlags ); + + if( retv ) + return retv; + + return EDA_SHAPE::Compare( &static_cast( aOther ) ); +} + + static struct SCH_SHAPE_DESC { SCH_SHAPE_DESC() { + ENUM_MAP& fillEnum = ENUM_MAP::Instance(); + + if( fillEnum.Choices().GetCount() == 0 ) + { + fillEnum.Map( FILL_T::NO_FILL, _HKI( "None" ) ) + .Map( FILL_T::FILLED_SHAPE, _HKI( "Body outline color" ) ) + .Map( FILL_T::FILLED_WITH_BG_BODYCOLOR, _HKI( "Body background color" ) ) + .Map( FILL_T::FILLED_WITH_COLOR, _HKI( "Fill color" ) ); + } + PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); REGISTER_TYPE( SCH_SHAPE ); propMgr.AddTypeCast( new TYPE_CAST ); @@ -544,9 +722,40 @@ static struct SCH_SHAPE_DESC return false; }; + auto isSymbolItem = + []( INSPECTABLE* aItem ) -> bool + { + if( SCH_SHAPE* shape = dynamic_cast( aItem ) ) + return shape->GetLayer() == LAYER_DEVICE; + + return false; + }; + + auto isSchematicItem = + []( INSPECTABLE* aItem ) -> bool + { + if( SCH_SHAPE* shape = dynamic_cast( aItem ) ) + return shape->GetLayer() != LAYER_DEVICE; + + return false; + }; + propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( SCH_ITEM ), _HKI( "Position X" ), isPolygon ); propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( SCH_ITEM ), _HKI( "Position Y" ), isPolygon ); + + propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( EDA_SHAPE ), + _HKI( "Filled" ), isSchematicItem ); + + void ( SCH_SHAPE::*fillModeSetter )( FILL_T ) = &SCH_SHAPE::SetFillMode; + FILL_T ( SCH_SHAPE::*fillModeGetter )() const = &SCH_SHAPE::GetFillMode; + + propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Fill" ), + fillModeSetter, fillModeGetter ), + _HKI( "Shape Properties" ) ) + .SetAvailableFunc( isSymbolItem ); } } _SCH_SHAPE_DESC; + +ENUM_TO_WXANY( FILL_T ); diff --git a/eeschema/sch_shape.h b/eeschema/sch_shape.h index 81da7a56d7..6d9a1ddbe7 100644 --- a/eeschema/sch_shape.h +++ b/eeschema/sch_shape.h @@ -32,13 +32,12 @@ class SCH_SHAPE : public SCH_ITEM, public EDA_SHAPE { public: - SCH_SHAPE( SHAPE_T aShape = SHAPE_T::UNDEFINED, int aLineWidth = 0, - FILL_T aFillType = FILL_T::NO_FILL, - KICAD_T aType = SCH_SHAPE_T ); + SCH_SHAPE( SHAPE_T aShape = SHAPE_T::UNDEFINED, SCH_LAYER_ID aLayer = LAYER_NOTES, + int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL, KICAD_T aType = SCH_SHAPE_T ); // Do not create a copy constructor. The one generated by the compiler is adequate. - virtual ~SCH_SHAPE() {} + virtual ~SCH_SHAPE() override {} wxString GetClass() const override { @@ -47,24 +46,17 @@ public: void SwapData( SCH_ITEM* aItem ) override; - bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override - { - return hitTest( aPosition, aAccuracy ); - } + bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; + bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override; - bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override - { - return hitTest( aRect, aContained, aAccuracy ); - } - - int GetPenWidth() const override; - - int GetEffectiveWidth() const override { return GetPenWidth(); } + int GetPenWidth() const override { return GetStroke().GetWidth(); } bool HasLineStroke() const override { return true; } STROKE_PARAMS GetStroke() const override { return m_stroke; } void SetStroke( const STROKE_PARAMS& aStroke ) override; + int GetEffectiveWidth() const override; + LINE_STYLE GetEffectiveLineStyle() const { if( m_stroke.GetLineStyle() == LINE_STYLE::DEFAULT ) @@ -73,10 +65,10 @@ public: return m_stroke.GetLineStyle(); } - const BOX2I GetBoundingBox() const override { return getBoundingBox(); } + const BOX2I GetBoundingBox() const override; - VECTOR2I GetPosition() const override { return getPosition(); } - void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); } + VECTOR2I GetPosition() const override { return getPosition(); } + void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); } VECTOR2I GetCenter() const { return getCenter(); } @@ -96,6 +88,17 @@ public: void AddPoint( const VECTOR2I& aPosition ); + /** + * Make a set of SHAPE objects representing the SCH_SHAPE. Caller owns the objects. + * + * @param aEdgeOnly indicates only edges should be generated (even if 0 width), and no fill + * shapes. + */ + std::vector MakeEffectiveShapes( bool aEdgeOnly = false ) const override + { + return makeEffectiveShapes( aEdgeOnly, true ); + } + void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override; @@ -128,6 +131,16 @@ protected: { m_fill = aFlag ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL; } + + /** + * @copydoc SCH_ITEM::compare() + * + * The circle specific sort order is as follows: + * - Circle horizontal (X) position. + * - Circle vertical (Y) position. + * - Circle radius. + */ + int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override; }; diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index c0580cff15..2be5272381 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -80,16 +80,15 @@ static LIB_SYMBOL* dummy() { symbol = new LIB_SYMBOL( wxEmptyString ); - LIB_SHAPE* square = new LIB_SHAPE( symbol, SHAPE_T::RECTANGLE ); + SCH_SHAPE* square = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ); square->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) ); square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) ); + symbol->AddDrawItem( square ); SCH_TEXT* text = new SCH_TEXT( { 0, 0 }, wxT( "??"), LAYER_DEVICE ); text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) ); - - symbol->AddDrawItem( square ); symbol->AddDrawItem( text ); } diff --git a/eeschema/sch_tablecell.cpp b/eeschema/sch_tablecell.cpp index e3c56650b7..65fb10abf8 100644 --- a/eeschema/sch_tablecell.cpp +++ b/eeschema/sch_tablecell.cpp @@ -24,13 +24,12 @@ #include #include #include -#include #include #include SCH_TABLECELL::SCH_TABLECELL( int aLineWidth, FILL_T aFillType ) : - SCH_TEXTBOX( aLineWidth, aFillType, wxEmptyString, SCH_TABLECELL_T ), + SCH_TEXTBOX( LAYER_NOTES, aLineWidth, aFillType, wxEmptyString, SCH_TABLECELL_T ), m_colSpan( 1 ), m_rowSpan( 1 ) { diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 418bf7c684..7d7e04626f 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -421,7 +421,7 @@ void SCH_TEXT::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBody const BOX2I SCH_TEXT::GetBoundingBox() const { - if( m_layer == LAYER_DEVICE ) // TODO: remove upside-down coordinate system in symbol editor + if( m_layer == LAYER_DEVICE ) // TODO: nuke symbol editor's upside-down coordinate system { BOX2I bbox = GetTextBox( -1, true ); bbox.RevertYAxis(); @@ -525,7 +525,7 @@ BITMAPS SCH_TEXT::GetMenuImage() const bool SCH_TEXT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const { - if( m_layer == LAYER_DEVICE ) // TODO: remove upside-down coordinate system in symbol editor + if( m_layer == LAYER_DEVICE ) // TODO: nuke symbol editor's upside-down coordinate system { EDA_TEXT tmp_text( *this ); tmp_text.SetTextPos( DefaultTransform.TransformCoordinate( GetTextPos() ) ); @@ -557,7 +557,7 @@ bool SCH_TEXT::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) con rect.Inflate( aAccuracy ); - if( m_layer == LAYER_DEVICE ) // TODO: remove upside-down coordinate system in symbol editor + if( m_layer == LAYER_DEVICE ) // TODO: nuke symbol editor's upside-down coordinate system { BOX2I bBox = GetTextBox(); bBox.RevertYAxis(); diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index 2de47c1fac..6a40ddaa28 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -34,18 +34,17 @@ #include #include #include -#include -#include #include #include #include -SCH_TEXTBOX::SCH_TEXTBOX( int aLineWidth, FILL_T aFillType, const wxString& text, KICAD_T aType ) : - SCH_SHAPE( SHAPE_T::RECTANGLE, aLineWidth, aFillType, aType ), - EDA_TEXT( schIUScale, text ) +SCH_TEXTBOX::SCH_TEXTBOX( SCH_LAYER_ID aLayer, int aLineWidth, FILL_T aFillType, + const wxString& aText, KICAD_T aType ) : + SCH_SHAPE( SHAPE_T::RECTANGLE, aLayer, aLineWidth, aFillType, aType ), + EDA_TEXT( schIUScale, aText ) { - m_layer = LAYER_NOTES; + m_layer = aLayer; SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); SetVertJustify( GR_TEXT_V_ALIGN_TOP ); @@ -75,7 +74,10 @@ SCH_TEXTBOX::SCH_TEXTBOX( const SCH_TEXTBOX& aText ) : int SCH_TEXTBOX::GetLegacyTextMargin() const { - return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 ); + if( m_layer == LAYER_DEVICE ) + return KiROUND( GetTextSize().y * 0.8 ); + else + return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 ); } @@ -120,9 +122,19 @@ void SCH_TEXTBOX::Rotate90( bool aClockwise ) VECTOR2I SCH_TEXTBOX::GetDrawPos() const { - BOX2I bbox( m_start, m_end - m_start ); + BOX2I bbox; - bbox.Normalize(); + if( m_layer == LAYER_DEVICE ) // TODO: nuke symbol editor's upside-down coordinate system + { + bbox = BOX2I( VECTOR2I( std::min( m_start.x, m_end.x ), std::min( -m_start.y, -m_end.y ) ), + VECTOR2I( abs( m_end.x - m_start.x ), abs( m_end.y - m_start.y ) ) ); + } + else + { + bbox = BOX2I( m_start, m_end - m_start ); + + bbox.Normalize(); + } VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom ); @@ -265,14 +277,21 @@ KIFONT::FONT* SCH_TEXTBOX::getDrawFont() const void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) { + if( IsPrivate() ) + return; + wxDC* DC = aSettings->GetPrintDC(); - int penWidth = GetPenWidth(); + int penWidth = GetEffectivePenWidth( aSettings ); bool blackAndWhiteMode = GetGRForceBlackPenState(); VECTOR2I pt1 = GetStart(); VECTOR2I pt2 = GetEnd(); COLOR4D color = GetStroke().GetColor(); + COLOR4D bg = aSettings->GetBackgroundColor(); LINE_STYLE lineStyle = GetStroke().GetLineStyle(); + if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() ) + bg = COLOR4D::WHITE; + if( GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode && !aForceNoFill ) GRFilledRect( DC, pt1, pt2, 0, GetFillColor(), GetFillColor() ); @@ -283,6 +302,12 @@ void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aB if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED ) color = aSettings->GetLayerColor( m_layer ); + if( aDimmed ) + { + color.Desaturate( ); + color = color.Mix( bg, 0.5f ); + } + if( lineStyle == LINE_STYLE::DEFAULT ) lineStyle = LINE_STYLE::SOLID; @@ -297,10 +322,19 @@ void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aB for( SHAPE* shape : shapes ) { STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings, - [&]( const VECTOR2I& a, const VECTOR2I& b ) - { - GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color ); - } ); + [&]( const VECTOR2I& a, const VECTOR2I& b ) + { + if( m_layer == LAYER_DEVICE ) + { + VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset; + VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset; + GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color ); + } + else + { + GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color ); + } + } ); } for( SHAPE* shape : shapes ) @@ -313,7 +347,34 @@ void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aB if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED ) color = aSettings->GetLayerColor( m_layer ); - EDA_TEXT::Print( aSettings, aOffset, color ); + if( aDimmed ) + { + color.Desaturate( ); + color = color.Mix( bg, 0.5f ); + } + + if( m_layer == LAYER_DEVICE ) + { + SCH_TEXTBOX temp( *this ); + + if( aSettings->m_Transform.y1 ) + { + temp.SetTextAngle( temp.GetTextAngle() == ANGLE_HORIZONTAL ? ANGLE_VERTICAL + : ANGLE_HORIZONTAL ); + } + + // NB: GetDrawPos() will want Symbol Editor (upside-down) coordinates + temp.SetStart( VECTOR2I( pt1.x, -pt1.y ) ); + temp.SetEnd( VECTOR2I( pt2.x, -pt2.y ) ); + + GRPrintText( DC, temp.GetDrawPos(), color, temp.GetShownText( true ), temp.GetTextAngle(), + temp.GetTextSize(), temp.GetHorizJustify(), temp.GetVertJustify(), penWidth, + temp.IsItalic(), temp.IsBold(), getDrawFont(), GetFontMetrics() ); + } + else + { + EDA_TEXT::Print( aSettings, aOffset, color ); + } } @@ -345,11 +406,6 @@ wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtr text = ExpandTextVars( text, &textResolver ); } - KIFONT::FONT* font = GetFont(); - - if( !font ) - font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() ); - VECTOR2I size = GetEnd() - GetStart(); int colWidth; @@ -358,7 +414,8 @@ wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtr else colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() ); - font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() ); + getDrawFont()->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), + IsItalic() ); return text; } @@ -399,7 +456,7 @@ void SCH_TEXTBOX::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const wxString SCH_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const { - return wxString::Format( _( "Graphic Text Box" ) ); + return wxString::Format( _( "Text Box" ) ); } @@ -412,16 +469,20 @@ BITMAPS SCH_TEXTBOX::GetMenuImage() const void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) { + if( IsPrivate() ) + return; + if( aBackground ) { SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed ); return; } - SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet(); + SCH_SHEET_PATH* sheet = Schematic() ? &Schematic()->CurrentSheet() : nullptr; SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); int penWidth = GetEffectivePenWidth( renderSettings ); COLOR4D color = GetStroke().GetColor(); + COLOR4D bg = renderSettings->GetBackgroundColor(); LINE_STYLE lineStyle = GetStroke().GetLineStyle(); if( penWidth > 0 ) @@ -429,6 +490,12 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) color = renderSettings->GetLayerColor( m_layer ); + if( aDimmed ) + { + color.Desaturate( ); + color = color.Mix( bg, 0.5f ); + } + if( lineStyle == LINE_STYLE::DEFAULT ) lineStyle = LINE_STYLE::SOLID; @@ -438,16 +505,22 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS aPlotter->SetDash( penWidth, LINE_STYLE::SOLID ); } - KIFONT::FONT* font = GetFont(); - - if( !font ) - font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() ); + KIFONT::FONT* font = getDrawFont(); color = GetTextColor(); if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) color = renderSettings->GetLayerColor( m_layer ); + if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() ) + bg = COLOR4D::WHITE; + + if( aDimmed ) + { + color.Desaturate( ); + color = color.Mix( bg, 0.5f ); + } + penWidth = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() ); penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() ); aPlotter->SetCurrentLineWidth( penWidth ); @@ -457,7 +530,27 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' ); positions.reserve( strings_list.Count() ); - GetLinePositions( positions, (int) strings_list.Count() ); + if( m_layer == LAYER_DEVICE ) + { + VECTOR2I start = renderSettings->TransformCoordinate( m_start ) + aOffset; + VECTOR2I end = renderSettings->TransformCoordinate( m_end ) + aOffset; + SCH_TEXTBOX temp( *this ); + + if( renderSettings->m_Transform.y1 ) + { + temp.SetTextAngle( temp.GetTextAngle() == ANGLE_HORIZONTAL ? ANGLE_VERTICAL + : ANGLE_HORIZONTAL ); + } + + // NB: GetDrawPos() will want Symbol Editor (upside-down) coordinates + temp.SetStart( VECTOR2I( start.x, -start.y ) ); + temp.SetEnd( VECTOR2I( end.x, -end.y ) ); + temp.GetLinePositions( positions, (int) strings_list.Count() ); + } + else + { + GetLinePositions( positions, (int) strings_list.Count() ); + } TEXT_ATTRIBUTES attrs = GetAttributes(); attrs.m_StrokeWidth = penWidth; @@ -528,12 +621,15 @@ bool SCH_TEXTBOX::operator==( const SCH_ITEM& aOther ) const double SCH_TEXTBOX::Similarity( const SCH_ITEM& aOther ) const { + if( m_Uuid == aOther.m_Uuid ) + return 1.0; + if( aOther.Type() != Type() ) return 0.0; auto other = static_cast( aOther ); - double similarity = 1.0; + double similarity = SimilarityBase( other ); if( m_excludedFromSim != other.m_excludedFromSim ) similarity *= 0.9; @@ -557,6 +653,56 @@ double SCH_TEXTBOX::Similarity( const SCH_ITEM& aOther ) const } +int SCH_TEXTBOX::compare( const SCH_ITEM& aOther, int aCompareFlags ) const +{ + wxASSERT( aOther.Type() == SCH_TEXTBOX_T ); + + int retv = SCH_SHAPE::compare( aOther, aCompareFlags ); + + if( retv ) + return retv; + + const SCH_TEXTBOX* tmp = static_cast( &aOther ); + + int result = GetText().CmpNoCase( tmp->GetText() ); + + if( result != 0 ) + return result; + + if( GetTextWidth() != tmp->GetTextWidth() ) + return GetTextWidth() - tmp->GetTextWidth(); + + if( GetTextHeight() != tmp->GetTextHeight() ) + return GetTextHeight() - tmp->GetTextHeight(); + + if( IsBold() != tmp->IsBold() ) + return IsBold() - tmp->IsBold(); + + if( IsItalic() != tmp->IsItalic() ) + return IsItalic() - tmp->IsItalic(); + + if( GetHorizJustify() != tmp->GetHorizJustify() ) + return GetHorizJustify() - tmp->GetHorizJustify(); + + if( GetTextAngle().AsTenthsOfADegree() != tmp->GetTextAngle().AsTenthsOfADegree() ) + return GetTextAngle().AsTenthsOfADegree() - tmp->GetTextAngle().AsTenthsOfADegree(); + + if( GetMarginLeft() != tmp->GetMarginLeft() ) + return GetMarginLeft() - tmp->GetMarginLeft(); + + if( GetMarginTop() != tmp->GetMarginTop() ) + return GetMarginTop() - tmp->GetMarginTop(); + + if( GetMarginRight() != tmp->GetMarginRight() ) + return GetMarginRight() - tmp->GetMarginRight(); + + if( GetMarginBottom() != tmp->GetMarginBottom() ) + return GetMarginBottom() - tmp->GetMarginBottom(); + + return 0; +} + + static struct SCH_TEXTBOX_DESC { SCH_TEXTBOX_DESC() diff --git a/eeschema/sch_textbox.h b/eeschema/sch_textbox.h index b7a38b033f..7e8d576dea 100644 --- a/eeschema/sch_textbox.h +++ b/eeschema/sch_textbox.h @@ -35,19 +35,20 @@ class HTML_MESSAGE_BOX; class SCH_TEXTBOX : public SCH_SHAPE, public EDA_TEXT { public: - SCH_TEXTBOX( int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL, - const wxString& aText = wxEmptyString, KICAD_T aType = SCH_TEXTBOX_T ); + SCH_TEXTBOX( SCH_LAYER_ID aLayer = LAYER_NOTES, int aLineWidth = 0, + FILL_T aFillType = FILL_T::NO_FILL, const wxString& aText = wxEmptyString, + KICAD_T aType = SCH_TEXTBOX_T ); SCH_TEXTBOX( const SCH_TEXTBOX& aText ); ~SCH_TEXTBOX() { } - static inline bool ClassOf( const EDA_ITEM* aItem ) + static bool ClassOf( const EDA_ITEM* aItem ) { return aItem && SCH_TEXTBOX_T == aItem->Type(); } - virtual wxString GetClass() const override + wxString GetClass() const override { return wxT( "SCH_TEXTBOX" ); } @@ -74,12 +75,12 @@ public: wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override { - SCHEMATIC* schematic = Schematic(); + SCH_SHEET_PATH* sheetPath = nullptr; - if( schematic ) - return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth ); - else - return GetText(); + if( SCHEMATIC* schematic = Schematic() ) + sheetPath = &schematic->CurrentSheet(); + + return GetShownText( sheetPath, aAllowExtraText, aDepth ); } bool IsHypertext() const override @@ -150,6 +151,8 @@ protected: const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); } + int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override; + protected: bool m_excludedFromSim; int m_marginLeft; diff --git a/eeschema/symbol_checker.cpp b/eeschema/symbol_checker.cpp index 3a5fb00f20..5076371960 100644 --- a/eeschema/symbol_checker.cpp +++ b/eeschema/symbol_checker.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include // helper function to sort pins by pin num @@ -47,7 +47,7 @@ static void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector& * @param aUnitsProvider a frame to format coordinates in messages */ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, - int aGridForPins, EDA_DRAW_FRAME* aUnitsProvider ) + int aGridForPins, EDA_DRAW_FRAME* aUnitsProvider ) { if( !aSymbol ) return; @@ -363,10 +363,10 @@ void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector& aMessag for( const SCH_ITEM& item : aSymbol->GetDrawItems() ) { - if( item.Type() != LIB_SHAPE_T ) + if( item.Type() != SCH_SHAPE_T ) continue; - const LIB_SHAPE* shape = static_cast( &item ); + const SCH_SHAPE* shape = static_cast( &item ); switch( shape->GetShape() ) { diff --git a/eeschema/tools/ee_grid_helper.cpp b/eeschema/tools/ee_grid_helper.cpp index 57213d9cd2..846813a068 100644 --- a/eeschema/tools/ee_grid_helper.cpp +++ b/eeschema/tools/ee_grid_helper.cpp @@ -380,10 +380,8 @@ GRID_HELPER_GRIDS EE_GRID_HELPER::GetItemGrid( const EDA_ITEM* aItem ) const case SCH_TEXT_T: return GRID_TEXT; - case LIB_SHAPE_T: case SCH_SHAPE_T: // The text box's border lines are what need to be on the graphic grid - case LIB_TEXTBOX_T: case SCH_TEXTBOX_T: case SCH_BITMAP_T: return GRID_GRAPHICS; diff --git a/eeschema/tools/ee_point_editor.cpp b/eeschema/tools/ee_point_editor.cpp index 16ed857820..c38c5cf91b 100644 --- a/eeschema/tools/ee_point_editor.cpp +++ b/eeschema/tools/ee_point_editor.cpp @@ -42,10 +42,7 @@ using namespace std::placeholders; #include #include #include -#include #include -#include -#include // Few constants to avoid using bare numbers for point indices @@ -83,12 +80,12 @@ enum LINE_POINTS }; -enum BEZIER_CURVE_POINTS +enum BEZIER_POINTS { - BEZIER_CURVE_START, - BEZIER_CURVE_CONTROL_POINT1, - BEZIER_CURVE_CONTROL_POINT2, - BEZIER_CURVE_END + BEZIER_START, + BEZIER_CTRL_PT1, + BEZIER_CTRL_PT2, + BEZIER_END }; @@ -105,116 +102,30 @@ public: // Generate list of edit points based on the item type switch( aItem->Type() ) { - case LIB_SHAPE_T: - { - LIB_SHAPE* shape = static_cast( aItem ); - - switch( shape->GetShape() ) - { - case SHAPE_T::ARC: - points->AddPoint( mapCoords( shape->GetPosition() ) ); - points->AddPoint( mapCoords( shape->GetStart() ) ); - points->AddPoint( mapCoords( shape->GetEnd() ) ); - break; - - case SHAPE_T::CIRCLE: - points->AddPoint( mapCoords( shape->GetPosition() ) ); - points->AddPoint( mapCoords( shape->GetEnd() ) ); - break; - - case SHAPE_T::RECTANGLE: - { - shape->Normalize(); - - VECTOR2I topLeft = mapCoords( shape->GetPosition() ); - VECTOR2I botRight = mapCoords( shape->GetEnd() ); - - points->AddPoint( topLeft ); - points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); - points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) ); - points->AddPoint( botRight ); - - points->AddLine( points->Point( RECT_TOPLEFT ), points->Point( RECT_TOPRIGHT ) ); - points->Line( RECT_TOP ).SetConstraint( new EC_PERPLINE( points->Line( RECT_TOP ) ) ); - points->AddLine( points->Point( RECT_TOPRIGHT ), points->Point( RECT_BOTRIGHT ) ); - points->Line( RECT_RIGHT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_RIGHT ) ) ); - points->AddLine( points->Point( RECT_BOTRIGHT ), points->Point( RECT_BOTLEFT ) ); - points->Line( RECT_BOT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_BOT ) ) ); - points->AddLine( points->Point( RECT_BOTLEFT ), points->Point( RECT_TOPLEFT ) ); - points->Line( RECT_LEFT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_LEFT ) ) ); - - break; - } - - case SHAPE_T::POLY: - for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() ) - points->AddPoint( mapCoords( pt ) ); - - break; - - case SHAPE_T::BEZIER: - points->AddPoint( mapCoords( shape->GetStart() ) ); - points->AddPoint( mapCoords( shape->GetBezierC1() ) ); - points->AddPoint( mapCoords( shape->GetBezierC2() ) ); - points->AddPoint( mapCoords( shape->GetEnd() ) ); - break; - - default: - UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); - } - - break; - } - - case LIB_TEXTBOX_T: - { - LIB_TEXTBOX* textBox = static_cast( aItem ); - - textBox->Normalize(); - - VECTOR2I topLeft = mapCoords( textBox->GetPosition() ); - VECTOR2I botRight = mapCoords( textBox->GetEnd() ); - - points->AddPoint( topLeft ); - points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); - points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) ); - points->AddPoint( botRight ); - - points->AddLine( points->Point( RECT_TOPLEFT ), points->Point( RECT_TOPRIGHT ) ); - points->Line( RECT_TOP ).SetConstraint( new EC_PERPLINE( points->Line( RECT_TOP ) ) ); - points->AddLine( points->Point( RECT_TOPRIGHT ), points->Point( RECT_BOTRIGHT ) ); - points->Line( RECT_RIGHT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_RIGHT ) ) ); - points->AddLine( points->Point( RECT_BOTRIGHT ), points->Point( RECT_BOTLEFT ) ); - points->Line( RECT_BOT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_BOT ) ) ); - points->AddLine( points->Point( RECT_BOTLEFT ), points->Point( RECT_TOPLEFT ) ); - points->Line( RECT_LEFT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_LEFT ) ) ); - - break; - } - case SCH_SHAPE_T: { SCH_SHAPE* shape = static_cast( aItem ); + bool invertY = shape->GetLayer() == LAYER_DEVICE; switch( shape->GetShape() ) { case SHAPE_T::ARC: - points->AddPoint( shape->GetPosition() ); - points->AddPoint( shape->GetStart() ); - points->AddPoint( shape->GetEnd() ); + points->AddPoint( mapCoords( shape->GetPosition(), invertY ) ); + points->AddPoint( mapCoords( shape->GetStart(), invertY ) ); + points->AddPoint( mapCoords( shape->GetEnd(), invertY ) ); break; case SHAPE_T::CIRCLE: - points->AddPoint( shape->GetPosition() ); - points->AddPoint( shape->GetEnd() ); + points->AddPoint( mapCoords( shape->GetPosition(), invertY ) ); + points->AddPoint( mapCoords( shape->GetEnd(), invertY ) ); break; case SHAPE_T::RECTANGLE: { shape->Normalize(); - VECTOR2I topLeft = shape->GetPosition(); - VECTOR2I botRight = shape->GetEnd(); + VECTOR2I topLeft = mapCoords( shape->GetPosition(), invertY ); + VECTOR2I botRight = mapCoords( shape->GetEnd(), invertY ); points->AddPoint( topLeft ); points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); @@ -235,15 +146,15 @@ public: case SHAPE_T::POLY: for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() ) - points->AddPoint( pt ); + points->AddPoint( mapCoords( pt, invertY ) ); break; case SHAPE_T::BEZIER: - points->AddPoint( shape->GetStart() ); - points->AddPoint( shape->GetBezierC1() ); - points->AddPoint( shape->GetBezierC2() ); - points->AddPoint( shape->GetEnd() ); + points->AddPoint( mapCoords( shape->GetStart(), invertY ) ); + points->AddPoint( mapCoords( shape->GetBezierC1(), invertY ) ); + points->AddPoint( mapCoords( shape->GetBezierC2(), invertY ) ); + points->AddPoint( mapCoords( shape->GetEnd(), invertY ) ); break; default: @@ -255,12 +166,13 @@ public: case SCH_TEXTBOX_T: { - SCH_TEXTBOX* textBox = static_cast( aItem ); + SCH_TEXTBOX* textbox = static_cast( aItem ); + bool invertY = textbox->GetLayer() == LAYER_DEVICE; - textBox->Normalize(); + textbox->Normalize(); - VECTOR2I topLeft = textBox->GetPosition(); - VECTOR2I botRight = textBox->GetEnd(); + VECTOR2I topLeft = mapCoords( textbox->GetPosition(), invertY ); + VECTOR2I botRight = mapCoords( textbox->GetEnd(), invertY ); points->AddPoint( topLeft ); points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); @@ -460,8 +372,8 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent ) const EE_SELECTION& selection = m_selectionTool->GetSelection(); - if( selection.Size() != 1 || !selection.Front()->IsType( { LIB_SHAPE_T, SCH_SHAPE_T, - LIB_TEXTBOX_T, SCH_TEXTBOX_T, + if( selection.Size() != 1 || !selection.Front()->IsType( { SCH_SHAPE_T, + SCH_TEXTBOX_T, SCH_TABLECELL_T, SCH_SHEET_T, SCH_ITEM_LOCATE_GRAPHIC_LINE_T, @@ -720,168 +632,10 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const switch( item->Type() ) { - case LIB_SHAPE_T: - { - LIB_SHAPE* shape = static_cast( item ); - - switch( shape->GetShape() ) - { - case SHAPE_T::ARC: - if( getEditedPointIndex() == ARC_CENTER ) - { - shape->SetEditState( 4 ); - shape->CalcEdit( mapCoords( m_editPoints->Point( ARC_CENTER ).GetPosition() ) ); - } - else if( getEditedPointIndex() == ARC_START ) - { - shape->SetEditState( 2 ); - shape->CalcEdit( mapCoords( m_editPoints->Point( ARC_START ).GetPosition() ) ); - } - else if( getEditedPointIndex() == ARC_END ) - { - shape->SetEditState( 3 ); - shape->CalcEdit( mapCoords( m_editPoints->Point( ARC_END ).GetPosition() ) ); - } - break; - - case SHAPE_T::CIRCLE: - shape->SetPosition( mapCoords( m_editPoints->Point( CIRC_CENTER ).GetPosition() ) ); - shape->SetEnd( mapCoords( m_editPoints->Point( CIRC_END ).GetPosition() ) ); - break; - - case SHAPE_T::POLY: - shape->GetPolyShape().RemoveAllContours(); - shape->GetPolyShape().NewOutline(); - - for( unsigned i = 0; i < m_editPoints->PointsSize(); ++i ) - { - VECTOR2I pt = mapCoords( m_editPoints->Point( i ).GetPosition() ); - shape->GetPolyShape().Append( pt.x, pt.y, -1, -1, true ); - } - - break; - - case SHAPE_T::RECTANGLE: - { - EE_GRID_HELPER gridHelper( m_toolMgr ); - VECTOR2I topLeft = m_editPoints->Point( RECT_TOPLEFT ).GetPosition(); - VECTOR2I topRight = m_editPoints->Point( RECT_TOPRIGHT ).GetPosition(); - VECTOR2I botLeft = m_editPoints->Point( RECT_BOTLEFT ).GetPosition(); - VECTOR2I botRight = m_editPoints->Point( RECT_BOTRIGHT ).GetPosition(); - - gridHelper.SetSnap( aSnapToGrid ); - - pinEditedCorner( schIUScale.MilsToIU( 1 ), schIUScale.MilsToIU( 1 ), topLeft, topRight, - botLeft, botRight, &gridHelper ); - - if( isModified( m_editPoints->Point( RECT_TOPLEFT ) ) - || isModified( m_editPoints->Point( RECT_TOPRIGHT ) ) - || isModified( m_editPoints->Point( RECT_BOTRIGHT ) ) - || isModified( m_editPoints->Point( RECT_BOTLEFT ) ) ) - { - shape->SetPosition( mapCoords( topLeft ) ); - shape->SetEnd( mapCoords( botRight ) ); - } - else if( isModified( m_editPoints->Line( RECT_TOP ) ) ) - { - shape->SetStartY( mapCoords( topLeft ).y ); - } - else if( isModified( m_editPoints->Line( RECT_LEFT ) ) ) - { - shape->SetStartX( mapCoords( topLeft ).x ); - } - else if( isModified( m_editPoints->Line( RECT_BOT ) ) ) - { - shape->SetEndY( mapCoords( botRight ).y ); - } - else if( isModified( m_editPoints->Line( RECT_RIGHT ) ) ) - { - shape->SetEndX( mapCoords( botRight ).x ); - } - - for( unsigned i = 0; i < m_editPoints->LinesSize(); ++i ) - { - if( !isModified( m_editPoints->Line( i ) ) ) - { - m_editPoints->Line( i ).SetConstraint( - new EC_PERPLINE( m_editPoints->Line( i ) ) ); - } - } - - break; - } - - case SHAPE_T::BEZIER: - shape->SetStart( mapCoords( m_editPoints->Point( BEZIER_CURVE_START ).GetPosition() ) ); - shape->SetBezierC1( mapCoords( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition() ) ); - shape->SetBezierC2( mapCoords( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition() ) ); - shape->SetEnd( mapCoords( m_editPoints->Point( BEZIER_CURVE_END ).GetPosition() ) ); - - shape->RebuildBezierToSegmentsPointsList( shape->GetWidth() ); - break; - - default: - UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); - } - - break; - } - - case LIB_TEXTBOX_T: - { - LIB_TEXTBOX* textbox = static_cast( item ); - EE_GRID_HELPER gridHelper( m_toolMgr ); - VECTOR2I topLeft = m_editPoints->Point( RECT_TOPLEFT ).GetPosition(); - VECTOR2I topRight = m_editPoints->Point( RECT_TOPRIGHT ).GetPosition(); - VECTOR2I botLeft = m_editPoints->Point( RECT_BOTLEFT ).GetPosition(); - VECTOR2I botRight = m_editPoints->Point( RECT_BOTRIGHT ).GetPosition(); - - gridHelper.SetSnap( aSnapToGrid ); - - pinEditedCorner( schIUScale.MilsToIU( 1 ), schIUScale.MilsToIU( 1 ), topLeft, topRight, - botLeft, botRight, &gridHelper ); - - if( isModified( m_editPoints->Point( RECT_TOPLEFT ) ) - || isModified( m_editPoints->Point( RECT_TOPRIGHT ) ) - || isModified( m_editPoints->Point( RECT_BOTRIGHT ) ) - || isModified( m_editPoints->Point( RECT_BOTLEFT ) ) ) - { - textbox->SetPosition( mapCoords( topLeft ) ); - textbox->SetEnd( mapCoords( botRight ) ); - } - else if( isModified( m_editPoints->Line( RECT_TOP ) ) ) - { - textbox->SetStartY( mapCoords( topLeft ).y ); - } - else if( isModified( m_editPoints->Line( RECT_LEFT ) ) ) - { - textbox->SetStartX( mapCoords( topLeft ).x ); - } - else if( isModified( m_editPoints->Line( RECT_BOT ) ) ) - { - textbox->SetEndY( mapCoords( botRight ).y ); - } - else if( isModified( m_editPoints->Line( RECT_RIGHT ) ) ) - { - textbox->SetEndX( mapCoords( botRight ).x ); - } - - for( unsigned i = 0; i < m_editPoints->LinesSize(); ++i ) - { - if( !isModified( m_editPoints->Line( i ) ) ) - { - m_editPoints->Line( i ).SetConstraint( - new EC_PERPLINE( m_editPoints->Line( i ) ) ); - } - } - - textbox->ClearRenderCache(); - break; - } - case SCH_SHAPE_T: { SCH_SHAPE* shape = static_cast( item ); + bool invertY = true; switch( shape->GetShape() ) { @@ -889,23 +643,23 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const if( getEditedPointIndex() == ARC_CENTER ) { shape->SetEditState( 4 ); - shape->CalcEdit( m_editPoints->Point( ARC_CENTER ).GetPosition() ); + shape->CalcEdit( mapCoords( m_editPoints->Point( ARC_CENTER ).GetPosition(), invertY ) ); } else if( getEditedPointIndex() == ARC_START ) { shape->SetEditState( 2 ); - shape->CalcEdit( m_editPoints->Point( ARC_START ).GetPosition() ); + shape->CalcEdit( mapCoords( m_editPoints->Point( ARC_START ).GetPosition(), invertY ) ); } else if( getEditedPointIndex() == ARC_END ) { shape->SetEditState( 3 ); - shape->CalcEdit( m_editPoints->Point( ARC_END ).GetPosition() ); + shape->CalcEdit( mapCoords( m_editPoints->Point( ARC_END ).GetPosition(), invertY ) ); } break; case SHAPE_T::CIRCLE: - shape->SetPosition( m_editPoints->Point( CIRC_CENTER ).GetPosition() ); - shape->SetEnd( m_editPoints->Point( CIRC_END ).GetPosition() ); + shape->SetPosition( mapCoords( m_editPoints->Point( CIRC_CENTER ).GetPosition(), invertY ) ); + shape->SetEnd( mapCoords( m_editPoints->Point( CIRC_END ).GetPosition(), invertY ) ); break; case SHAPE_T::POLY: @@ -914,7 +668,7 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const for( unsigned i = 0; i < m_editPoints->PointsSize(); ++i ) { - VECTOR2I pt = m_editPoints->Point( i ).GetPosition(); + VECTOR2I pt = mapCoords( m_editPoints->Point( i ).GetPosition(), invertY ); shape->GetPolyShape().Append( pt.x, pt.y, -1, -1, true ); } @@ -938,24 +692,24 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const || isModified( m_editPoints->Point( RECT_BOTRIGHT ) ) || isModified( m_editPoints->Point( RECT_BOTLEFT ) ) ) { - shape->SetPosition( topLeft ); - shape->SetEnd( botRight ); + shape->SetPosition( mapCoords( topLeft, invertY ) ); + shape->SetEnd( mapCoords( botRight, invertY ) ); } else if( isModified( m_editPoints->Line( RECT_TOP ) ) ) { - shape->SetStartY( topLeft.y ); + shape->SetStartY( mapCoords( topLeft, invertY ).y ); } else if( isModified( m_editPoints->Line( RECT_LEFT ) ) ) { - shape->SetStartX( topLeft.x ); + shape->SetStartX( mapCoords( topLeft, invertY ).x ); } else if( isModified( m_editPoints->Line( RECT_BOT ) ) ) { - shape->SetEndY( botRight.y ); + shape->SetEndY( mapCoords( botRight, invertY ).y ); } else if( isModified( m_editPoints->Line( RECT_RIGHT ) ) ) { - shape->SetEndX( botRight.x ); + shape->SetEndX( mapCoords( botRight, invertY ).x ); } for( unsigned i = 0; i < m_editPoints->LinesSize(); ++i ) @@ -971,10 +725,10 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const } case SHAPE_T::BEZIER: - shape->SetStart( m_editPoints->Point( BEZIER_CURVE_START ).GetPosition() ); - shape->SetBezierC1( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition() ); - shape->SetBezierC2( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition() ); - shape->SetEnd( m_editPoints->Point( BEZIER_CURVE_END ).GetPosition() ); + shape->SetStart( mapCoords( m_editPoints->Point( BEZIER_START ).GetPosition(), invertY ) ); + shape->SetBezierC1( mapCoords( m_editPoints->Point( BEZIER_CTRL_PT1 ).GetPosition(), invertY ) ); + shape->SetBezierC2( mapCoords( m_editPoints->Point( BEZIER_CTRL_PT2 ).GetPosition(), invertY ) ); + shape->SetEnd( mapCoords( m_editPoints->Point( BEZIER_END ).GetPosition(), invertY ) ); shape->RebuildBezierToSegmentsPointsList( shape->GetWidth() ); break; @@ -988,7 +742,8 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const case SCH_TEXTBOX_T: { - SCH_TEXTBOX* textBox = static_cast( item ); + SCH_TEXTBOX* textbox = static_cast( item ); + bool invertY = textbox->GetLayer() == LAYER_DEVICE; EE_GRID_HELPER gridHelper( m_toolMgr ); VECTOR2I topLeft = m_editPoints->Point( RECT_TOPLEFT ).GetPosition(); VECTOR2I topRight = m_editPoints->Point( RECT_TOPRIGHT ).GetPosition(); @@ -1005,24 +760,24 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const || isModified( m_editPoints->Point( RECT_BOTRIGHT ) ) || isModified( m_editPoints->Point( RECT_BOTLEFT ) ) ) { - textBox->SetPosition( topLeft ); - textBox->SetEnd( botRight ); + textbox->SetPosition( mapCoords( topLeft, invertY ) ); + textbox->SetEnd( mapCoords( botRight, invertY ) ); } else if( isModified( m_editPoints->Line( RECT_TOP ) ) ) { - textBox->SetStartY( topLeft.y ); + textbox->SetStartY( mapCoords( topLeft, invertY ).y ); } else if( isModified( m_editPoints->Line( RECT_LEFT ) ) ) { - textBox->SetStartX( topLeft.x ); + textbox->SetStartX( mapCoords( topLeft, invertY ).x ); } else if( isModified( m_editPoints->Line( RECT_BOT ) ) ) { - textBox->SetEndY( botRight.y ); + textbox->SetEndY( mapCoords( botRight, invertY ).y ); } else if( isModified( m_editPoints->Line( RECT_RIGHT ) ) ) { - textBox->SetEndX( botRight.x ); + textbox->SetEndX( mapCoords( botRight, invertY ).x ); } for( unsigned i = 0; i < m_editPoints->LinesSize(); ++i ) @@ -1034,7 +789,7 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const } } - textBox->ClearRenderCache(); + textbox->ClearRenderCache(); break; } @@ -1223,112 +978,22 @@ void EE_POINT_EDITOR::updatePoints() switch( item->Type() ) { - case LIB_SHAPE_T: - { - LIB_SHAPE* shape = static_cast( item ); - - switch( shape->GetShape() ) - { - case SHAPE_T::ARC: - m_editPoints->Point( ARC_CENTER ).SetPosition( mapCoords( shape->GetPosition() ) ); - m_editPoints->Point( ARC_START ).SetPosition( mapCoords( shape->GetStart() ) ); - m_editPoints->Point( ARC_END ).SetPosition( mapCoords( shape->GetEnd() ) ); - break; - - case SHAPE_T::CIRCLE: - m_editPoints->Point( CIRC_CENTER ).SetPosition( mapCoords( shape->GetPosition() ) ); - m_editPoints->Point( CIRC_END ).SetPosition( mapCoords( shape->GetEnd() ) ); - break; - - case SHAPE_T::POLY: - { - if( (int) m_editPoints->PointsSize() != shape->GetPointCount() ) - { - getView()->Remove( m_editPoints.get() ); - m_editedPoint = nullptr; - m_editPoints = EDIT_POINTS_FACTORY::Make( item, m_frame ); - getView()->Add( m_editPoints.get() ); - } - else - { - int ii = 0; - - for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() ) - m_editPoints->Point( ii++ ).SetPosition( mapCoords( pt ) ); - } - - break; - } - - case SHAPE_T::RECTANGLE: - { - // point editor works only with rectangles having width and height > 0 - // Some symbols can have rectangles with width or height < 0 - // So normalize the size: - BOX2I dummy; - dummy.SetOrigin( mapCoords( shape->GetPosition() ) ); - dummy.SetEnd( mapCoords( shape->GetEnd() ) ); - dummy.Normalize(); - VECTOR2I topLeft = dummy.GetPosition(); - VECTOR2I botRight = dummy.GetEnd(); - - m_editPoints->Point( RECT_TOPLEFT ).SetPosition( topLeft ); - m_editPoints->Point( RECT_TOPRIGHT ).SetPosition( VECTOR2I( botRight.x, topLeft.y ) ); - m_editPoints->Point( RECT_BOTLEFT ).SetPosition( VECTOR2I( topLeft.x, botRight.y ) ); - m_editPoints->Point( RECT_BOTRIGHT ).SetPosition( botRight ); - break; - } - - case SHAPE_T::BEZIER: - m_editPoints->Point( BEZIER_CURVE_START ).SetPosition( mapCoords( shape->GetStart() ) ); - m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).SetPosition( mapCoords( shape->GetBezierC1() ) ); - m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).SetPosition( mapCoords( shape->GetBezierC2() ) ); - m_editPoints->Point( BEZIER_CURVE_END ).SetPosition( mapCoords( shape->GetEnd() ) ); - break; - - default: - UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); - } - - break; - } - - case LIB_TEXTBOX_T: - { - LIB_TEXTBOX* textbox = static_cast( item ); - - // point editor works only with rectangles having width and height > 0 - // Some symbols can have rectangles with width or height < 0 - // So normalize the size: - BOX2I dummy; - dummy.SetOrigin( mapCoords( textbox->GetPosition() ) ); - dummy.SetEnd( mapCoords( textbox->GetEnd() ) ); - dummy.Normalize(); - VECTOR2I topLeft = dummy.GetPosition(); - VECTOR2I botRight = dummy.GetEnd(); - - m_editPoints->Point( RECT_TOPLEFT ).SetPosition( topLeft ); - m_editPoints->Point( RECT_TOPRIGHT ).SetPosition( VECTOR2I( botRight.x, topLeft.y ) ); - m_editPoints->Point( RECT_BOTLEFT ).SetPosition( VECTOR2I( topLeft.x, botRight.y ) ); - m_editPoints->Point( RECT_BOTRIGHT ).SetPosition( botRight ); - break; - } - case SCH_SHAPE_T: { SCH_SHAPE* shape = static_cast( item ); + bool invertY = true; switch( shape->GetShape() ) { case SHAPE_T::ARC: - m_editPoints->Point( ARC_CENTER ).SetPosition( shape->GetPosition() ); - m_editPoints->Point( ARC_START ).SetPosition( shape->GetStart() ); - m_editPoints->Point( ARC_END ).SetPosition( shape->GetEnd() ); + m_editPoints->Point( ARC_CENTER ).SetPosition( mapCoords( shape->GetPosition(), invertY ) ); + m_editPoints->Point( ARC_START ).SetPosition( mapCoords( shape->GetStart(), invertY ) ); + m_editPoints->Point( ARC_END ).SetPosition( mapCoords( shape->GetEnd(), invertY ) ); break; case SHAPE_T::CIRCLE: - m_editPoints->Point( CIRC_CENTER ).SetPosition( shape->GetPosition() ); - m_editPoints->Point( CIRC_END ).SetPosition( shape->GetEnd() ); + m_editPoints->Point( CIRC_CENTER ).SetPosition( mapCoords( shape->GetPosition(), invertY ) ); + m_editPoints->Point( CIRC_END ).SetPosition( mapCoords( shape->GetEnd(), invertY ) ); break; case SHAPE_T::POLY: @@ -1345,7 +1010,7 @@ void EE_POINT_EDITOR::updatePoints() int ii = 0; for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() ) - m_editPoints->Point( ii++ ).SetPosition( pt ); + m_editPoints->Point( ii++ ).SetPosition( mapCoords( pt, invertY ) ); } break; @@ -1357,8 +1022,8 @@ void EE_POINT_EDITOR::updatePoints() // Some symbols can have rectangles with width or height < 0 // So normalize the size: BOX2I dummy; - dummy.SetOrigin( shape->GetPosition() ); - dummy.SetEnd( shape->GetEnd() ); + dummy.SetOrigin( mapCoords( shape->GetPosition(), invertY ) ); + dummy.SetEnd( mapCoords( shape->GetEnd(), invertY ) ); dummy.Normalize(); VECTOR2I topLeft = dummy.GetPosition(); VECTOR2I botRight = dummy.GetEnd(); @@ -1371,10 +1036,10 @@ void EE_POINT_EDITOR::updatePoints() } case SHAPE_T::BEZIER: - m_editPoints->Point( BEZIER_CURVE_START ).SetPosition( shape->GetStart() ); - m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).SetPosition( shape->GetBezierC1() ); - m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).SetPosition( shape->GetBezierC2() ); - m_editPoints->Point( BEZIER_CURVE_END ).SetPosition( shape->GetEnd() ); + m_editPoints->Point( BEZIER_START ).SetPosition( mapCoords( shape->GetStart(), invertY ) ); + m_editPoints->Point( BEZIER_CTRL_PT1 ).SetPosition( mapCoords( shape->GetBezierC1(), invertY ) ); + m_editPoints->Point( BEZIER_CTRL_PT2 ).SetPosition( mapCoords( shape->GetBezierC2(), invertY ) ); + m_editPoints->Point( BEZIER_END ).SetPosition( mapCoords( shape->GetEnd(), invertY ) ); break; default: @@ -1386,14 +1051,15 @@ void EE_POINT_EDITOR::updatePoints() case SCH_TEXTBOX_T: { - SCH_TEXTBOX* textBox = static_cast( item ); + SCH_TEXTBOX* textbox = static_cast( item ); + bool invertY = textbox->GetLayer() == LAYER_DEVICE; // point editor works only with rectangles having width and height > 0 // Some symbols can have rectangles with width or height < 0 // So normalize the size: BOX2I dummy; - dummy.SetOrigin( textBox->GetPosition() ); - dummy.SetEnd( textBox->GetEnd() ); + dummy.SetOrigin( mapCoords( textbox->GetPosition(), invertY ) ); + dummy.SetEnd( mapCoords( textbox->GetEnd(), invertY ) ); dummy.Normalize(); VECTOR2I topLeft = dummy.GetPosition(); VECTOR2I botRight = dummy.GetEnd(); @@ -1483,10 +1149,11 @@ void EE_POINT_EDITOR::setEditedPoint( EDIT_POINT* aPoint ) bool EE_POINT_EDITOR::removeCornerCondition( const SELECTION& ) { - if( !m_editPoints || !m_editedPoint || m_editPoints->GetParent()->Type() != LIB_SHAPE_T ) + if( !m_editPoints || !m_editedPoint || m_editPoints->GetParent()->Type() != SCH_SHAPE_T ) return false; - LIB_SHAPE* shape = static_cast( m_editPoints->GetParent() ); + SCH_SHAPE* shape = static_cast( m_editPoints->GetParent() ); + bool invertY = shape->GetLayer() == LAYER_DEVICE; if( shape->GetPolyShape().IsEmpty() ) return false; @@ -1498,7 +1165,7 @@ bool EE_POINT_EDITOR::removeCornerCondition( const SELECTION& ) for( const VECTOR2I& pt : poly.CPoints() ) { - if( pt == mapCoords( m_editedPoint->GetPosition() ) ) + if( pt == mapCoords( m_editedPoint->GetPosition(), invertY ) ) return true; } @@ -1508,10 +1175,10 @@ bool EE_POINT_EDITOR::removeCornerCondition( const SELECTION& ) bool EE_POINT_EDITOR::addCornerCondition( const SELECTION& ) { - if( !m_editPoints || m_editPoints->GetParent()->Type() != LIB_SHAPE_T ) + if( !m_editPoints || m_editPoints->GetParent()->Type() != SCH_SHAPE_T ) return false; - LIB_SHAPE* shape = static_cast( m_editPoints->GetParent() ); + SCH_SHAPE* shape = static_cast( m_editPoints->GetParent() ); if( shape->GetShape() != SHAPE_T::POLY ) return false; @@ -1525,17 +1192,18 @@ bool EE_POINT_EDITOR::addCornerCondition( const SELECTION& ) int EE_POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent ) { - if( !m_editPoints || m_editPoints->GetParent()->Type() != LIB_SHAPE_T ) + if( !m_editPoints || m_editPoints->GetParent()->Type() != SCH_SHAPE_T ) return 0; - LIB_SHAPE* shape = static_cast( m_editPoints->GetParent() ); + SCH_SHAPE* shape = static_cast( m_editPoints->GetParent() ); + bool invertY = shape->GetLayer() == LAYER_DEVICE; SHAPE_LINE_CHAIN& poly = shape->GetPolyShape().Outline( 0 ); SCH_COMMIT commit( m_toolMgr ); commit.Modify( shape, m_frame->GetScreen() ); VECTOR2I cursor = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() ); - VECTOR2I pos = mapCoords( cursor ); + VECTOR2I pos = mapCoords( cursor, invertY ); int currentMinDistance = INT_MAX; int closestLineStart = 0; @@ -1563,10 +1231,10 @@ int EE_POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent ) int EE_POINT_EDITOR::removeCorner( const TOOL_EVENT& aEvent ) { - if( !m_editPoints || !m_editedPoint || m_editPoints->GetParent()->Type() != LIB_SHAPE_T ) + if( !m_editPoints || !m_editedPoint || m_editPoints->GetParent()->Type() != SCH_SHAPE_T ) return 0; - LIB_SHAPE* shape = static_cast( m_editPoints->GetParent() ); + SCH_SHAPE* shape = static_cast( m_editPoints->GetParent() ); SHAPE_LINE_CHAIN& poly = shape->GetPolyShape().Outline( 0 ); SCH_COMMIT commit( m_toolMgr ); diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 136fc9d417..a50868ba45 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -45,14 +45,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include @@ -570,9 +568,9 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) } else { - m_selection = RequestSelection( { LIB_SHAPE_T, + m_selection = RequestSelection( { SCH_SHAPE_T, SCH_TEXT_T, - LIB_TEXTBOX_T, + SCH_TEXTBOX_T, LIB_PIN_T, SCH_FIELD_T } ); } @@ -1355,7 +1353,7 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const { EDA_ITEM* item = collector[ i ]; SCH_LINE* line = dynamic_cast( item ); - LIB_SHAPE* shape = dynamic_cast( item ); + SCH_SHAPE* shape = dynamic_cast( item ); SCH_TABLE* table = dynamic_cast( item ); // Lines are hard to hit. Give them a bit more slop to still be considered "exact". @@ -1391,8 +1389,7 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const // Find the closest item. (Note that at this point all hits are either exact or non-exact.) VECTOR2I pos( aPos ); - SEG poss( m_isSymbolEditor ? mapCoords( pos ) : pos, - m_isSymbolEditor ? mapCoords( pos ) : pos ); + SEG poss( mapCoords( pos, m_isSymbolEditor ), mapCoords( pos, m_isSymbolEditor ) ); EDA_ITEM* closest = nullptr; int closestDist = INT_MAX / 4; @@ -1636,7 +1633,6 @@ bool EE_SELECTION_TOOL::itemPassesFilter( EDA_ITEM* aItem ) } case SCH_SHAPE_T: - case LIB_SHAPE_T: if( !m_filter.graphics ) return false; @@ -1647,7 +1643,6 @@ bool EE_SELECTION_TOOL::itemPassesFilter( EDA_ITEM* aItem ) case SCH_TABLE_T: case SCH_TABLECELL_T: case SCH_FIELD_T: - case LIB_TEXTBOX_T: if( !m_filter.text ) return false; @@ -2482,8 +2477,9 @@ bool EE_SELECTION_TOOL::Selectable( const EDA_ITEM* aItem, const VECTOR2I* aPos, case SCH_FIELD_T: // SCH_FIELD objects are not unit/body-style-specific. break; - case LIB_SHAPE_T: + case SCH_SHAPE_T: case SCH_TEXT_T: + case SCH_TEXTBOX_T: case LIB_PIN_T: if( symEditFrame ) { diff --git a/eeschema/tools/ee_tool_base.h b/eeschema/tools/ee_tool_base.h index 0a98196349..d46081ccd4 100644 --- a/eeschema/tools/ee_tool_base.h +++ b/eeschema/tools/ee_tool_base.h @@ -202,20 +202,22 @@ protected: }; -// For LibEdit -inline VECTOR2I mapCoords( const wxPoint& aCoord ) +// +// TODO: nuke symbol editor's upside-down coordinate system +// +inline VECTOR2I mapCoords( const wxPoint& aCoord, bool aInvertY ) { - return VECTOR2I( aCoord.x, -aCoord.y ); + return VECTOR2I( aCoord.x, aInvertY ? -aCoord.y : aCoord.y ); } -inline VECTOR2I mapCoords( const VECTOR2I& aCoord ) +inline VECTOR2I mapCoords( const VECTOR2I& aCoord, bool aInvertY ) { - return VECTOR2I( aCoord.x, -aCoord.y ); + return VECTOR2I( aCoord.x, aInvertY ? -aCoord.y : aCoord.y ); } -inline VECTOR2I mapCoords( const int x, const int y ) +inline VECTOR2I mapCoords( const int x, const int y, bool aInvertY ) { - return VECTOR2I( x, -y ); + return VECTOR2I( x, aInvertY ? -y : y ); } #endif diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 49fd74d77e..f0192196bc 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -1886,7 +1886,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) if( isTextBox ) { - SCH_TEXTBOX* textbox = new SCH_TEXTBOX( 0, m_lastTextboxFillStyle ); + SCH_TEXTBOX* textbox = new SCH_TEXTBOX( LAYER_NOTES, 0, m_lastTextboxFillStyle ); textbox->SetTextSize( VECTOR2I( sch_settings.m_DefaultTextSize, sch_settings.m_DefaultTextSize ) ); @@ -1907,12 +1907,12 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) } else { - item = new SCH_SHAPE( type, 0, m_lastFillStyle ); + item = new SCH_SHAPE( type, LAYER_NOTES, 0, m_lastFillStyle ); item->SetStroke( m_lastStroke ); item->SetFillColor( m_lastFillColor ); item->SetParent( schematic ); - description = wxString::Format( _( "Add %s" ), item->EDA_SHAPE::GetFriendlyName() ); + description = wxString::Format( _( "Add %s" ), item->GetFriendlyName() ); } item->SetFlags( IS_NEW ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 81496915fe..3aacfd2468 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -2282,7 +2282,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent ) case SCH_TEXTBOX_T: { - SCH_TEXTBOX* new_textbox = new SCH_TEXTBOX( 0, FILL_T::NO_FILL, txt ); + SCH_TEXTBOX* new_textbox = new SCH_TEXTBOX( LAYER_NOTES, 0, FILL_T::NO_FILL, txt ); BOX2I bbox = item->GetBoundingBox(); if( SCH_LABEL_BASE* label = dynamic_cast( item ) ) diff --git a/eeschema/tools/symbol_editor_drawing_tools.cpp b/eeschema/tools/symbol_editor_drawing_tools.cpp index 64502a09f4..8c6d6ad739 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.cpp +++ b/eeschema/tools/symbol_editor_drawing_tools.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 CERN - * Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2024 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 @@ -31,15 +31,14 @@ #include #include #include -#include -#include +#include +#include #include #include #include #include #include #include -#include "dialog_lib_textbox_properties.h" static void* g_lastPinWeakPtr; @@ -361,7 +360,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::opt VECTOR2I cursorPos; SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType; LIB_SYMBOL* symbol = m_frame->GetCurSymbol(); - LIB_SHAPE* item = nullptr; + SCH_SHAPE* item = nullptr; wxString description; if( m_inDrawShape ) @@ -461,8 +460,9 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::opt if( isTextBox ) { - LIB_TEXTBOX* textbox = new LIB_TEXTBOX( symbol, lineWidth, m_lastFillStyle ); + SCH_TEXTBOX* textbox = new SCH_TEXTBOX( LAYER_DEVICE, lineWidth, m_lastFillStyle ); + textbox->SetParent( symbol ); textbox->SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ), schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) ); @@ -478,8 +478,9 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::opt } else { - item = new LIB_SHAPE( symbol, shapeType, lineWidth, m_lastFillStyle ); - description = wxString::Format( _( "Add %s" ), item->EDA_SHAPE::GetFriendlyName() ); + item = new SCH_SHAPE( shapeType, LAYER_DEVICE, lineWidth, m_lastFillStyle ); + item->SetParent( symbol ); + description = wxString::Format( _( "Add %s" ), item->GetFriendlyName() ); } item->SetStroke( m_lastStroke ); @@ -524,8 +525,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::opt if( isTextBox ) { - LIB_TEXTBOX* textbox = static_cast( item ); - DIALOG_LIB_TEXTBOX_PROPERTIES dlg( m_frame, static_cast( item ) ); + SCH_TEXTBOX* textbox = static_cast( item ); + DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast( item ) ); // QuasiModal required for syntax help and Scintilla auto-complete if( dlg.ShowQuasiModal() != wxID_OK ) diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index 0842c2dcb8..f0da73b488 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -31,15 +31,14 @@ #include #include #include -#include +#include #include -#include #include #include #include #include #include -#include +#include #include "symbol_editor_edit_tool.h" #include // for wxTextEntryDialog #include // for KiROUND @@ -166,7 +165,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) if( selection.GetSize() == 1 ) rotPoint = item->GetPosition(); else - rotPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter() ) ); + rotPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter(), true ) ); for( unsigned ii = 0; ii < selection.GetSize(); ii++ ) { @@ -238,7 +237,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) } else { - mirrorPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter() ) ); + mirrorPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter(), true ) ); for( unsigned ii = 0; ii < selection.GetSize(); ii++ ) { @@ -272,9 +271,9 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) static std::vector nonFields = { LIB_SYMBOL_T, - LIB_SHAPE_T, + SCH_SHAPE_T, SCH_TEXT_T, - LIB_TEXTBOX_T, + SCH_TEXTBOX_T, LIB_PIN_T }; @@ -457,15 +456,15 @@ int SYMBOL_EDITOR_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) break; - case LIB_SHAPE_T: - editShapeProperties( static_cast( item ) ); + case SCH_SHAPE_T: + editShapeProperties( static_cast( item ) ); break; case SCH_TEXT_T: editTextProperties( item ); break; - case LIB_TEXTBOX_T: + case SCH_TEXTBOX_T: editTextBoxProperties( item ); break; @@ -486,9 +485,9 @@ int SYMBOL_EDITOR_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) } -void SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties( LIB_SHAPE* aShape ) +void SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties( SCH_SHAPE* aShape ) { - DIALOG_LIB_SHAPE_PROPERTIES dlg( m_frame, aShape ); + DIALOG_SHAPE_PROPERTIES dlg( m_frame, aShape ); if( dlg.ShowModal() != wxID_OK ) return; @@ -525,10 +524,10 @@ void SYMBOL_EDITOR_EDIT_TOOL::editTextProperties( SCH_ITEM* aItem ) void SYMBOL_EDITOR_EDIT_TOOL::editTextBoxProperties( SCH_ITEM* aItem ) { - if ( aItem->Type() != LIB_TEXTBOX_T ) + if ( aItem->Type() != SCH_TEXTBOX_T ) return; - DIALOG_LIB_TEXTBOX_PROPERTIES dlg( m_frame, static_cast( aItem ) ); + DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast( aItem ) ); if( dlg.ShowModal() != wxID_OK ) return; @@ -896,7 +895,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection ); m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, &newItems ); - selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) ); + selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ), true ) ); if( m_toolMgr->RunSynchronousAction( EE_ACTIONS::move, &commit ) ) commit.Push( _( "Duplicate" ) ); diff --git a/eeschema/tools/symbol_editor_edit_tool.h b/eeschema/tools/symbol_editor_edit_tool.h index 5333621fe6..f498eabce0 100644 --- a/eeschema/tools/symbol_editor_edit_tool.h +++ b/eeschema/tools/symbol_editor_edit_tool.h @@ -65,7 +65,7 @@ public: int InteractiveDelete( const TOOL_EVENT& aEvent ); private: - void editShapeProperties( LIB_SHAPE* aShape ); + void editShapeProperties( SCH_SHAPE* aShape ); void editTextProperties( SCH_ITEM* aItem ); void editTextBoxProperties( SCH_ITEM* aItem ); void editFieldProperties( SCH_FIELD* aField ); diff --git a/eeschema/tools/symbol_editor_move_tool.cpp b/eeschema/tools/symbol_editor_move_tool.cpp index 737270056f..d2e062e07a 100644 --- a/eeschema/tools/symbol_editor_move_tool.cpp +++ b/eeschema/tools/symbol_editor_move_tool.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include "symbol_editor_move_tool.h" @@ -227,7 +227,7 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM if( lib_item->IsNew() ) { m_anchorPos = selection.GetReferencePoint(); - VECTOR2I delta = m_cursor - mapCoords( m_anchorPos ); + VECTOR2I delta = m_cursor - mapCoords( m_anchorPos, true ); // Drag items to the current cursor position for( EDA_ITEM* item : selection ) @@ -387,13 +387,13 @@ int SYMBOL_EDITOR_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent ) [&]( EDA_ITEM* item, const VECTOR2I& delta ) { commit.Modify( item, m_frame->GetScreen() ); - static_cast( item )->Move( mapCoords( delta ) ); + static_cast( item )->Move( mapCoords( delta, true ) ); updateItem( item, true ); }; for( EDA_ITEM* item : selection ) { - if( LIB_SHAPE* shape = dynamic_cast( item ) ) + if( SCH_SHAPE* shape = dynamic_cast( item ) ) { VECTOR2I newStart = grid.AlignGrid( shape->GetStart(), grid.GetItemGrid( shape ) ); VECTOR2I newEnd = grid.AlignGrid( shape->GetEnd(), grid.GetItemGrid( shape ) ); @@ -423,8 +423,6 @@ int SYMBOL_EDITOR_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent ) break; - break; - case SHAPE_T::POLY: if( shape->GetPointCount() > 0 ) { @@ -513,7 +511,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent ) void SYMBOL_EDITOR_MOVE_TOOL::moveItem( EDA_ITEM* aItem, const VECTOR2I& aDelta ) { - static_cast( aItem )->Move( mapCoords( aDelta ) ); + static_cast( aItem )->Move( mapCoords( aDelta, true ) ); aItem->SetFlags( IS_MOVING ); } diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index d1f3037584..f5bc17124b 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -137,6 +137,21 @@ enum KICAD_T PCB_SHAPE_LOCATE_POLY_T, PCB_SHAPE_LOCATE_BEZIER_T, + /* + * Draw items in library symbol. + * + * The order of these items effects the sort order for items inside the + * "DRAW/ENDDRAW" section of the symbol definition in a library file. + * If you add a new draw item, type, please make sure you add it so the + * sort order is logical. + */ + LIB_SYMBOL_T, + SCH_SHAPE_T, + SCH_FIELD_T, + SCH_TEXT_T, + SCH_TEXTBOX_T, + LIB_PIN_T, + // Schematic draw Items. The order of these items effects the sort order. // It is currently ordered to mimic the old Eeschema locate behavior where // the smallest item is the selected item. @@ -146,17 +161,13 @@ enum KICAD_T SCH_BUS_WIRE_ENTRY_T, SCH_BUS_BUS_ENTRY_T, SCH_LINE_T, - SCH_SHAPE_T, SCH_BITMAP_T, - SCH_TEXTBOX_T, - SCH_TEXT_T, SCH_TABLE_T, SCH_TABLECELL_T, SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_DIRECTIVE_LABEL_T, - SCH_FIELD_T, SCH_SYMBOL_T, SCH_SHEET_PIN_T, SCH_SHEET_T, @@ -191,19 +202,6 @@ enum KICAD_T SCHEMATIC_T, - /* - * Draw items in library symbol. - * - * The order of these items effects the sort order for items inside the - * "DRAW/ENDDRAW" section of the symbol definition in a library file. - * If you add a new draw item, type, please make sure you add it so the - * sort order is logical. - */ - LIB_SYMBOL_T, - LIB_SHAPE_T, - LIB_TEXTBOX_T, - LIB_PIN_T, - /* * For GerbView: item types: */ @@ -411,8 +409,6 @@ constexpr bool IsEeschemaType( const KICAD_T aType ) case SCHEMATIC_T: case LIB_SYMBOL_T: - case LIB_SHAPE_T: - case LIB_TEXTBOX_T: case LIB_PIN_T: return true; diff --git a/include/eda_shape.h b/include/eda_shape.h index c8da3983b2..15d57b50cf 100644 --- a/include/eda_shape.h +++ b/include/eda_shape.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 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 @@ -119,8 +119,6 @@ public: void SetShape( SHAPE_T aShape ) { m_shape = aShape; } SHAPE_T GetShape() const { return m_shape; } - wxString GetFriendlyName() const; - /** * Return the starting point of the graphic. */ @@ -346,7 +344,9 @@ public: bool operator==( const EDA_SHAPE& aOther ) const; protected: - void setPosition( const VECTOR2I& aPos ); + wxString getFriendlyName() const; + + void setPosition( const VECTOR2I& aPos ); VECTOR2I getPosition() const; virtual void setFilled( bool aFlag ) diff --git a/pcbnew/pcb_shape.h b/pcbnew/pcb_shape.h index f22d0bf786..685beb2e02 100644 --- a/pcbnew/pcb_shape.h +++ b/pcbnew/pcb_shape.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 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 @@ -45,9 +45,9 @@ public: // Do not create a copy constructor & operator=. // The ones generated by the compiler are adequate. - ~PCB_SHAPE(); + ~PCB_SHAPE() override; - static inline bool ClassOf( const EDA_ITEM* aItem ) + static bool ClassOf( const EDA_ITEM* aItem ) { return aItem && PCB_SHAPE_T == aItem->Type(); } @@ -62,7 +62,7 @@ public: bool IsConnected() const override; - wxString GetFriendlyName() const override { return EDA_SHAPE::GetFriendlyName(); } + wxString GetFriendlyName() const override { return getFriendlyName(); } bool IsType( const std::vector& aScanTypes ) const override; @@ -150,15 +150,15 @@ public: int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth = false ) const override; - virtual wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override; + wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override; - virtual BITMAPS GetMenuImage() const override; + BITMAPS GetMenuImage() const override; - virtual EDA_ITEM* Clone() const override; + EDA_ITEM* Clone() const override; - virtual const BOX2I ViewBBox() const override; + const BOX2I ViewBBox() const override; - virtual void ViewGetLayers( int aLayers[], int& aCount ) const override; + void ViewGetLayers( int aLayers[], int& aCount ) const override; ///< @copydoc VIEW_ITEM::ViewGetLOD double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; @@ -172,7 +172,7 @@ public: #endif protected: - virtual void swapData( BOARD_ITEM* aImage ) override; + void swapData( BOARD_ITEM* aImage ) override; struct cmp_drawings { diff --git a/pcbnew/tools/pcb_point_editor.cpp b/pcbnew/tools/pcb_point_editor.cpp index 3d12419a04..36a2520648 100644 --- a/pcbnew/tools/pcb_point_editor.cpp +++ b/pcbnew/tools/pcb_point_editor.cpp @@ -94,12 +94,12 @@ enum CIRCLE_POINTS }; -enum BEZIER_CURVE_POINTS +enum BEZIER_POINTS { - BEZIER_CURVE_START, - BEZIER_CURVE_CONTROL_POINT1, - BEZIER_CURVE_CONTROL_POINT2, - BEZIER_CURVE_END + BEZIER_START, + BEZIER_CTRL_PT1, + BEZIER_CTRL_PT2, + BEZIER_END }; @@ -1398,14 +1398,14 @@ void PCB_POINT_EDITOR::updateItem( BOARD_COMMIT* aCommit ) } case SHAPE_T::BEZIER: - if( isModified( m_editPoints->Point( BEZIER_CURVE_START ) ) ) - shape->SetStart( m_editPoints->Point( BEZIER_CURVE_START ).GetPosition() ); - else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ) ) ) - shape->SetBezierC1( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition() ); - else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ) ) ) - shape->SetBezierC2( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition() ); - else if( isModified( m_editPoints->Point( BEZIER_CURVE_END ) ) ) - shape->SetEnd( m_editPoints->Point( BEZIER_CURVE_END ).GetPosition() ); + if( isModified( m_editPoints->Point( BEZIER_START ) ) ) + shape->SetStart( m_editPoints->Point( BEZIER_START ).GetPosition() ); + else if( isModified( m_editPoints->Point( BEZIER_CTRL_PT1 ) ) ) + shape->SetBezierC1( m_editPoints->Point( BEZIER_CTRL_PT1 ).GetPosition() ); + else if( isModified( m_editPoints->Point( BEZIER_CTRL_PT2 ) ) ) + shape->SetBezierC2( m_editPoints->Point( BEZIER_CTRL_PT2 ).GetPosition() ); + else if( isModified( m_editPoints->Point( BEZIER_END ) ) ) + shape->SetEnd( m_editPoints->Point( BEZIER_END ).GetPosition() ); shape->RebuildBezierToSegmentsPointsList( shape->GetWidth() ); break; @@ -1981,10 +1981,10 @@ void PCB_POINT_EDITOR::updatePoints() } case SHAPE_T::BEZIER: - m_editPoints->Point( BEZIER_CURVE_START ).SetPosition( shape->GetStart() ); - m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).SetPosition( shape->GetBezierC1() ); - m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).SetPosition( shape->GetBezierC2() ); - m_editPoints->Point( BEZIER_CURVE_END ).SetPosition( shape->GetEnd() ); + m_editPoints->Point( BEZIER_START ).SetPosition( shape->GetStart() ); + m_editPoints->Point( BEZIER_CTRL_PT1 ).SetPosition( shape->GetBezierC1() ); + m_editPoints->Point( BEZIER_CTRL_PT2 ).SetPosition( shape->GetBezierC2() ); + m_editPoints->Point( BEZIER_END ).SetPosition( shape->GetEnd() ); break; default: // suppress warnings diff --git a/qa/schematic_utils/schematic_file_util.cpp b/qa/schematic_utils/schematic_file_util.cpp index 84953e055c..a1f6665022 100644 --- a/qa/schematic_utils/schematic_file_util.cpp +++ b/qa/schematic_utils/schematic_file_util.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include diff --git a/qa/tests/eeschema/test_ee_item.cpp b/qa/tests/eeschema/test_ee_item.cpp index 94b39400fa..975dec7ea6 100644 --- a/qa/tests/eeschema/test_ee_item.cpp +++ b/qa/tests/eeschema/test_ee_item.cpp @@ -44,8 +44,6 @@ #include #include -#include -#include #include #include @@ -84,10 +82,10 @@ public: case SCH_BUS_WIRE_ENTRY_T: return new SCH_BUS_WIRE_ENTRY(); case SCH_BUS_BUS_ENTRY_T: return new SCH_BUS_BUS_ENTRY(); case SCH_LINE_T: return new SCH_LINE(); - case SCH_SHAPE_T: return new SCH_SHAPE( SHAPE_T::ARC ); + case SCH_SHAPE_T: return new SCH_SHAPE( SHAPE_T::ARC, LAYER_NOTES ); case SCH_BITMAP_T: return new SCH_BITMAP(); case SCH_TEXT_T: return new SCH_TEXT( VECTOR2I( 0, 0 ), "test text" ); - case SCH_TEXTBOX_T: return new SCH_TEXTBOX( 0, FILL_T::NO_FILL, "test textbox" ); + case SCH_TEXTBOX_T: return new SCH_TEXTBOX( LAYER_NOTES, 0, FILL_T::NO_FILL, "test textbox" ); case SCH_TABLECELL_T: return new SCH_TABLECELL(); case SCH_TABLE_T: { @@ -115,8 +113,6 @@ public: "test aPin" ); case SCH_SHEET_T: return new SCH_SHEET(); - case LIB_SHAPE_T: return new LIB_SHAPE( &m_symbol, SHAPE_T::ARC ); - case LIB_TEXTBOX_T: return new LIB_TEXTBOX( &m_symbol, 0, FILL_T::NO_FILL, "test" ); case LIB_PIN_T: return new LIB_PIN( &m_symbol ); case SCHEMATIC_T: diff --git a/qa/tests/eeschema/test_lib_part.cpp b/qa/tests/eeschema/test_lib_part.cpp index 0c946de615..6ea1a1fc64 100644 --- a/qa/tests/eeschema/test_lib_part.cpp +++ b/qa/tests/eeschema/test_lib_part.cpp @@ -29,7 +29,7 @@ #include // Code under test -#include +#include #include #include "lib_field_test_utils.h" @@ -409,22 +409,22 @@ BOOST_AUTO_TEST_CASE( Compare ) m_part_no_data.SetNormal(); // Draw item list size comparison tests. - testPart.AddDrawItem( new LIB_SHAPE( &testPart, SHAPE_T::RECTANGLE ) ); - m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::RECTANGLE ) ); + testPart.AddDrawItem( new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ) ); + m_part_no_data.AddDrawItem( new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ) ); BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ), 0 ); - m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_SHAPE_T].front() ); + m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_SHAPE_T].front() ); BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 ); - testPart.RemoveDrawItem( &testPart.GetDrawItems()[LIB_SHAPE_T].front() ); - m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::RECTANGLE ) ); + testPart.RemoveDrawItem( &testPart.GetDrawItems()[SCH_SHAPE_T].front() ); + m_part_no_data.AddDrawItem( new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ) ); BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); - m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_SHAPE_T].front() ); + m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_SHAPE_T].front() ); // Draw item list contents comparison tests. - testPart.AddDrawItem( new LIB_SHAPE( &testPart, SHAPE_T::RECTANGLE ) ); - m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::ARC ) ); + testPart.AddDrawItem( new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ) ); + m_part_no_data.AddDrawItem( new SCH_SHAPE( SHAPE_T::ARC, LAYER_DEVICE ) ); BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); - m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_SHAPE_T].front() ); - testPart.RemoveDrawItem( &testPart.GetDrawItems()[LIB_SHAPE_T].front() ); + m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_SHAPE_T].front() ); + testPart.RemoveDrawItem( &testPart.GetDrawItems()[SCH_SHAPE_T].front() ); m_part_no_data.AddDrawItem( new LIB_PIN( &m_part_no_data ) ); BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_PIN_T].front() );