RIP LIB_TEXTBOX and LIB_SHAPE.

This commit is contained in:
Jeff Young 2024-04-15 21:18:54 +01:00
parent 3efe504dcc
commit d761b4f22f
78 changed files with 3429 additions and 10132 deletions

View File

@ -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_SHEET: return SCH_SHEET_T;
case types::KiCadObjectType::KOT_SCH_PIN: return SCH_PIN_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_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_LIB_PIN: return LIB_PIN_T;
case types::KiCadObjectType::KOT_WSG_LINE: return WSG_LINE_T; case types::KiCadObjectType::KOT_WSG_LINE: return WSG_LINE_T;
case types::KiCadObjectType::KOT_WSG_RECT: return WSG_RECT_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_SHEET_T: return types::KiCadObjectType::KOT_SCH_SHEET;
case SCH_PIN_T: return types::KiCadObjectType::KOT_SCH_PIN; case SCH_PIN_T: return types::KiCadObjectType::KOT_SCH_PIN;
case LIB_SYMBOL_T: return types::KiCadObjectType::KOT_LIB_SYMBOL; 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 LIB_PIN_T: return types::KiCadObjectType::KOT_LIB_PIN;
case WSG_LINE_T: return types::KiCadObjectType::KOT_WSG_LINE; case WSG_LINE_T: return types::KiCadObjectType::KOT_WSG_LINE;
case WSG_RECT_T: return types::KiCadObjectType::KOT_WSG_RECT; case WSG_RECT_T: return types::KiCadObjectType::KOT_WSG_RECT;

View File

@ -396,8 +396,6 @@ static struct EDA_ITEM_DESC
.Map( SCH_SCREEN_T, _HKI( "SCH Screen" ) ) .Map( SCH_SCREEN_T, _HKI( "SCH Screen" ) )
.Map( LIB_SYMBOL_T, _HKI( "Symbol" ) ) .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( LIB_PIN_T, _HKI( "Pin" ) )
.Map( GERBER_LAYOUT_T, _HKI( "Gerber Layout" ) ) .Map( GERBER_LAYOUT_T, _HKI( "Gerber Layout" ) )

View File

@ -5,7 +5,7 @@
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2023 CERN * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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() ) if( IsProxyItem() )
{ {
@ -733,7 +733,7 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
wxString msg; wxString msg;
wxString shape = _( "Shape" ); wxString shape = _( "Shape" );
aList.emplace_back( shape, GetFriendlyName() ); aList.emplace_back( shape, getFriendlyName() );
switch( m_shape ) switch( m_shape )
{ {
@ -1322,12 +1322,7 @@ void EDA_SHAPE::DupPolyPointsList( std::vector<VECTOR2I>& aBuffer ) const
bool EDA_SHAPE::IsPolyShapeValid() const bool EDA_SHAPE::IsPolyShapeValid() const
{ {
// return true if the polygonal shape is valid (has more than 2 points) // return true if the polygonal shape is valid (has more than 2 points)
if( GetPolyShape().OutlineCount() == 0 ) return GetPolyShape().OutlineCount() > 0 && GetPolyShape().Outline( 0 ).PointCount() > 2;
return false;
const SHAPE_LINE_CHAIN& outline = static_cast<const SHAPE_POLY_SET&>( GetPolyShape() ).Outline( 0 );
return outline.PointCount() > 2;
} }
@ -1335,10 +1330,7 @@ int EDA_SHAPE::GetPointCount() const
{ {
// return the number of corners of the polygonal shape // return the number of corners of the polygonal shape
// this shape is expected to be only one polygon without hole // this shape is expected to be only one polygon without hole
if( GetPolyShape().OutlineCount() ) return GetPolyShape().OutlineCount() ? GetPolyShape().VertexCount( 0 ) : 0;
return GetPolyShape().VertexCount( 0 );
return 0;
} }

View File

@ -123,12 +123,8 @@ set( EESCHEMA_DLGS
dialogs/dialog_lib_edit_pin_table_base.cpp dialogs/dialog_lib_edit_pin_table_base.cpp
dialogs/dialog_lib_new_symbol.cpp dialogs/dialog_lib_new_symbol.cpp
dialogs/dialog_lib_new_symbol_base.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.cpp
dialogs/dialog_lib_symbol_properties_base.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.cpp
dialogs/dialog_line_properties_base.cpp dialogs/dialog_line_properties_base.cpp
dialogs/dialog_migrate_buses.cpp dialogs/dialog_migrate_buses.cpp
@ -360,9 +356,7 @@ set( EESCHEMA_SRCS
gfx_import_utils.cpp gfx_import_utils.cpp
picksymbol.cpp picksymbol.cpp
lib_pin.cpp lib_pin.cpp
lib_shape.cpp
lib_symbol.cpp lib_symbol.cpp
lib_textbox.cpp
libarch.cpp libarch.cpp
menubar.cpp menubar.cpp
net_navigator.cpp net_navigator.cpp

View File

@ -19,9 +19,7 @@
*/ */
#include <lib_pin.h> #include <lib_pin.h>
#include <lib_shape.h>
#include <lib_symbol.h> #include <lib_symbol.h>
#include <lib_textbox.h>
#include <sch_bitmap.h> #include <sch_bitmap.h>
#include <sch_bus_entry.h> #include <sch_bus_entry.h>
#include <sch_field.h> #include <sch_field.h>
@ -91,8 +89,6 @@ std::unique_ptr<EDA_ITEM> CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer
} }
case LIB_SYMBOL_T: return nullptr; // TODO: ctor currently requires non-null name case LIB_SYMBOL_T: return nullptr; // TODO: ctor currently requires non-null name
case LIB_SHAPE_T: return std::make_unique<LIB_SHAPE>( parentLibSymbol );
case LIB_TEXTBOX_T: return std::make_unique<LIB_TEXTBOX>( parentLibSymbol );
case LIB_PIN_T: return std::make_unique<LIB_PIN>( parentLibSymbol ); case LIB_PIN_T: return std::make_unique<LIB_PIN>( parentLibSymbol );
default: default:

View File

@ -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 <dialog_lib_shape_properties.h>
#include <symbol_edit_frame.h>
#include <symbol_editor_settings.h>
#include <confirm.h>
#include <lib_shape.h>
#include <widgets/color_swatch.h>
#include <settings/color_settings.h>
#include <sch_painter.h>
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<int>( 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();
}

View File

@ -1,64 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
* 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 <dialog_lib_shape_properties_base.h>
#include <widgets/unit_binder.h>
/**
* 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

View File

@ -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()
{
}

File diff suppressed because it is too large Load Diff

View File

@ -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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class COLOR_SWATCH;
class WX_INFOBAR;
#include "dialog_shim.h"
#include <wx/infobar.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/checkbox.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/panel.h>
#include <wx/bmpcbox.h>
#include <wx/gbsizer.h>
#include <wx/radiobut.h>
#include <wx/statbox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// 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();
};

View File

@ -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 <symbol_edit_frame.h>
#include <symbol_editor_settings.h>
#include <widgets/bitmap_button.h>
#include <widgets/font_choice.h>
#include <widgets/color_swatch.h>
#include <base_units.h>
#include <general.h>
#include <settings/color_settings.h>
#include <lib_textbox.h>
#include <confirm.h>
#include <dialogs/html_message_box.h>
#include <string_utils.h>
#include <scintilla_tricks.h>
#include <dialog_lib_textbox_properties.h>
#include "symbol_editor_drawing_tools.h"
#include <gr_text.h>
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<int>( 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<SYMBOL_EDITOR_DRAWING_TOOLS>();
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 );
}

View File

@ -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 <widgets/unit_binder.h>
#include <sch_text.h>
#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

View File

@ -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 );
}

File diff suppressed because it is too large Load Diff

View File

@ -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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class BITMAP_BUTTON;
class COLOR_SWATCH;
class FONT_CHOICE;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/stc/stc.h>
#include <wx/choice.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/hyperlink.h>
#include <wx/textctrl.h>
#include <wx/panel.h>
#include <wx/checkbox.h>
#include <wx/bmpcbox.h>
#include <wx/gbsizer.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// 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();
};

View File

@ -24,26 +24,36 @@
#include <widgets/color_swatch.h> #include <widgets/color_swatch.h>
#include <stroke_params.h> #include <stroke_params.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <symbol_edit_frame.h>
#include <sch_shape.h> #include <sch_shape.h>
#include <dialog_shape_properties.h> #include <dialog_shape_properties.h>
#include <settings/color_settings.h> #include <settings/color_settings.h>
#include <symbol_editor_settings.h>
#include <sch_commit.h> #include <sch_commit.h>
#include <string_utils.h>
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 ), DIALOG_SHAPE_PROPERTIES_BASE( aParent ),
m_frame( aParent ), m_frame( aParent ),
m_shape( aShape ), m_shape( aShape ),
m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits, true ) 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_helpLabel1->SetFont( KIUI::GetInfoFont( this ).Italic() );
m_helpLabel2->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->SetDefaultColor( COLOR4D::UNSPECIFIED );
m_borderColorSwatch->SetSwatchBackground( schematicBackground );
for( const auto& [ lineStyle, lineStyleDesc ] : lineTypeNames ) for( const auto& [ lineStyle, lineStyleDesc ] : lineTypeNames )
m_borderStyleCombo->Append( lineStyleDesc.name, KiBitmapBundle( lineStyleDesc.bitmap ) ); 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_borderStyleCombo->Append( DEFAULT_STYLE );
m_fillColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); m_fillColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
m_fillColorSwatch->SetSwatchBackground( schematicBackground );
KIGFX::COLOR4D canvas = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ); KIGFX::COLOR4D canvas = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
m_borderColorSwatch->SetSwatchBackground( canvas.ToColour() ); 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() ) if( m_frame->GetColorSettings()->GetOverrideSchItemColors() )
m_infoBar->ShowMessage( _( "Note: individual item colors overridden in Preferences." ) ); 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 // Required under wxGTK if we want to dismiss the dialog with the ESC key
SetFocus(); SetFocus();
SetupStandardButtons(); SetupStandardButtons();
if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( 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 // Now all widgets have the size fixed, call FinishDialogSettings
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() bool DIALOG_SHAPE_PROPERTIES::TransferDataToWindow()
{ {
if( !wxDialog::TransferDataToWindow() ) if( !wxDialog::TransferDataToWindow() )
@ -101,8 +145,66 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataToWindow()
else else
wxFAIL_MSG( "Line type not found in the type lookup map" ); wxFAIL_MSG( "Line type not found in the type lookup map" );
if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( 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_filledCtrl->SetValue( m_shape->IsFilled() );
m_fillColorSwatch->SetSwatchColor( m_shape->GetFillColor(), false ); m_fillColorSwatch->SetSwatchColor( m_shape->GetFillColor(), false );
}
return true; return true;
} }
@ -113,7 +215,16 @@ void DIALOG_SHAPE_PROPERTIES::onBorderChecked( wxCommandEvent& event )
bool border = m_borderCheckbox->GetValue(); bool border = m_borderCheckbox->GetValue();
if( border && m_borderWidth.GetValue() < 0 ) 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<SYMBOL_EDIT_FRAME*>( 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_borderWidth.Enable( border );
m_borderColorLabel->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() bool DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow()
{ {
if( !wxDialog::TransferDataFromWindow() ) if( !wxDialog::TransferDataFromWindow() )
@ -145,9 +302,14 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow()
STROKE_PARAMS stroke = m_shape->GetStroke(); STROKE_PARAMS stroke = m_shape->GetStroke();
if( m_borderCheckbox->GetValue() ) if( m_borderCheckbox->GetValue() )
{
if( !m_borderWidth.IsIndeterminate() )
stroke.SetWidth( std::max( 0, m_borderWidth.GetIntValue() ) ); stroke.SetWidth( std::max( 0, m_borderWidth.GetIntValue() ) );
}
else else
{
stroke.SetWidth( -1 ); stroke.SetWidth( -1 );
}
auto it = lineTypeNames.begin(); auto it = lineTypeNames.begin();
std::advance( it, m_borderStyleCombo->GetSelection() ); std::advance( it, m_borderStyleCombo->GetSelection() );
@ -161,13 +323,43 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow()
m_shape->SetStroke( stroke ); m_shape->SetStroke( stroke );
m_shape->SetFillMode( m_filledCtrl->GetValue() ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL ); if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( 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() ); m_shape->SetFillColor( m_fillColorSwatch->GetSwatchColor() );
}
if( !commit.Empty() ) if( !commit.Empty() )
{ commit.Push( wxString::Format( _( "Edit %s" ), m_shape->GetFriendlyName() ) );
commit.Push( wxString::Format( _( "Edit %s" ), m_shape->EDA_SHAPE::GetFriendlyName() ) );
}
return true; return true;
} }

View File

@ -26,7 +26,7 @@
class SCH_SHAPE; class SCH_SHAPE;
class SCH_EDIT_FRAME; class SCH_BASE_FRAME;
#include <dialog_shape_properties_base.h> #include <dialog_shape_properties_base.h>
@ -36,17 +36,24 @@ class SCH_EDIT_FRAME;
class DIALOG_SHAPE_PROPERTIES : public DIALOG_SHAPE_PROPERTIES_BASE class DIALOG_SHAPE_PROPERTIES : public DIALOG_SHAPE_PROPERTIES_BASE
{ {
public: 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 TransferDataToWindow() override;
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
private: bool GetApplyToAllConversions() { return m_checkApplyToAllBodyStyles->IsChecked(); }
void onBorderChecked( wxCommandEvent& aEvent) override; bool GetApplyToAllUnits() { return m_checkApplyToAllUnits->IsChecked(); }
void onFillChecked( wxCommandEvent& aEvent ) override;
private: 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; SCH_SHAPE* m_shape;
UNIT_BINDER m_borderWidth; UNIT_BINDER m_borderWidth;
}; };

View File

@ -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/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -15,6 +15,10 @@
BEGIN_EVENT_TABLE( DIALOG_SHAPE_PROPERTIES_BASE, DIALOG_SHIM ) 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_onBorderChecked )
EVT_CHECKBOX( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillChecked ) 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() 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 ) 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 ); mainSizer->Add( m_infoBar, 0, wxBOTTOM|wxEXPAND, 5 );
m_textEntrySizer = new wxGridBagSizer( 3, 3 ); wxBoxSizer* bColumns;
m_textEntrySizer->SetFlexibleDirection( wxBOTH ); bColumns = new wxBoxSizer( wxHORIZONTAL );
m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_textEntrySizer->SetEmptyCellSize( wxSize( 36,-1 ) ); 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_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 = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderWidthLabel->Wrap( -1 ); 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; wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL ); 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 ); 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 = new wxStaticText( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderStyleLabel->Wrap( -1 ); 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 = new wxBitmapComboBox( this, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) ); m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) );
m_textEntrySizer->Add( m_borderStyleCombo, wxGBPosition( 2, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_borderSizer->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_helpLabel1 = new wxStaticText( this, wxID_ANY, _("Set border width to 0 to use schematic's default line width."), wxDefaultPosition, wxDefaultSize, 0 ); 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 ); m_helpLabel1->Wrap( 320 );
bSizer12->Add( m_helpLabel1, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 10 ); 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 ); 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_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK ); m_sdbSizerOK = new wxButton( this, wxID_OK );

File diff suppressed because it is too large Load Diff

View File

@ -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/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -27,6 +27,9 @@ class WX_INFOBAR;
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/bmpcbox.h> #include <wx/bmpcbox.h>
#include <wx/gbsizer.h> #include <wx/gbsizer.h>
#include <wx/radiobut.h>
#include <wx/statbox.h>
#include <wx/simplebook.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/dialog.h> #include <wx/dialog.h>
@ -43,11 +46,21 @@ class DIALOG_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM
// Private event handlers // Private event handlers
void _wxFB_onBorderChecked( wxCommandEvent& event ){ onBorderChecked( event ); } void _wxFB_onBorderChecked( wxCommandEvent& event ){ onBorderChecked( event ); }
void _wxFB_onFillChecked( wxCommandEvent& event ){ onFillChecked( event ); } void _wxFB_onFillChecked( wxCommandEvent& event ){ onFillChecked( event ); }
void _wxFB_onFillRadioButton( wxCommandEvent& event ){ onFillRadioButton( event ); }
void _wxFB_onFill( wxCommandEvent& event ){ onFill( event ); }
protected: protected:
enum
{
NO_FILL = 1000,
FILLED_SHAPE,
FILLED_WITH_BG_BODYCOLOR,
FILLED_WITH_COLOR
};
WX_INFOBAR* m_infoBar; WX_INFOBAR* m_infoBar;
wxGridBagSizer* m_textEntrySizer; wxGridBagSizer* m_borderSizer;
wxCheckBox* m_borderCheckbox; wxCheckBox* m_borderCheckbox;
wxStaticText* m_borderWidthLabel; wxStaticText* m_borderWidthLabel;
wxTextCtrl* m_borderWidthCtrl; wxTextCtrl* m_borderWidthCtrl;
@ -57,12 +70,25 @@ class DIALOG_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM
COLOR_SWATCH* m_borderColorSwatch; COLOR_SWATCH* m_borderColorSwatch;
wxStaticText* m_borderStyleLabel; wxStaticText* m_borderStyleLabel;
wxBitmapComboBox* m_borderStyleCombo; wxBitmapComboBox* m_borderStyleCombo;
wxStaticText* m_helpLabel1;
wxSimplebook* m_fillBook;
wxPanel* m_schematicPage;
wxGridBagSizer* m_fillSizer;
wxCheckBox* m_filledCtrl; wxCheckBox* m_filledCtrl;
wxStaticText* m_fillColorLabel; wxStaticText* m_fillColorLabel;
wxPanel* m_panelFillColor; wxPanel* m_panelFillColor;
COLOR_SWATCH* m_fillColorSwatch; COLOR_SWATCH* m_fillColorSwatch;
wxStaticText* m_helpLabel1;
wxStaticText* m_helpLabel2; 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; wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK; wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel; 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 event handlers, override them in your derived class
virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); } virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); }
virtual void onFillChecked( 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: public:

View File

@ -37,7 +37,7 @@
#include <dialogs/html_message_box.h> #include <dialogs/html_message_box.h>
#include <scintilla_tricks.h> #include <scintilla_tricks.h>
#include <dialog_text_properties.h> #include <dialog_text_properties.h>
#include <gr_text.h> #include <string_utils.h>
DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_ITEM* aTextItem ) : 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 ); 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 ); m_textCtrl->SetEOLMode( wxSTC_EOL_LF );
#ifdef _WIN32 #ifdef _WIN32
@ -493,10 +498,8 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
m_currentItem->SetExcludedFromSim( m_excludeFromSim->GetValue() ); m_currentItem->SetExcludedFromSim( m_excludeFromSim->GetValue() );
if( m_isSymbolEditor ) if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame ) )
{ {
SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
m_currentItem->SetPrivate( m_privateCheckbox->GetValue() ); m_currentItem->SetPrivate( m_privateCheckbox->GetValue() );
if( !m_commonToAllUnits->GetValue() ) if( !m_commonToAllUnits->GetValue() )

View File

@ -24,7 +24,7 @@
#include <gal/gal_display_options.h> #include <gal/gal_display_options.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <layer_ids.h> #include <layer_ids.h>
#include <lib_shape.h> #include <sch_shape.h>
#include <math/vector2wx.h> #include <math/vector2wx.h>
#include <page_info.h> #include <page_info.h>
#include <panel_eeschema_color_settings.h> #include <panel_eeschema_color_settings.h>
@ -375,8 +375,9 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
symbol->SetShowPinNumbers( true ); symbol->SetShowPinNumbers( true );
symbol->SetPinNameOffset( 0 ); 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->SetUnit( 0 );
comp_body->SetBodyStyle( 0 ); comp_body->SetBodyStyle( 0 );
comp_body->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); comp_body->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );

View File

@ -26,7 +26,7 @@
#include <stdint.h> #include <stdint.h>
#include <lib_symbol.h> #include <lib_symbol.h>
#include <lib_shape.h> #include <sch_shape.h>
#include <import_gfx/graphics_importer_lib_symbol.h> #include <import_gfx/graphics_importer_lib_symbol.h>
#include <import_gfx/svg_import_plugin.h> #include <import_gfx/svg_import_plugin.h>
@ -118,8 +118,7 @@ void ConvertImageToLibShapes( LIB_SYMBOL* aSymbol, int unit, wxImage img, VECTOR
for( const SHAPE_POLY_SET::POLYGON& poly : polySet.CPolygons() ) for( const SHAPE_POLY_SET::POLYGON& poly : polySet.CPolygons() )
{ {
std::unique_ptr<LIB_SHAPE> shape = auto shape = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY, LAYER_DEVICE );
std::make_unique<LIB_SHAPE>( aSymbol, SHAPE_T::POLY );
shape->SetPolyShape( poly ); shape->SetPolyShape( poly );

View File

@ -26,7 +26,7 @@
#include "graphics_importer_lib_symbol.h" #include "graphics_importer_lib_symbol.h"
#include <lib_symbol.h> #include <lib_symbol.h>
#include <lib_shape.h> #include <sch_shape.h>
#include <sch_text.h> #include <sch_text.h>
#include <memory> #include <memory>
@ -81,7 +81,8 @@ void GRAPHICS_IMPORTER_LIB_SYMBOL::AddLine( const VECTOR2D& aStart, const VECTOR
if( pt0 == pt1 ) if( pt0 == pt1 )
return; return;
std::unique_ptr<LIB_SHAPE> line = std::make_unique<LIB_SHAPE>( m_symbol, SHAPE_T::POLY ); std::unique_ptr<SCH_SHAPE> line = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY, LAYER_DEVICE );
line->SetParent( m_symbol );
line->SetUnit( m_unit ); line->SetUnit( m_unit );
line->SetStroke( MapStrokeParams( aStroke ) ); 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 IMPORTED_STROKE& aStroke, bool aFilled,
const COLOR4D& aFillColor ) const COLOR4D& aFillColor )
{ {
std::unique_ptr<LIB_SHAPE> circle = std::make_unique<LIB_SHAPE>( m_symbol, SHAPE_T::CIRCLE ); std::unique_ptr<SCH_SHAPE> circle = std::make_unique<SCH_SHAPE>( SHAPE_T::CIRCLE, LAYER_DEVICE );
circle->SetParent( m_symbol );
circle->SetUnit( m_unit ); circle->SetUnit( m_unit );
circle->SetFillColor( aFillColor ); circle->SetFillColor( aFillColor );
circle->SetFilled( aFilled ); 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, void GRAPHICS_IMPORTER_LIB_SYMBOL::AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart,
const EDA_ANGLE& aAngle, const IMPORTED_STROKE& aStroke ) const EDA_ANGLE& aAngle, const IMPORTED_STROKE& aStroke )
{ {
std::unique_ptr<LIB_SHAPE> arc = std::make_unique<LIB_SHAPE>( m_symbol, SHAPE_T::ARC ); std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>( SHAPE_T::ARC, LAYER_DEVICE );
arc->SetParent( m_symbol );
arc->SetUnit( m_unit ); arc->SetUnit( m_unit );
/** /**
@ -160,7 +163,8 @@ void GRAPHICS_IMPORTER_LIB_SYMBOL::AddPolygon( const std::vector<VECTOR2D>& aVer
if( convertedPoints.empty() ) if( convertedPoints.empty() )
return; return;
std::unique_ptr<LIB_SHAPE> polygon = std::make_unique<LIB_SHAPE>( m_symbol, SHAPE_T::POLY ); std::unique_ptr<SCH_SHAPE> polygon = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY, LAYER_DEVICE );
polygon->SetParent( m_symbol );
polygon->SetUnit( m_unit ); polygon->SetUnit( m_unit );
if( aFilled ) if( aFilled )
@ -205,7 +209,8 @@ void GRAPHICS_IMPORTER_LIB_SYMBOL::AddSpline( const VECTOR2D& aStart,
const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd, const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd,
const IMPORTED_STROKE& aStroke ) const IMPORTED_STROKE& aStroke )
{ {
std::unique_ptr<LIB_SHAPE> spline = std::make_unique<LIB_SHAPE>( m_symbol, SHAPE_T::BEZIER ); std::unique_ptr<SCH_SHAPE> spline = std::make_unique<SCH_SHAPE>( SHAPE_T::BEZIER, LAYER_DEVICE );
spline->SetParent( m_symbol );
spline->SetUnit( m_unit ); spline->SetUnit( m_unit );
spline->SetStroke( MapStrokeParams( aStroke ) ); spline->SetStroke( MapStrokeParams( aStroke ) );
spline->SetStart( MapCoordinate( aStart ) ); spline->SetStart( MapCoordinate( aStart ) );

View File

@ -29,11 +29,8 @@
#include <import_gfx/graphics_importer.h> #include <import_gfx/graphics_importer.h>
#include <layer_ids.h>
class LIB_SYMBOL; class LIB_SYMBOL;
class LIB_SHAPE;
class LIB_TEXT;
class GRAPHICS_IMPORTER_LIB_SYMBOL : public GRAPHICS_IMPORTER class GRAPHICS_IMPORTER_LIB_SYMBOL : public GRAPHICS_IMPORTER
{ {

View File

@ -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 bool aIncludeElectricalType ) const
{ {
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>(); EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
@ -1269,9 +1269,10 @@ const BOX2I LIB_PIN::GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNa
bool includeType = aIncludeElectricalType; bool includeType = aIncludeElectricalType;
int minsizeV = TARGET_PIN_RADIUS; int minsizeV = TARGET_PIN_RADIUS;
if( !aIncludeInvisiblePins && !IsVisible() ) if( !aIncludeLabelsOnInvisiblePins && !IsVisible() )
{ {
includeName = false; includeName = false;
includeNumber = false;
includeType = false; includeType = false;
} }

View File

@ -27,7 +27,6 @@
#ifndef CLASS_PIN_H #ifndef CLASS_PIN_H
#define CLASS_PIN_H #define CLASS_PIN_H
#include <iostream>
#include <pin_type.h> #include <pin_type.h>
#include <lib_symbol.h> #include <lib_symbol.h>
@ -185,16 +184,15 @@ public:
const BOX2I GetBoundingBox() const override { return GetBoundingBox( false, true, true ); } const BOX2I GetBoundingBox() const override { return GetBoundingBox( false, true, true ); }
/** /**
* @param aIncludeInvisibles - if false, do not include labels for invisible pins * @param aIncludeLabelsOnInvisblePins - if false, do not include labels for invisible pins
* in the calculation. * in the calculation.
*/ */
const BOX2I GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber, const BOX2I GetBoundingBox( bool aIncludeLabelsOnInvisblePins, bool aIncludeNameAndNumber,
bool aIncludeElectricalType ) const; bool aIncludeElectricalType ) const;
/** /**
* Return whether this pin forms a global power connection: i.e., is part of * Return whether this pin forms a global power connection: i.e., is part of a power symbol
* a power symbol and of type POWER_IN, or is a legacy invisible global * and of type POWER_IN, or is a legacy invisible global power pin on a symbol.
* power pin on a symbol.
*/ */
bool IsGlobalPower() const bool IsGlobalPower() const
{ {
@ -222,11 +220,9 @@ public:
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override; void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
/** /**
* Plot the pin number and pin text info, given the pin line coordinates. * Plot the pin name and number.
* Same as DrawPinTexts((), but output is the plotter * @param aTextInside - draw the names & numbers inside the symbol body (ie: in the opposite
* The line must be vertical or horizontal. * direction of \a aPinOrient).
* 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.
*/ */
void PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient, void PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient,
int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed ) const; int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed ) const;

View File

@ -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 <sch_draw_panel.h>
#include <plotters/plotter.h>
#include <macros.h>
#include <base_units.h>
#include <widgets/msgpanel.h>
#include <bitmaps.h>
#include <eda_draw_frame.h>
#include <general.h>
#include <lib_shape.h>
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<const LIB_SHAPE&>( 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<VECTOR2I> 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<SHAPE*> 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<MSG_PANEL_ITEM>& 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<const LIB_SHAPE&>( 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<const LIB_SHAPE&>( 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<LIB_SHAPE, SCH_ITEM> );
propMgr.AddTypeCast( new TYPE_CAST<LIB_SHAPE, EDA_SHAPE> );
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<LIB_SHAPE*>( 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<FILL_T>& fillEnum = ENUM_MAP<FILL_T>::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 )

View File

@ -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 <sch_item.h>
#include <eda_shape.h>
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<MSG_PANEL_ITEM>& 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<SHAPE*> 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

View File

@ -33,7 +33,7 @@
#include <symbol_library.h> #include <symbol_library.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <settings/color_settings.h> #include <settings/color_settings.h>
#include <lib_shape.h> #include <sch_shape.h>
#include <memory> #include <memory>
@ -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 ) 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) ); aShapes.insert( &(*it) );
else if( it->Type() == SCH_FIELD_T ) else if( it->Type() == SCH_FIELD_T )
aFields.insert( &(*it) ); 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 ) 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) ); bShapes.insert( &(*it) );
else if( it->Type() == SCH_FIELD_T ) else if( it->Type() == SCH_FIELD_T )
bFields.insert( &(*it) ); 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 ); 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<LIB_SHAPE&>( item ); SCH_SHAPE& shape = static_cast<SCH_SHAPE&>( item );
if( shape.GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR ) if( shape.GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
aForceNoFill = true; aForceNoFill = true;
@ -800,9 +800,9 @@ void LIB_SYMBOL::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUni
if( item.IsPrivate() ) if( item.IsPrivate() )
continue; continue;
if( item.Type() == LIB_SHAPE_T ) if( item.Type() == SCH_SHAPE_T )
{ {
LIB_SHAPE& shape = static_cast<LIB_SHAPE&>( item ); SCH_SHAPE& shape = static_cast<SCH_SHAPE&>( item );
// Do not draw items not attached to the current part // Do not draw items not attached to the current part
if( aUnit && shape.m_unit && ( shape.m_unit != aUnit ) ) 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() void LIB_SYMBOL::FixupDrawItems()
{ {
std::vector<LIB_SHAPE*> potential_top_items; std::vector<SCH_SHAPE*> potential_top_items;
std::vector<SCH_ITEM*> bottom_items; std::vector<SCH_ITEM*> bottom_items;
for( SCH_ITEM& item : m_drawings ) for( SCH_ITEM& item : m_drawings )
{ {
if( item.Type() == LIB_SHAPE_T ) if( item.Type() == SCH_SHAPE_T )
{ {
LIB_SHAPE& shape = static_cast<LIB_SHAPE&>( item ); SCH_SHAPE& shape = static_cast<SCH_SHAPE&>( item );
if( shape.GetFillMode() == FILL_T::FILLED_WITH_COLOR ) if( shape.GetFillMode() == FILL_T::FILLED_WITH_COLOR )
potential_top_items.push_back( &shape ); potential_top_items.push_back( &shape );
@ -928,7 +928,7 @@ void LIB_SYMBOL::FixupDrawItems()
return a->GetBoundingBox().GetArea() > b->GetBoundingBox().GetArea(); 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 ) for( SCH_ITEM* bottom_item : bottom_items )
{ {

View File

@ -45,7 +45,7 @@ class TEST_LIB_SYMBOL_FIXTURE;
typedef std::shared_ptr<LIB_SYMBOL> LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL typedef std::shared_ptr<LIB_SYMBOL> LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL
typedef std::weak_ptr<LIB_SYMBOL> LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL typedef std::weak_ptr<LIB_SYMBOL> LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL
typedef MULTIVECTOR<SCH_ITEM, SCH_TEXT_T, LIB_PIN_T> LIB_ITEMS_CONTAINER; typedef MULTIVECTOR<SCH_ITEM, SCH_SHAPE_T, LIB_PIN_T> LIB_ITEMS_CONTAINER;
typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS; typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS;

View File

@ -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 <base_units.h>
#include <pgm_base.h>
#include <sch_edit_frame.h>
#include <plotters/plotter.h>
#include <widgets/msgpanel.h>
#include <bitmaps.h>
#include <string_utils.h>
#include <schematic.h>
#include <settings/color_settings.h>
#include <sch_painter.h>
#include <dialogs/html_message_box.h>
#include <project/project_file.h>
#include <project/net_settings.h>
#include <core/kicad_algo.h>
#include <trigo.h>
#include <lib_textbox.h>
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<const LIB_TEXTBOX*>( &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<const LIB_SHAPE&>( 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<SHAPE*> 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<VECTOR2I> 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<MSG_PANEL_ITEM>& 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<const LIB_TEXTBOX&>( 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<const LIB_TEXTBOX&>( 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<LIB_TEXTBOX, LIB_SHAPE> );
propMgr.AddTypeCast( new TYPE_CAST<LIB_TEXTBOX, EDA_SHAPE> );
propMgr.AddTypeCast( new TYPE_CAST<LIB_TEXTBOX, EDA_TEXT> );
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<LIB_TEXTBOX, int>( _HKI( "Margin Left" ),
&LIB_TEXTBOX::SetMarginLeft, &LIB_TEXTBOX::GetMarginLeft, PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<LIB_TEXTBOX, int>( _HKI( "Margin Top" ),
&LIB_TEXTBOX::SetMarginTop, &LIB_TEXTBOX::GetMarginTop, PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<LIB_TEXTBOX, int>( _HKI( "Margin Right" ),
&LIB_TEXTBOX::SetMarginRight, &LIB_TEXTBOX::GetMarginRight, PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<LIB_TEXTBOX, int>( _HKI( "Margin Bottom" ),
&LIB_TEXTBOX::SetMarginBottom, &LIB_TEXTBOX::GetMarginBottom, PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<LIB_TEXTBOX, int>( _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;

View File

@ -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 <eda_text.h>
#include <lib_shape.h>
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<MSG_PANEL_ITEM>& 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 */

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2022 CERN * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View File

@ -25,7 +25,6 @@
#include <memory> #include <memory>
#include "altium_parser_sch.h" #include "altium_parser_sch.h"
#include "sch_shape.h"
#include <io/io_utils.h> #include <io/io_utils.h>
#include <io/altium/altium_binary_parser.h> #include <io/altium/altium_binary_parser.h>
#include <io/altium/altium_ascii_parser.h> #include <io/altium/altium_ascii_parser.h>
@ -37,16 +36,15 @@
#include <project/project_file.h> #include <project/project_file.h>
#include <project/net_settings.h> #include <project/net_settings.h>
#include <lib_shape.h>
#include <lib_id.h> #include <lib_id.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <lib_textbox.h>
#include <sch_bitmap.h> #include <sch_bitmap.h>
#include <sch_bus_entry.h> #include <sch_bus_entry.h>
#include <sch_symbol.h> #include <sch_symbol.h>
#include <sch_junction.h> #include <sch_junction.h>
#include <sch_line.h> #include <sch_line.h>
#include <sch_shape.h>
#include <sch_no_connect.h> #include <sch_no_connect.h>
#include <sch_screen.h> #include <sch_screen.h>
#include <sch_label.h> #include <sch_label.h>
@ -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 ) ALTIUM_SCH_RECORD aType )
{ {
COLOR4D color = GetColorFromInt( elem.Color ); 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 ) ); 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 ) ALTIUM_SCH_RECORD aType, int aStrokeColor )
{ {
COLOR4D bgcolor = GetColorFromInt( elem.AreaColor ); 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_isIntLib = false;
m_rootSheet = nullptr; m_rootSheet = nullptr;
@ -1661,10 +1660,9 @@ void SCH_IO_ALTIUM::AddLibTextBox( const ASCH_TEXT_FRAME *aElem, std::vector<LIB
schsym = m_symbols.at( libSymbolIt->first ); schsym = m_symbols.at( libSymbolIt->first );
} }
LIB_TEXTBOX* textBox = new LIB_TEXTBOX( symbol ); SCH_TEXTBOX* textBox = new SCH_TEXTBOX( LAYER_DEVICE );
textBox->SetUnit( std::max( 0, aElem->ownerpartid ) ); textBox->SetUnit( std::max( 0, aElem->ownerpartid ) );
symbol->AddDrawItem( textBox, false ); symbol->AddDrawItem( textBox, false );
/// Handle text frames that are in a library symbol, not on schematic /// Handle text frames that are in a library symbol, not on schematic
@ -1808,7 +1806,7 @@ void SCH_IO_ALTIUM::ParseBezier( const std::map<wxString, wxString>& aProperties
if( i + 2 == elem.points.size() ) if( i + 2 == elem.points.size() )
{ {
// special case: single line // 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 ); symbol->AddDrawItem( line, false );
line->SetUnit( std::max( 0, elem.ownerpartid ) ); line->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -1830,7 +1828,7 @@ void SCH_IO_ALTIUM::ParseBezier( const std::map<wxString, wxString>& aProperties
// I haven't a clue what this is all about, but the sample document we have in // 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 // https://gitlab.com/kicad/code/kicad/-/issues/8974 responds best by treating it
// as another single line special case. // 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 ); symbol->AddDrawItem( line, false );
line->SetUnit( std::max( 0, elem.ownerpartid ) ); line->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -1849,7 +1847,7 @@ void SCH_IO_ALTIUM::ParseBezier( const std::map<wxString, wxString>& aProperties
else else
{ {
// Bezier always has exactly 4 control points // 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 ); symbol->AddDrawItem( bezier, false );
bezier->SetUnit( std::max( 0, elem.ownerpartid ) ); bezier->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -1935,7 +1933,7 @@ void SCH_IO_ALTIUM::ParsePolyline( const std::map<wxString, wxString>& aProperti
if( aSymbol.empty() && !IsComponentPartVisible( elem ) ) if( aSymbol.empty() && !IsComponentPartVisible( elem ) )
return; 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 ); symbol->AddDrawItem( line, false );
line->SetUnit( std::max( 0, elem.ownerpartid ) ); line->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -2006,7 +2004,7 @@ void SCH_IO_ALTIUM::ParsePolygon( const std::map<wxString, wxString>& aPropertie
if( aSymbol.empty() && !IsComponentPartVisible( elem ) ) if( aSymbol.empty() && !IsComponentPartVisible( elem ) )
return; 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 ); symbol->AddDrawItem( line, false );
line->SetUnit( std::max( 0, elem.ownerpartid ) ); line->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -2087,7 +2085,7 @@ void SCH_IO_ALTIUM::ParseRoundRectangle( const std::map<wxString, wxString>& aPr
if( aSymbol.empty() && !IsComponentPartVisible( elem ) ) if( aSymbol.empty() && !IsComponentPartVisible( elem ) )
return; return;
LIB_SHAPE* rect = nullptr; SCH_SHAPE* rect = nullptr;
int width = std::abs( elem.TopRight.x - elem.BottomLeft.x ); int width = std::abs( elem.TopRight.x - elem.BottomLeft.x );
int height = std::abs( elem.TopRight.y - elem.BottomLeft.y ); int height = std::abs( elem.TopRight.y - elem.BottomLeft.y );
@ -2096,7 +2094,7 @@ void SCH_IO_ALTIUM::ParseRoundRectangle( const std::map<wxString, wxString>& aPr
if( std::abs( elem.CornerRadius.x ) >= width / 2 if( std::abs( elem.CornerRadius.x ) >= width / 2
&& std::abs( elem.CornerRadius.y ) >= height / 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; VECTOR2I center = ( elem.TopRight + elem.BottomLeft ) / 2;
int radius = std::min( width / 2, height / 2 ); int radius = std::min( width / 2, height / 2 );
@ -2110,7 +2108,7 @@ void SCH_IO_ALTIUM::ParseRoundRectangle( const std::map<wxString, wxString>& aPr
} }
else else
{ {
rect = new LIB_SHAPE( symbol, SHAPE_T::RECTANGLE ); rect = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE );
if( !schsym ) if( !schsym )
{ {
@ -2205,7 +2203,7 @@ void SCH_IO_ALTIUM::ParseArc( const std::map<wxString, wxString>& aProperties,
if( elem.m_StartAngle == 0 && ( elem.m_EndAngle == 0 || elem.m_EndAngle == 360 ) ) 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 ); symbol->AddDrawItem( circle, false );
circle->SetUnit( std::max( 0, elem.ownerpartid ) ); circle->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -2220,7 +2218,7 @@ void SCH_IO_ALTIUM::ParseArc( const std::map<wxString, wxString>& aProperties,
} }
else 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 ); symbol->AddDrawItem( arc, false );
arc->SetUnit( std::max( 0, elem.ownerpartid ) ); arc->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -2317,7 +2315,7 @@ void SCH_IO_ALTIUM::ParseEllipticalArc( const std::map<wxString, wxString>& aPro
for( const BEZIER<int>& bezier : beziers ) for( const BEZIER<int>& 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 ); symbol->AddDrawItem( schbezier, false );
schbezier->SetUnit( std::max( 0, elem.ownerpartid ) ); schbezier->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -2441,7 +2439,7 @@ void SCH_IO_ALTIUM::ParseEllipse( const std::map<wxString, wxString>& aPropertie
for( const BEZIER<int>& bezier : beziers ) for( const BEZIER<int>& 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 ); symbol->AddDrawItem( libbezier, false );
libbezier->SetUnit( std::max( 0, elem.ownerpartid ) ); libbezier->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -2471,7 +2469,7 @@ void SCH_IO_ALTIUM::ParseEllipse( const std::map<wxString, wxString>& aPropertie
// Add a polygon to fill the center // Add a polygon to fill the center
if( elem.IsSolid ) 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 ); symbol->AddDrawItem( libline, false );
libline->SetUnit( std::max( 0, elem.ownerpartid ) ); libline->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -2536,7 +2534,7 @@ void SCH_IO_ALTIUM::ParseCircle( const std::map<wxString, wxString>& aProperties
schsym = m_symbols.at( libSymbolIt->first ); 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 ); symbol->AddDrawItem( circle, false );
circle->SetUnit( std::max( 0, elem.ownerpartid ) ); circle->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -2601,7 +2599,7 @@ void SCH_IO_ALTIUM::ParseLine( const std::map<wxString, wxString>& aProperties,
if( aSymbol.empty() && !IsComponentPartVisible( elem ) ) if( aSymbol.empty() && !IsComponentPartVisible( elem ) )
return; 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 ); symbol->AddDrawItem( line, false );
line->SetUnit( std::max( 0, elem.ownerpartid ) ); line->SetUnit( std::max( 0, elem.ownerpartid ) );
@ -2836,7 +2834,7 @@ void SCH_IO_ALTIUM::ParseRectangle( const std::map<wxString, wxString>& aPropert
if( aSymbol.empty() && !IsComponentPartVisible( elem ) ) if( aSymbol.empty() && !IsComponentPartVisible( elem ) )
return; 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 ); symbol->AddDrawItem( rect, false );
rect->SetUnit( std::max( 0, elem.ownerpartid ) ); 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 ) 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 ); aKsymbol->AddDrawItem( line1, false );
line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, 0 } );
@ -2984,7 +2982,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_
if( aStyle == ASCH_POWER_PORT_STYLE::CIRCLE ) 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 ); aKsymbol->AddDrawItem( circle, false );
circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) ); circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) );
circle->SetPosition( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -75 ) } ); circle->SetPosition( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -75 ) } );
@ -2992,7 +2990,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_
} }
else 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 ); aKsymbol->AddDrawItem( line2, false );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line2->AddPoint( { schIUScale.MilsToIU( -25 ), schIUScale.MilsToIU( -50 ) } ); 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 ) 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 ); aKsymbol->AddDrawItem( line, false );
line->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line->AddPoint( { 0, 0 } ); line->AddPoint( { 0, 0 } );
line->AddPoint( { 0, schIUScale.MilsToIU( -72 ) } ); 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 ); aKsymbol->AddDrawItem( bezier, false );
bezier->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) ); bezier->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) );
bezier->SetStart( { schIUScale.MilsToIU( 30 ), schIUScale.MilsToIU( -50 ) } ); 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::EARTH
|| aStyle == ASCH_POWER_PORT_STYLE::GOST_ARROW ) || 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 ); aKsymbol->AddDrawItem( line1, false );
line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, 0 } );
@ -3034,25 +3032,25 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_
if( aStyle == ASCH_POWER_PORT_STYLE::POWER_GROUND ) 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 ); aKsymbol->AddDrawItem( line2, false );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
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 ); aKsymbol->AddDrawItem( line3, false );
line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
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 ); aKsymbol->AddDrawItem( line4, false );
line4->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
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 ); aKsymbol->AddDrawItem( line5, false );
line5->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line5->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line5->AddPoint( { schIUScale.MilsToIU( -10 ), schIUScale.MilsToIU( -190 ) } ); 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 ) 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 ); aKsymbol->AddDrawItem( line2, false );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
@ -3070,7 +3068,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_
} }
else if( aStyle == ASCH_POWER_PORT_STYLE::EARTH ) 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 ); aKsymbol->AddDrawItem( line2, false );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line2->AddPoint( { schIUScale.MilsToIU( -150 ), schIUScale.MilsToIU( -200 ) } ); 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( 100 ), schIUScale.MilsToIU( -100 ) } );
line2->AddPoint( { schIUScale.MilsToIU( 50 ), schIUScale.MilsToIU( -200 ) } ); 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 ); aKsymbol->AddDrawItem( line3, false );
line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line3->AddPoint( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -100 ) } ); 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 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 ); aKsymbol->AddDrawItem( line2, false );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line2->AddPoint( { schIUScale.MilsToIU( -25 ), schIUScale.MilsToIU( -50 ) } ); 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 else if( aStyle == ASCH_POWER_PORT_STYLE::GOST_POWER_GROUND
|| aStyle == ASCH_POWER_PORT_STYLE::GOST_EARTH ) || 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 ); aKsymbol->AddDrawItem( line1, false );
line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, 0 } );
line1->AddPoint( { 0, schIUScale.MilsToIU( -160 ) } ); 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 ); aKsymbol->AddDrawItem( line2, false );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
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 ); aKsymbol->AddDrawItem( line3, false );
line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
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 ); aKsymbol->AddDrawItem( line4, false );
line4->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line4->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line4->AddPoint( { schIUScale.MilsToIU( -20 ), schIUScale.MilsToIU( -240 ) } ); 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 ) if( aStyle == ASCH_POWER_PORT_STYLE::GOST_POWER_GROUND )
return { 0, schIUScale.MilsToIU( 300 ) }; 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 ); aKsymbol->AddDrawItem( circle, false );
circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
circle->SetPosition( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -160 ) } ); 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 ) 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 ); aKsymbol->AddDrawItem( line1, false );
line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, 0 } );
line1->AddPoint( { 0, schIUScale.MilsToIU( -200 ) } ); 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 ); aKsymbol->AddDrawItem( line2, false );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -200 ) } ); line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -200 ) } );
@ -3160,13 +3158,13 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_
RPT_SEVERITY_WARNING ); 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 ); aKsymbol->AddDrawItem( line1, false );
line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, 0 } );
line1->AddPoint( { 0, schIUScale.MilsToIU( -100 ) } ); 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 ); aKsymbol->AddDrawItem( line2, false );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line2->AddPoint( { schIUScale.MilsToIU( -50 ), schIUScale.MilsToIU( -100 ) } ); line2->AddPoint( { schIUScale.MilsToIU( -50 ), schIUScale.MilsToIU( -100 ) } );

View File

@ -26,6 +26,7 @@
#define _SCH_IO_ALTIUM_H_ #define _SCH_IO_ALTIUM_H_
#include <memory> #include <memory>
#include <sch_sheet_path.h>
#include <vector> #include <vector>
#include <sch_io/sch_io.h> #include <sch_io/sch_io.h>
#include <sch_io/sch_io_mgr.h> #include <sch_io/sch_io_mgr.h>

View File

@ -30,7 +30,6 @@
#include <core/mirror.h> #include <core/mirror.h>
#include <core/kicad_algo.h> #include <core/kicad_algo.h>
#include <eda_text.h> #include <eda_text.h>
#include <lib_shape.h>
#include <macros.h> #include <macros.h>
#include <progress_reporter.h> #include <progress_reporter.h>
#include <string_utils.h> #include <string_utils.h>
@ -1621,7 +1620,8 @@ const LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef( const SYMDEF_ID& aSymd
} }
else 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( shape->SetPolyShape( fig.Shape.ConvertToPolySet(
[&]( const VECTOR2I& aPt ) [&]( const VECTOR2I& aPt )
{ {
@ -1989,7 +1989,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices( const std::vect
{ {
cur = &aCadstarVertices.at( i ); cur = &aCadstarVertices.at( i );
LIB_SHAPE* shape = nullptr; SCH_SHAPE* shape = nullptr;
bool cw = false; bool cw = false;
VECTOR2I startPoint = getKiCadLibraryPoint( prev->End, aSymbolOrigin ); VECTOR2I startPoint = getKiCadLibraryPoint( prev->End, aSymbolOrigin );
VECTOR2I endPoint = getKiCadLibraryPoint( cur->End, aSymbolOrigin ); VECTOR2I endPoint = getKiCadLibraryPoint( cur->End, aSymbolOrigin );
@ -2009,7 +2009,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices( const std::vect
switch( cur->Type ) switch( cur->Type )
{ {
case VERTEX_TYPE::POINT: 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( startPoint );
shape->AddPoint( endPoint ); shape->AddPoint( endPoint );
break; break;
@ -2021,7 +2021,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices( const std::vect
case VERTEX_TYPE::ANTICLOCKWISE_SEMICIRCLE: case VERTEX_TYPE::ANTICLOCKWISE_SEMICIRCLE:
case VERTEX_TYPE::ANTICLOCKWISE_ARC: 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 ); shape->SetPosition( centerPoint );
@ -2396,12 +2396,12 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadShapeVertices( const std::vector<VERTEX>& a
{ {
SHAPE_ARC tempArc = cur->BuildArc( transformedStartPoint, pointTransform ); 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() ); arcShape->SetArcGeometry( tempArc.GetP0(), tempArc.GetArcMid(), tempArc.GetP1() );
loadItemOntoKiCadSheet( aCadstarSheetID, arcShape ); loadItemOntoKiCadSheet( aCadstarSheetID, arcShape );
}
break; break;
}
case VERTEX_TYPE::POINT: case VERTEX_TYPE::POINT:
{ {
@ -2415,14 +2415,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadShapeVertices( const std::vector<VERTEX>& a
segment->SetEndPoint( transformedEndPoint ); segment->SetEndPoint( transformedEndPoint );
loadItemOntoKiCadSheet( aCadstarSheetID, segment ); loadItemOntoKiCadSheet( aCadstarSheetID, segment );
}
break; break;
}
default: default:
wxFAIL_MSG( "Unknown CADSTAR Vertex type" ); wxFAIL_MSG( "Unknown CADSTAR Vertex type" );
} }
prev = cur; prev = cur;
} }
} }
@ -3209,9 +3208,9 @@ LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart( const LIB_SYMBOL* aSym
{ {
switch( item.Type() ) switch( item.Type() )
{ {
case KICAD_T::LIB_SHAPE_T: case KICAD_T::SCH_SHAPE_T:
{ {
LIB_SHAPE& shape = static_cast<LIB_SHAPE&>( item ); SCH_SHAPE& shape = static_cast<SCH_SHAPE&>( item );
if( shape.GetShape() == SHAPE_T::ARC ) 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 // Note: Need the custom comparison function to ensure the map is sorted correctly
std::map<VECTOR2I, SHAPE_LINE_CHAIN, decltype( compLambda )> uniqueSegments( compLambda ); std::map<VECTOR2I, SHAPE_LINE_CHAIN, decltype( compLambda )> 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<LIB_SHAPE&>( *shapeIt ); SCH_SHAPE& shape = static_cast<SCH_SHAPE&>( *shapeIt );
if( aGateNumber > 0 && shape.GetUnit() != aGateNumber ) if( aGateNumber > 0 && shape.GetUnit() != aGateNumber )
continue; continue;

View File

@ -36,11 +36,8 @@
#include <wx/txtstrm.h> #include <wx/txtstrm.h>
#include <wx/xml/xml.h> #include <wx/xml/xml.h>
#include <symbol_library.h>
#include <io/eagle/eagle_parser.h> #include <io/eagle/eagle_parser.h>
#include <string_utils.h> #include <string_utils.h>
#include <gr_text.h>
#include <lib_shape.h>
#include <lib_id.h> #include <lib_id.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <project.h> #include <project.h>
@ -2151,7 +2148,7 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBO
if( nodeName == wxT( "circle" ) ) if( nodeName == wxT( "circle" ) )
{ {
aSymbol->AddDrawItem( loadSymbolCircle( aSymbol, currentNode, aGateNumber ) ); aSymbol->AddDrawItem( loadSymbolCircle( currentNode, aGateNumber ) );
} }
else if( nodeName == wxT( "pin" ) ) else if( nodeName == wxT( "pin" ) )
{ {
@ -2215,11 +2212,11 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBO
} }
else if( nodeName == wxT( "polygon" ) ) else if( nodeName == wxT( "polygon" ) )
{ {
aSymbol->AddDrawItem( loadSymbolPolyLine( aSymbol, currentNode, aGateNumber ) ); aSymbol->AddDrawItem( loadSymbolPolyLine( currentNode, aGateNumber ) );
} }
else if( nodeName == wxT( "rectangle" ) ) else if( nodeName == wxT( "rectangle" ) )
{ {
aSymbol->AddDrawItem( loadSymbolRectangle( aSymbol, currentNode, aGateNumber ) ); aSymbol->AddDrawItem( loadSymbolRectangle( currentNode, aGateNumber ) );
} }
else if( nodeName == wxT( "text" ) ) else if( nodeName == wxT( "text" ) )
{ {
@ -2250,7 +2247,7 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBO
} }
else if( nodeName == wxT( "wire" ) ) else if( nodeName == wxT( "wire" ) )
{ {
aSymbol->AddDrawItem( loadSymbolWire( aSymbol, currentNode, aGateNumber ) ); aSymbol->AddDrawItem( loadSymbolWire( currentNode, aGateNumber ) );
} }
else if( nodeName == wxT( "frame" ) ) else if( nodeName == wxT( "frame" ) )
{ {
@ -2288,12 +2285,11 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBO
} }
LIB_SHAPE* SCH_IO_EAGLE::loadSymbolCircle( std::unique_ptr<LIB_SYMBOL>& aSymbol, SCH_SHAPE* SCH_IO_EAGLE::loadSymbolCircle( wxXmlNode* aCircleNode, int aGateNumber )
wxXmlNode* aCircleNode, int aGateNumber )
{ {
// Parse the circle properties // Parse the circle properties
ECIRCLE c( aCircleNode ); 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() ); VECTOR2I center( c.x.ToSchUnits(), c.y.ToSchUnits() );
circle->SetPosition( center ); circle->SetPosition( center );
@ -2305,11 +2301,10 @@ LIB_SHAPE* SCH_IO_EAGLE::loadSymbolCircle( std::unique_ptr<LIB_SYMBOL>& aSymbol,
} }
LIB_SHAPE* SCH_IO_EAGLE::loadSymbolRectangle( std::unique_ptr<LIB_SYMBOL>& aSymbol, SCH_SHAPE* SCH_IO_EAGLE::loadSymbolRectangle( wxXmlNode* aRectNode, int aGateNumber )
wxXmlNode* aRectNode, int aGateNumber )
{ {
ERECT rect( aRectNode ); 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->SetPosition( VECTOR2I( rect.x1.ToSchUnits(), rect.y1.ToSchUnits() ) );
rectangle->SetEnd( VECTOR2I( rect.x2.ToSchUnits(), rect.y2.ToSchUnits() ) ); rectangle->SetEnd( VECTOR2I( rect.x2.ToSchUnits(), rect.y2.ToSchUnits() ) );
@ -2336,8 +2331,7 @@ LIB_SHAPE* SCH_IO_EAGLE::loadSymbolRectangle( std::unique_ptr<LIB_SYMBOL>& aSymb
} }
SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr<LIB_SYMBOL>& aSymbol, SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( wxXmlNode* aWireNode, int aGateNumber )
wxXmlNode* aWireNode, int aGateNumber )
{ {
EWIRE ewire = EWIRE( aWireNode ); EWIRE ewire = EWIRE( aWireNode );
@ -2354,7 +2348,7 @@ SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr<LIB_SYMBOL>& aSymbol,
// if the wire is an arc // if the wire is an arc
if( ewire.curve ) 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 ); VECTOR2I center = ConvertArcCenter( begin, end, *ewire.curve * -1 );
double radius = sqrt( ( ( center.x - begin.x ) * ( center.x - begin.x ) ) + double radius = sqrt( ( ( center.x - begin.x ) * ( center.x - begin.x ) ) +
( ( center.y - begin.y ) * ( center.y - begin.y ) ) ); ( ( center.y - begin.y ) * ( center.y - begin.y ) ) );
@ -2382,7 +2376,7 @@ SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr<LIB_SYMBOL>& aSymbol,
} }
else 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( begin );
poly->AddPoint( end ); poly->AddPoint( end );
@ -2394,10 +2388,9 @@ SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr<LIB_SYMBOL>& aSymbol,
} }
LIB_SHAPE* SCH_IO_EAGLE::loadSymbolPolyLine( std::unique_ptr<LIB_SYMBOL>& aSymbol, SCH_SHAPE* SCH_IO_EAGLE::loadSymbolPolyLine( wxXmlNode* aPolygonNode, int aGateNumber )
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 ); EPOLYGON epoly( aPolygonNode );
wxXmlNode* vertex = aPolygonNode->GetChildren(); wxXmlNode* vertex = aPolygonNode->GetChildren();
VECTOR2I pt, prev_pt; VECTOR2I pt, prev_pt;
@ -2559,7 +2552,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
if( yMin > yMax ) if( yMin > yMax )
std::swap( yMin, 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( xMin, yMin ) );
lines->AddPoint( VECTOR2I( xMax, yMin ) ); lines->AddPoint( VECTOR2I( xMax, yMin ) );
lines->AddPoint( VECTOR2I( xMax, yMax ) ); lines->AddPoint( VECTOR2I( xMax, yMax ) );
@ -2569,7 +2562,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
if( !( eframe.border_left == false ) ) if( !( eframe.border_left == false ) )
{ {
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY ); lines = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE );
lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ), lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ),
yMin + schIUScale.MilsToIU( 150 ) ) ); yMin + schIUScale.MilsToIU( 150 ) ) );
lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ), lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ),
@ -2587,7 +2580,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
for( i = 1; i < eframe.rows; i++ ) for( i = 1; i < eframe.rows; i++ )
{ {
int newY = KiROUND( yMin + ( rowSpacing * (double) i ) ); int newY = KiROUND( yMin + ( rowSpacing * (double) i ) );
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY ); lines = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE );
lines->AddPoint( VECTOR2I( x1, newY ) ); lines->AddPoint( VECTOR2I( x1, newY ) );
lines->AddPoint( VECTOR2I( x2, newY ) ); lines->AddPoint( VECTOR2I( x2, newY ) );
aItems.push_back( lines ); aItems.push_back( lines );
@ -2609,7 +2602,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
if( !( eframe.border_right == false ) ) if( !( eframe.border_right == false ) )
{ {
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY ); lines = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE );
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ), lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
yMin + schIUScale.MilsToIU( 150 ) ) ); yMin + schIUScale.MilsToIU( 150 ) ) );
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ), lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
@ -2627,7 +2620,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
for( i = 1; i < eframe.rows; i++ ) for( i = 1; i < eframe.rows; i++ )
{ {
int newY = KiROUND( yMin + ( rowSpacing * (double) i ) ); int newY = KiROUND( yMin + ( rowSpacing * (double) i ) );
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY ); lines = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE );
lines->AddPoint( VECTOR2I( x1, newY ) ); lines->AddPoint( VECTOR2I( x1, newY ) );
lines->AddPoint( VECTOR2I( x2, newY ) ); lines->AddPoint( VECTOR2I( x2, newY ) );
aItems.push_back( lines ); aItems.push_back( lines );
@ -2649,7 +2642,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
if( !( eframe.border_top == false ) ) if( !( eframe.border_top == false ) )
{ {
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY ); lines = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE );
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ), lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
yMax - schIUScale.MilsToIU( 150 ) ) ); yMax - schIUScale.MilsToIU( 150 ) ) );
lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ), lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ),
@ -2667,7 +2660,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
for( i = 1; i < eframe.columns; i++ ) for( i = 1; i < eframe.columns; i++ )
{ {
int newX = KiROUND( xMin + ( columnSpacing * (double) i ) ); int newX = KiROUND( xMin + ( columnSpacing * (double) i ) );
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY ); lines = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE );
lines->AddPoint( VECTOR2I( newX, y1 ) ); lines->AddPoint( VECTOR2I( newX, y1 ) );
lines->AddPoint( VECTOR2I( newX, y2 ) ); lines->AddPoint( VECTOR2I( newX, y2 ) );
aItems.push_back( lines ); aItems.push_back( lines );
@ -2689,7 +2682,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
if( !( eframe.border_bottom == false ) ) if( !( eframe.border_bottom == false ) )
{ {
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY ); lines = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE );
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ), lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
yMin + schIUScale.MilsToIU( 150 ) ) ); yMin + schIUScale.MilsToIU( 150 ) ) );
lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ), lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ),
@ -2707,7 +2700,7 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
for( i = 1; i < eframe.columns; i++ ) for( i = 1; i < eframe.columns; i++ )
{ {
int newX = KiROUND( xMin + ( columnSpacing * (double) i ) ); int newX = KiROUND( xMin + ( columnSpacing * (double) i ) );
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY ); lines = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE );
lines->AddPoint( VECTOR2I( newX, y1 ) ); lines->AddPoint( VECTOR2I( newX, y1 ) );
lines->AddPoint( VECTOR2I( newX, y2 ) ); lines->AddPoint( VECTOR2I( newX, y2 ) );
aItems.push_back( lines ); aItems.push_back( lines );

View File

@ -51,11 +51,7 @@ class SCH_FIELD;
class STRING_UTF8_MAP; class STRING_UTF8_MAP;
class LIB_SYMBOL; class LIB_SYMBOL;
class SYMBOL_LIB; class SYMBOL_LIB;
class LIB_SHAPE;
class LIB_RECTANGLE;
class LIB_POLYLINE;
class LIB_PIN; class LIB_PIN;
class LIB_TEXT;
class wxXmlNode; class wxXmlNode;
@ -156,14 +152,10 @@ private:
bool loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBOL>& aSymbol, bool loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBOL>& aSymbol,
EDEVICE* aDevice, int aGateNumber, const wxString& aGateName ); EDEVICE* aDevice, int aGateNumber, const wxString& aGateName );
LIB_SHAPE* loadSymbolCircle( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aCircleNode, SCH_SHAPE* loadSymbolCircle( wxXmlNode* aCircleNode, int aGateNumber );
int aGateNumber ); SCH_SHAPE* loadSymbolRectangle( wxXmlNode* aRectNode, int aGateNumber );
LIB_SHAPE* loadSymbolRectangle( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aRectNode, SCH_SHAPE* loadSymbolPolyLine( wxXmlNode* aPolygonNode, int aGateNumber );
int aGateNumber ); SCH_ITEM* loadSymbolWire( wxXmlNode* aWireNode, int aGateNumber );
LIB_SHAPE* loadSymbolPolyLine( std::unique_ptr<LIB_SYMBOL>& aSymbol,
wxXmlNode* aPolygonNode, int aGateNumber );
SCH_ITEM* loadSymbolWire( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aWireNode,
int aGateNumber );
LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode*, EPIN* epin, LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode*, EPIN* epin,
int aGateNumber ); int aGateNumber );
SCH_TEXT* loadSymbolText( wxXmlNode* aLibText, int aGateNumber ); SCH_TEXT* loadSymbolText( wxXmlNode* aLibText, int aGateNumber );

View File

@ -27,20 +27,16 @@
#include <sch_io/sch_io_mgr.h> #include <sch_io/sch_io_mgr.h>
#include <schematic.h> #include <schematic.h>
#include <sch_sheet.h> #include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_line.h> #include <sch_line.h>
#include <lib_shape.h>
#include <sch_no_connect.h> #include <sch_no_connect.h>
#include <sch_label.h> #include <sch_label.h>
#include <sch_junction.h> #include <sch_junction.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <sch_shape.h> #include <sch_shape.h>
#include <sch_bitmap.h> #include <sch_bitmap.h>
#include <sch_bus_entry.h>
#include <string_utils.h> #include <string_utils.h>
#include <bezier_curves.h> #include <bezier_curves.h>
#include <wx/base64.h> #include <wx/base64.h>
#include <wx/url.h>
#include <wx/mstream.h> #include <wx/mstream.h>
#include <gfx_import_utils.h> #include <gfx_import_utils.h>
#include <import_gfx/svg_import_plugin.h> #include <import_gfx/svg_import_plugin.h>
@ -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 ) 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 ); aKsymbol->AddDrawItem( line1 );
line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, 0 } );
@ -187,7 +183,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F
if( aStyle == EASYEDA::POWER_FLAG_STYLE::CIRCLE ) 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 ); aKsymbol->AddDrawItem( circle );
circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) ); circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) );
circle->SetPosition( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -75 ) } ); circle->SetPosition( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -75 ) } );
@ -195,7 +191,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F
} }
else 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 ); aKsymbol->AddDrawItem( line2 );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line2->AddPoint( { schIUScale.MilsToIU( -25 ), schIUScale.MilsToIU( -50 ) } ); 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 ) 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 ); aKsymbol->AddDrawItem( line );
line->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line->AddPoint( { 0, 0 } ); line->AddPoint( { 0, 0 } );
line->AddPoint( { 0, schIUScale.MilsToIU( -72 ) } ); 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 ); aKsymbol->AddDrawItem( bezier );
bezier->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) ); bezier->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 5 ), LINE_STYLE::SOLID ) );
bezier->AddPoint( { schIUScale.MilsToIU( 30 ), schIUScale.MilsToIU( -50 ) } ); 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::EARTH
|| aStyle == EASYEDA::POWER_FLAG_STYLE::GOST_ARROW ) || 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 ); aKsymbol->AddDrawItem( line1 );
line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, 0 } );
@ -237,25 +233,25 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F
if( aStyle == EASYEDA::POWER_FLAG_STYLE::POWER_GROUND ) 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 ); aKsymbol->AddDrawItem( line2 );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
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 ); aKsymbol->AddDrawItem( line3 );
line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
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 ); aKsymbol->AddDrawItem( line4 );
line4->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
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 ); aKsymbol->AddDrawItem( line5 );
line5->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line5->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line5->AddPoint( { schIUScale.MilsToIU( -10 ), schIUScale.MilsToIU( -160 ) } ); 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 ) 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 ); aKsymbol->AddDrawItem( line2 );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
@ -273,7 +269,7 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F
} }
else if( aStyle == EASYEDA::POWER_FLAG_STYLE::EARTH ) 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 ); aKsymbol->AddDrawItem( line2 );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line2->AddPoint( { schIUScale.MilsToIU( -150 ), schIUScale.MilsToIU( -200 ) } ); 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( 100 ), schIUScale.MilsToIU( -100 ) } );
line2->AddPoint( { schIUScale.MilsToIU( 50 ), schIUScale.MilsToIU( -200 ) } ); 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 ); aKsymbol->AddDrawItem( line3 );
line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line3->AddPoint( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -100 ) } ); 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 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 ); aKsymbol->AddDrawItem( line2 );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line2->AddPoint( { schIUScale.MilsToIU( -25 ), schIUScale.MilsToIU( -50 ) } ); 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 else if( aStyle == EASYEDA::POWER_FLAG_STYLE::GOST_POWER_GROUND
|| aStyle == EASYEDA::POWER_FLAG_STYLE::GOST_EARTH ) || 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 ); aKsymbol->AddDrawItem( line1 );
line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, 0 } );
line1->AddPoint( { 0, schIUScale.MilsToIU( -160 ) } ); 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 ); aKsymbol->AddDrawItem( line2 );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
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 ); aKsymbol->AddDrawItem( line3 );
line3->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); 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 ) } );
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 ); aKsymbol->AddDrawItem( line4 );
line4->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line4->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line4->AddPoint( { schIUScale.MilsToIU( -20 ), schIUScale.MilsToIU( -240 ) } ); 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 ) if( aStyle == EASYEDA::POWER_FLAG_STYLE::GOST_POWER_GROUND )
return { 0, schIUScale.MilsToIU( 300 ) }; 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 ); aKsymbol->AddDrawItem( circle );
circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); circle->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
circle->SetPosition( { schIUScale.MilsToIU( 0 ), schIUScale.MilsToIU( -160 ) } ); 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 ) 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 ); aKsymbol->AddDrawItem( line1 );
line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, 0 } );
line1->AddPoint( { 0, schIUScale.MilsToIU( -200 ) } ); 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 ); aKsymbol->AddDrawItem( line2 );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -200 ) } ); line2->AddPoint( { schIUScale.MilsToIU( -100 ), schIUScale.MilsToIU( -200 ) } );
@ -363,13 +359,13 @@ VECTOR2I HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, EASYEDA::POWER_F
RPT_SEVERITY_WARNING ); 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 ); aKsymbol->AddDrawItem( line1 );
line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line1->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, 0 } );
line1->AddPoint( { 0, schIUScale.MilsToIU( -100 ) } ); 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 ); aKsymbol->AddDrawItem( line2 );
line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) ); line2->SetStroke( STROKE_PARAMS( schIUScale.MilsToIU( 10 ), LINE_STYLE::SOLID ) );
line2->AddPoint( { schIUScale.MilsToIU( -50 ), schIUScale.MilsToIU( -100 ) } ); 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] ) ) ) ); RelPosSym( VECTOR2I( Convert( ptArr[i - 1] ), Convert( ptArr[i] ) ) ) );
} }
std::unique_ptr<LIB_SHAPE> line = std::make_unique<LIB_SHAPE>( aSymbol, SHAPE_T::POLY ); auto line = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY, LAYER_DEVICE );
if( elType == wxS( "PG" ) ) if( elType == wxS( "PG" ) )
chain.SetClosed( true ); chain.SetClosed( true );
@ -449,8 +445,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol
for( SHAPE_LINE_CHAIN outline : lineChains ) for( SHAPE_LINE_CHAIN outline : lineChains )
{ {
std::unique_ptr<LIB_SHAPE> shape = auto shape = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY, LAYER_DEVICE );
std::make_unique<LIB_SHAPE>( aSymbol, SHAPE_T::POLY );
outline.Mirror( false, true ); outline.Mirror( false, true );
@ -631,7 +626,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol
if( cw ) if( cw )
std::swap( start, end ); std::swap( start, end );
std::unique_ptr<LIB_SHAPE> shape = std::make_unique<LIB_SHAPE>( aSymbol, SHAPE_T::ARC ); auto shape = std::make_unique<SCH_SHAPE>( SHAPE_T::ARC, LAYER_DEVICE );
shape->SetStart( RelPosSym( start ) ); shape->SetStart( RelPosSym( start ) );
shape->SetEnd( RelPosSym( end ) ); shape->SetEnd( RelPosSym( end ) );
@ -669,8 +664,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol
//if( cr.x == 0 ) //if( cr.x == 0 )
{ {
std::unique_ptr<LIB_SHAPE> rect = auto rect = std::make_unique<SCH_SHAPE>( SHAPE_T::RECTANGLE, LAYER_DEVICE );
std::make_unique<LIB_SHAPE>( aSymbol, SHAPE_T::RECTANGLE );
rect->SetStart( RelPosSym( start ) ); rect->SetStart( RelPosSym( start ) );
rect->SetEnd( RelPosSym( start + size ) ); rect->SetEnd( RelPosSym( start + size ) );
@ -694,8 +688,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol
} }
else if( elType == wxS( "E" ) ) else if( elType == wxS( "E" ) )
{ {
std::unique_ptr<LIB_SHAPE> circle = auto circle = std::make_unique<SCH_SHAPE>( SHAPE_T::CIRCLE, LAYER_DEVICE );
std::make_unique<LIB_SHAPE>( aSymbol, SHAPE_T::CIRCLE );
VECTOR2D center( Convert( arr[1] ), Convert( arr[2] ) ); VECTOR2D center( Convert( arr[1] ), Convert( arr[2] ) );
VECTOR2D radius( Convert( arr[3] ), Convert( arr[4] ) ); // TODO: corner radius 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 // M360,290h10 or M 420 300 h -5
wxString lineData = pinPathColorParts[0]; wxString lineData = pinPathColorParts[0];
wxRegEx regex( wxRegEx regex( wxS( "^M\\s*([-\\d.]+)[,\\s]([-\\d.]+)\\s*([h|v])\\s*([-\\d.]+)\\s*$" ) );
wxS( "^M\\s*([-\\d.]+)[,\\s]([-\\d.]+)\\s*([h|v])\\s*([-\\d.]+)\\s*$" ) );
if( regex.Matches( lineData ) ) if( regex.Matches( lineData ) )
{ {
startPoint.x = Convert( regex.GetMatch( lineData, 1 ) ); 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] ) ); VECTOR2D dotPos( Convert( dotParts[1] ), Convert( dotParts[2] ) );
std::unique_ptr<LIB_SHAPE> circle = auto circle = std::make_unique<SCH_SHAPE>( SHAPE_T::CIRCLE, LAYER_DEVICE );
std::make_unique<LIB_SHAPE>( aSymbol, SHAPE_T::CIRCLE );
circle->SetCenter( RelPosSym( dotPos ) ); circle->SetCenter( RelPosSym( dotPos ) );
circle->SetEnd( RelPosSym( circle->SetEnd( RelPosSym(
@ -835,8 +827,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol
for( SHAPE_LINE_CHAIN outline : lineChains ) for( SHAPE_LINE_CHAIN outline : lineChains )
{ {
std::unique_ptr<LIB_SHAPE> shape = auto shape = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY, LAYER_DEVICE );
std::make_unique<LIB_SHAPE>( aSymbol, SHAPE_T::POLY );
outline.Mirror( false, true ); outline.Mirror( false, true );

View File

@ -29,19 +29,9 @@
#include <io/easyeda/easyeda_parser_structs.h> #include <io/easyeda/easyeda_parser_structs.h>
#include <sch_io/sch_io_mgr.h> #include <sch_io/sch_io_mgr.h>
#include <pin_type.h>
#include <layer_ids.h>
#include <wx/filename.h>
#include <plotters/plotter.h>
class EDA_TEXT; 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 class SCH_EASYEDA_PARSER: public EASYEDA_PARSER_BASE
{ {

View File

@ -30,16 +30,13 @@
#include <sch_io/sch_io_mgr.h> #include <sch_io/sch_io_mgr.h>
#include <schematic.h> #include <schematic.h>
#include <sch_sheet.h> #include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_line.h> #include <sch_line.h>
#include <sch_bitmap.h> #include <sch_bitmap.h>
#include <lib_shape.h>
#include <sch_no_connect.h> #include <sch_no_connect.h>
#include <sch_label.h> #include <sch_label.h>
#include <sch_junction.h> #include <sch_junction.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <sch_shape.h> #include <sch_shape.h>
#include <sch_bus_entry.h>
#include <string_utils.h> #include <string_utils.h>
#include <bezier_curves.h> #include <bezier_curves.h>
#include <wx/base64.h> #include <wx/base64.h>
@ -429,8 +426,7 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector<nlohm
VECTOR2D end( line.at( 4 ), line.at( 5 ) ); VECTOR2D end( line.at( 4 ), line.at( 5 ) );
wxString styleStr = line.at( 9 ); wxString styleStr = line.at( 9 );
std::unique_ptr<LIB_SHAPE> rect = auto rect = std::make_unique<SCH_SHAPE>( SHAPE_T::RECTANGLE, LAYER_DEVICE );
std::make_unique<LIB_SHAPE>( ksymbol, SHAPE_T::RECTANGLE );
rect->SetStart( ScalePosSym( start ) ); rect->SetStart( ScalePosSym( start ) );
rect->SetEnd( ScalePosSym( end ) ); rect->SetEnd( ScalePosSym( end ) );
@ -446,8 +442,7 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector<nlohm
double radius = line.at( 4 ); double radius = line.at( 4 );
wxString styleStr = line.at( 5 ); wxString styleStr = line.at( 5 );
std::unique_ptr<LIB_SHAPE> circle = auto circle = std::make_unique<SCH_SHAPE>( SHAPE_T::CIRCLE, LAYER_DEVICE );
std::make_unique<LIB_SHAPE>( ksymbol, SHAPE_T::CIRCLE );
circle->SetCenter( ScalePosSym( center ) ); circle->SetCenter( ScalePosSym( center ) );
circle->SetEnd( circle->GetCenter() + VECTOR2I( ScaleSize( radius ), 0 ) ); circle->SetEnd( circle->GetCenter() + VECTOR2I( ScaleSize( radius ), 0 ) );
@ -470,7 +465,7 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector<nlohm
VECTOR2D kcenter = CalcArcCenter( kstart, kmid, kend ); VECTOR2D kcenter = CalcArcCenter( kstart, kmid, kend );
std::unique_ptr<LIB_SHAPE> shape = std::make_unique<LIB_SHAPE>( ksymbol, SHAPE_T::ARC ); auto shape = std::make_unique<SCH_SHAPE>( SHAPE_T::ARC, LAYER_DEVICE );
shape->SetStart( kstart ); shape->SetStart( kstart );
shape->SetEnd( kend ); shape->SetEnd( kend );
@ -492,13 +487,10 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector<nlohm
std::vector<double> points = line.at( 2 ); std::vector<double> points = line.at( 2 );
wxString styleStr = line.at( 4 ); wxString styleStr = line.at( 4 );
std::unique_ptr<LIB_SHAPE> shape = auto shape = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY, LAYER_DEVICE );
std::make_unique<LIB_SHAPE>( ksymbol, SHAPE_T::POLY );
for( size_t i = 1; i < points.size(); i += 2 ) for( size_t i = 1; i < points.size(); i += 2 )
{
shape->AddPoint( ScalePosSym( VECTOR2D( points[i - 1], points[i] ) ) ); shape->AddPoint( ScalePosSym( VECTOR2D( points[i - 1], points[i] ) ) );
}
shape->SetUnit( currentUnit ); shape->SetUnit( currentUnit );
ApplyLineStyle( lineStyles, shape, styleStr ); ApplyLineStyle( lineStyles, shape, styleStr );

View File

@ -30,17 +30,11 @@
#include <sch_io/sch_io_mgr.h> #include <sch_io/sch_io_mgr.h>
#include <pin_type.h> #include <pin_type.h>
#include <layer_ids.h> #include <layer_ids.h>
#include <wx/filename.h>
#include <plotters/plotter.h> #include <plotters/plotter.h>
class EDA_TEXT; class EDA_TEXT;
class LIB_SHAPE;
class LIB_PIN;
class SCH_LABEL_BASE;
class SCH_SYMBOL; class SCH_SYMBOL;
class SCH_TEXT;
class SCH_SHAPE;
namespace EASYEDAPRO namespace EASYEDAPRO
{ {

View File

@ -20,7 +20,7 @@
#include <magic_enum.hpp> #include <magic_enum.hpp>
#include <wx/log.h> #include <wx/log.h>
#include <lib_shape.h> #include <sch_shape.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <sch_text.h> #include <sch_text.h>
#include <macros.h> #include <macros.h>
@ -712,11 +712,11 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDrawEntries( std::unique_ptr<LIB_SYMBOL>
switch( line[0] ) switch( line[0] )
{ {
case 'A': // Arc case 'A': // Arc
aSymbol->AddDrawItem( loadArc( aSymbol, aReader ), false ); aSymbol->AddDrawItem( loadArc( aReader ), false );
break; break;
case 'C': // Circle case 'C': // Circle
aSymbol->AddDrawItem( loadCircle( aSymbol, aReader ), false ); aSymbol->AddDrawItem( loadCircle( aReader ), false );
break; break;
case 'T': // Text case 'T': // Text
@ -724,7 +724,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDrawEntries( std::unique_ptr<LIB_SYMBOL>
break; break;
case 'S': // Square case 'S': // Square
aSymbol->AddDrawItem( loadRect( aSymbol, aReader ), false ); aSymbol->AddDrawItem( loadRect( aReader ), false );
break; break;
case 'X': // Pin Description case 'X': // Pin Description
@ -732,11 +732,11 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDrawEntries( std::unique_ptr<LIB_SYMBOL>
break; break;
case 'P': // Polyline case 'P': // Polyline
aSymbol->AddDrawItem( loadPolyLine( aSymbol, aReader ), false ); aSymbol->AddDrawItem( loadPolyLine( aReader ), false );
break; break;
case 'B': // Bezier Curves case 'B': // Bezier Curves
aSymbol->AddDrawItem( loadBezier( aSymbol, aReader ), false ); aSymbol->AddDrawItem( loadBezier( aReader ), false );
break; break;
case '#': // Comment 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<LIB_SYMBOL>& aSymbol, SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc( LINE_READER& aReader )
LINE_READER& aReader )
{ {
const char* line = aReader.Line(); const char* line = aReader.Line();
wxCHECK_MSG( strCompare( "A", line, &line ), nullptr, "Invalid arc definition" ); 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; VECTOR2I center;
@ -915,14 +914,13 @@ LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc( std::unique_ptr<LIB_SYMBOL>&
} }
LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadCircle( std::unique_ptr<LIB_SYMBOL>& aSymbol, SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadCircle( LINE_READER& aReader )
LINE_READER& aReader )
{ {
const char* line = aReader.Line(); const char* line = aReader.Line();
wxCHECK_MSG( strCompare( "C", line, &line ), nullptr, "Invalid circle definition" ); 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; VECTOR2I center;
@ -953,7 +951,7 @@ SCH_TEXT* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText( LINE_READER& aReader,
{ {
const char* line = aReader.Line(); 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; double angleInTenths;
VECTOR2I center; 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<LIB_SYMBOL>& aSymbol, SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadRect( LINE_READER& aReader )
LINE_READER& aReader )
{ {
const char* line = aReader.Line(); const char* line = aReader.Line();
wxCHECK_MSG( strCompare( "S", line, &line ), nullptr, "Invalid rectangle definition" ); 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; VECTOR2I pos;
@ -1299,14 +1296,13 @@ LIB_PIN* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin( std::unique_ptr<LIB_SYMBOL>& aS
} }
LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPolyLine( std::unique_ptr<LIB_SYMBOL>& aSymbol, SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPolyLine( LINE_READER& aReader )
LINE_READER& aReader )
{ {
const char* line = aReader.Line(); const char* line = aReader.Line();
wxCHECK_MSG( strCompare( "P", line, &line ), nullptr, "Invalid poly definition" ); 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 ); int points = parseInt( aReader, line, &line );
polyLine->SetUnit( 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<LIB_SYMB
} }
LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadBezier( std::unique_ptr<LIB_SYMBOL>& aSymbol, SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadBezier( LINE_READER& aReader )
LINE_READER& aReader )
{ {
const char* line = aReader.Line(); const char* line = aReader.Line();
@ -1344,7 +1339,7 @@ LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadBezier( std::unique_ptr<LIB_SYMBOL
wxCHECK_MSG( points == 4, NULL, "Invalid Bezier curve definition" ); wxCHECK_MSG( points == 4, NULL, "Invalid Bezier curve definition" );
LIB_SHAPE* bezier = new LIB_SHAPE( aSymbol.get(), SHAPE_T::BEZIER ); SCH_SHAPE* bezier = new SCH_SHAPE( SHAPE_T::BEZIER, LAYER_DEVICE );
bezier->SetUnit( parseInt( aReader, line, &line ) ); bezier->SetUnit( parseInt( aReader, line, &line ) );
bezier->SetBodyStyle( 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() ) switch( item.Type() )
{ {
case LIB_PIN_T: savePin( static_cast<LIB_PIN*>( &item ), aFormatter ); break; case LIB_PIN_T:
case SCH_TEXT_T: saveText( static_cast<SCH_TEXT*>( &item ), aFormatter ); break; savePin( static_cast<LIB_PIN*>( &item ), aFormatter );
case LIB_SHAPE_T:
break;
case SCH_TEXT_T:
saveText( static_cast<SCH_TEXT*>( &item ), aFormatter );
break;
case SCH_SHAPE_T:
{ {
LIB_SHAPE& shape = static_cast<LIB_SHAPE&>( item ); SCH_SHAPE& shape = static_cast<SCH_SHAPE&>( item );
switch( shape.GetShape() ) 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; case SHAPE_T::RECTANGLE: saveRectangle( &shape, aFormatter ); break;
default: 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." ); 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." ); 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." ); 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 ) OUTPUTFORMATTER& aFormatter )
{ {
wxCHECK_RET( aPolyLine && aPolyLine->GetShape() == SHAPE_T::POLY, "Invalid POLY object." ); 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 ) OUTPUTFORMATTER& aFormatter )
{ {
wxCHECK_RET( aRectangle && aRectangle->GetShape() == SHAPE_T::RECTANGLE, wxCHECK_RET( aRectangle && aRectangle->GetShape() == SHAPE_T::RECTANGLE,

View File

@ -30,8 +30,8 @@
class FILE_LINE_READER; class FILE_LINE_READER;
class LIB_PIN; class LIB_PIN;
class LIB_SHAPE; class SCH_SHAPE;
class LIB_TEXT; class SCH_TEXT;
class LINE_READER; class LINE_READER;
class SCH_IO_KICAD_LEGACY; class SCH_IO_KICAD_LEGACY;
@ -73,24 +73,24 @@ private:
static void loadFootprintFilters( std::unique_ptr<LIB_SYMBOL>& aSymbol, static void loadFootprintFilters( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader ); LINE_READER& aReader );
void loadDocs(); void loadDocs();
static LIB_SHAPE* loadArc( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader ); static SCH_SHAPE* loadArc( LINE_READER& aReader );
static LIB_SHAPE* loadCircle( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader ); static SCH_SHAPE* loadCircle( LINE_READER& aReader );
static SCH_TEXT* loadText( LINE_READER& aReader, int aMajorVersion, int aMinorVersion ); static SCH_TEXT* loadText( LINE_READER& aReader, int aMajorVersion, int aMinorVersion );
static LIB_SHAPE* loadRect( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader ); static SCH_SHAPE* loadRect( LINE_READER& aReader );
static LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader ); static LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
static LIB_SHAPE* loadPolyLine( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader ); static SCH_SHAPE* loadPolyLine( LINE_READER& aReader );
static LIB_SHAPE* loadBezier( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader ); static SCH_SHAPE* loadBezier( LINE_READER& aReader );
static FILL_T parseFillMode( LINE_READER& aReader, const char* aLine, const char** aOutput ); static FILL_T parseFillMode( LINE_READER& aReader, const char* aLine, const char** aOutput );
void saveDocFile(); void saveDocFile();
static void saveArc( LIB_SHAPE* aArc, OUTPUTFORMATTER& aFormatter ); static void saveArc( SCH_SHAPE* aArc, OUTPUTFORMATTER& aFormatter );
static void saveBezier( LIB_SHAPE* aBezier, OUTPUTFORMATTER& aFormatter ); static void saveBezier( SCH_SHAPE* aBezier, OUTPUTFORMATTER& aFormatter );
static void saveCircle( LIB_SHAPE* aCircle, OUTPUTFORMATTER& aFormatter ); static void saveCircle( SCH_SHAPE* aCircle, OUTPUTFORMATTER& aFormatter );
static void saveField( const SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter ); static void saveField( const SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter );
static void savePin( const LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter ); static void savePin( const LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter );
static void savePolyLine( LIB_SHAPE* aPolyLine, OUTPUTFORMATTER& aFormatter ); static void savePolyLine( SCH_SHAPE* aPolyLine, OUTPUTFORMATTER& aFormatter );
static void saveRectangle( LIB_SHAPE* aRectangle, OUTPUTFORMATTER& aFormatter ); static void saveRectangle( SCH_SHAPE* aRectangle, OUTPUTFORMATTER& aFormatter );
static void saveText( const SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter ); static void saveText( const SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter );
int m_versionMajor; int m_versionMajor;

View File

@ -22,9 +22,9 @@
#include <wx/log.h> #include <wx/log.h>
#include <base_units.h> #include <base_units.h>
#include <build_version.h> #include <build_version.h>
#include <lib_shape.h> #include <sch_shape.h>
#include <lib_symbol.h> #include <lib_symbol.h>
#include <lib_textbox.h> #include <sch_textbox.h>
#include <locale_io.h> #include <locale_io.h>
#include <macros.h> #include <macros.h>
#include <richio.h> #include <richio.h>
@ -333,9 +333,9 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFO
switch( aItem->Type() ) switch( aItem->Type() )
{ {
case LIB_SHAPE_T: case SCH_SHAPE_T:
{ {
LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( aItem ); SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
STROKE_PARAMS stroke = shape->GetStroke(); STROKE_PARAMS stroke = shape->GetStroke();
FILL_T fillMode = shape->GetFillMode(); FILL_T fillMode = shape->GetFillMode();
COLOR4D fillColor = shape->GetFillColor(); COLOR4D fillColor = shape->GetFillColor();
@ -378,8 +378,8 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFO
saveText( static_cast<SCH_TEXT*>( aItem ), aFormatter, aNestLevel ); saveText( static_cast<SCH_TEXT*>( aItem ), aFormatter, aNestLevel );
break; break;
case LIB_TEXTBOX_T: case SCH_TEXTBOX_T:
saveTextBox( static_cast<LIB_TEXTBOX*>( aItem ), aFormatter, aNestLevel ); saveTextBox( static_cast<SCH_TEXTBOX*>( aItem ), aFormatter, aNestLevel );
break; break;
default: 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 ) 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", aFormatter.Print( aNestLevel, "(text_box%s %s\n",
aTextBox->IsPrivate() ? " private" : "", aTextBox->IsPrivate() ? " private" : "",

View File

@ -27,7 +27,7 @@
class FILE_LINE_READER; class FILE_LINE_READER;
class LIB_PIN; class LIB_PIN;
class SCH_TEXT; class SCH_TEXT;
class LIB_TEXTBOX; class SCH_TEXTBOX;
class LINE_READER; class LINE_READER;
class SCH_IO_KICAD_SEXPR; class SCH_IO_KICAD_SEXPR;
@ -67,7 +67,7 @@ private:
static void saveField( SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter, int aNestLevel ); static void saveField( SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter, int aNestLevel );
static void savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); static void savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 );
static void saveText( SCH_TEXT* aText, 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 ); int aNestLevel = 0 );
static void saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter, static void saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter,

View File

@ -36,9 +36,7 @@
#include <base_units.h> #include <base_units.h>
#include <lib_id.h> #include <lib_id.h>
#include <lib_shape.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <lib_textbox.h>
#include <math/util.h> // KiROUND, Clamp #include <math/util.h> // KiROUND, Clamp
#include <font/font.h> #include <font/font.h>
#include <string_utils.h> #include <string_utils.h>
@ -552,15 +550,15 @@ SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem()
switch( CurTok() ) switch( CurTok() )
{ {
case T_arc: case T_arc:
return parseArc(); return parseSymbolArc();
break; break;
case T_bezier: case T_bezier:
return parseBezier(); return parseSymbolBezier();
break; break;
case T_circle: case T_circle:
return parseCircle(); return parseSymbolCircle();
break; break;
case T_pin: case T_pin:
@ -568,11 +566,11 @@ SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem()
break; break;
case T_polyline: case T_polyline:
return parsePolyLine(); return parseSymbolPolyLine();
break; break;
case T_rectangle: case T_rectangle:
return parseRectangle(); return parseSymbolRectangle();
break; break;
case T_text: case T_text:
@ -580,7 +578,7 @@ SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem()
break; break;
case T_text_box: case T_text_box:
return parseTextBox(); return parseSymbolTextBox();
break; break;
default: default:
@ -1083,7 +1081,7 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
} }
LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseArc() SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolArc()
{ {
wxCHECK_MSG( CurTok() == T_arc, nullptr, wxCHECK_MSG( CurTok() == T_arc, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as an arc." ) ); 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; EDA_ANGLE endAngle = ANGLE_90;
bool hasAngles = false; bool hasAngles = false;
std::unique_ptr<LIB_SHAPE> arc = std::make_unique<LIB_SHAPE>( nullptr, SHAPE_T::ARC ); std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>( SHAPE_T::ARC, LAYER_DEVICE );
arc->SetUnit( m_unit ); arc->SetUnit( m_unit );
arc->SetBodyStyle( m_bodyStyle ); 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, wxCHECK_MSG( CurTok() == T_bezier, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a bezier." ) ); 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 ); STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT );
FILL_PARAMS fill; FILL_PARAMS fill;
std::unique_ptr<LIB_SHAPE> bezier = std::make_unique<LIB_SHAPE>( nullptr, SHAPE_T::BEZIER ); std::unique_ptr<SCH_SHAPE> bezier = std::make_unique<SCH_SHAPE>( SHAPE_T::BEZIER, LAYER_DEVICE );
bezier->SetUnit( m_unit ); bezier->SetUnit( m_unit );
bezier->SetBodyStyle( m_bodyStyle ); 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, wxCHECK_MSG( CurTok() == T_circle, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a circle." ) ); 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 ); STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT );
FILL_PARAMS fill; FILL_PARAMS fill;
std::unique_ptr<LIB_SHAPE> circle = std::make_unique<LIB_SHAPE>( nullptr, SHAPE_T::CIRCLE ); std::unique_ptr<SCH_SHAPE> circle = std::make_unique<SCH_SHAPE>( SHAPE_T::CIRCLE, LAYER_DEVICE );
circle->SetUnit( m_unit ); circle->SetUnit( m_unit );
circle->SetBodyStyle( m_bodyStyle ); 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, wxCHECK_MSG( CurTok() == T_polyline, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a poly." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a poly." ) );
@ -1635,7 +1633,7 @@ LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parsePolyLine()
T token; T token;
STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT ); STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT );
FILL_PARAMS fill; FILL_PARAMS fill;
std::unique_ptr<LIB_SHAPE> poly = std::make_unique<LIB_SHAPE>( nullptr, SHAPE_T::POLY ); std::unique_ptr<SCH_SHAPE> poly = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY, LAYER_DEVICE );
poly->SetUnit( m_unit ); poly->SetUnit( m_unit );
poly->SetBodyStyle( m_bodyStyle ); 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, wxCHECK_MSG( CurTok() == T_rectangle, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a rectangle." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a rectangle." ) );
@ -1703,7 +1701,7 @@ LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseRectangle()
T token; T token;
STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT ); STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT );
FILL_PARAMS fill; FILL_PARAMS fill;
std::unique_ptr<LIB_SHAPE> rectangle = std::make_unique<LIB_SHAPE>( nullptr, SHAPE_T::RECTANGLE ); auto rectangle = std::make_unique<SCH_SHAPE>( SHAPE_T::RECTANGLE, LAYER_DEVICE );
rectangle->SetUnit( m_unit ); rectangle->SetUnit( m_unit );
rectangle->SetBodyStyle( m_bodyStyle ); 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, wxCHECK_MSG( CurTok() == T_text_box, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a text box." ) ); 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 foundSize = false;
bool foundMargins = false; bool foundMargins = false;
std::unique_ptr<LIB_TEXTBOX> textBox = std::make_unique<LIB_TEXTBOX>( nullptr ); std::unique_ptr<SCH_TEXTBOX> textBox = std::make_unique<SCH_TEXTBOX>( LAYER_DEVICE );
textBox->SetUnit( m_unit ); textBox->SetUnit( m_unit );
textBox->SetBodyStyle( m_bodyStyle ); textBox->SetBodyStyle( m_bodyStyle );
@ -3618,9 +3616,8 @@ SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSchPolyLine()
T token; T token;
STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT ); STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT );
FILL_PARAMS fill; FILL_PARAMS fill;
int layer = LAYER_NOTES;
std::unique_ptr<SCH_SHAPE> polyline = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY, layer ); std::unique_ptr<SCH_SHAPE> polyline = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY, LAYER_NOTES );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {

View File

@ -37,9 +37,7 @@
#include <default_values.h> // For some default values #include <default_values.h> // For some default values
class LIB_SHAPE;
class LIB_PIN; class LIB_PIN;
class LIB_TEXTBOX;
class PAGE_INFO; class PAGE_INFO;
class SCH_BITMAP; class SCH_BITMAP;
class SCH_BUS_WIRE_ENTRY; class SCH_BUS_WIRE_ENTRY;
@ -195,14 +193,14 @@ private:
SCH_FIELD* parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol ); SCH_FIELD* parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol );
LIB_SHAPE* parseArc(); SCH_SHAPE* parseSymbolArc();
LIB_SHAPE* parseBezier(); SCH_SHAPE* parseSymbolBezier();
LIB_SHAPE* parseCircle(); SCH_SHAPE* parseSymbolCircle();
LIB_PIN* parsePin(); LIB_PIN* parsePin();
LIB_SHAPE* parsePolyLine(); SCH_SHAPE* parseSymbolPolyLine();
LIB_SHAPE* parseRectangle(); SCH_SHAPE* parseSymbolRectangle();
SCH_TEXT* parseSymbolText(); SCH_TEXT* parseSymbolText();
LIB_TEXTBOX* parseTextBox(); SCH_TEXTBOX* parseSymbolTextBox();
void parsePAGE_INFO( PAGE_INFO& aPageInfo ); void parsePAGE_INFO( PAGE_INFO& aPageInfo );
void parseTITLE_BLOCK( TITLE_BLOCK& aTitleBlock ); void parseTITLE_BLOCK( TITLE_BLOCK& aTitleBlock );

View File

@ -26,12 +26,8 @@
#include <sch_io/ltspice/sch_io_ltspice_parser.h> #include <sch_io/ltspice/sch_io_ltspice_parser.h>
#include <sch_io/ltspice/ltspice_schematic.h> #include <sch_io/ltspice/ltspice_schematic.h>
#include <sch_io/sch_io_mgr.h>
#include <schematic.h> #include <schematic.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_line.h> #include <sch_line.h>
#include <lib_shape.h>
#include <sch_label.h> #include <sch_label.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <sch_shape.h> #include <sch_shape.h>
@ -109,7 +105,7 @@ void SCH_IO_LTSPICE_PARSER::readIncludes( std::vector<LTSPICE_SCHEMATIC::LT_ASC>
void SCH_IO_LTSPICE_PARSER::CreateLines( LIB_SYMBOL* aSymbol, void SCH_IO_LTSPICE_PARSER::CreateLines( LIB_SYMBOL* aSymbol,
LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol,
int aIndex, LIB_SHAPE* shape ) int aIndex, SCH_SHAPE* shape )
{ {
LTSPICE_SCHEMATIC::LINE& lt_line = aLTSymbol.Lines[aIndex]; 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++ ) 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 ); CreateLines( aLibSymbol, aLtSymbol, j, line );
aLibSymbol->AddDrawItem( 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++ ) 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 ); CreateCircle( aLtSymbol, j, circle );
aLibSymbol->AddDrawItem( 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++ ) 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 ); CreateArc( aLtSymbol, j, arc );
aLibSymbol->AddDrawItem( 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++ ) 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 ); CreateRect( aLtSymbol, j, rectangle );
aLibSymbol->AddDrawItem( rectangle ); aLibSymbol->AddDrawItem( rectangle );
@ -822,7 +818,7 @@ SCH_SYMBOL* SCH_IO_LTSPICE_PARSER::CreatePowerSymbol( const VECTOR2I& aOffset,
std::vector<LTSPICE_SCHEMATIC::WIRE>& aWires ) std::vector<LTSPICE_SCHEMATIC::WIRE>& aWires )
{ {
LIB_SYMBOL* lib_symbol = new LIB_SYMBOL( wxS( "GND" ) ); 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 } ) );
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, 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]; 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, 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]; 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, 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]; LTSPICE_SCHEMATIC::CIRCLE& lt_circle = aLTSymbol.Circles[aIndex];

View File

@ -30,13 +30,11 @@
#include <sch_io/sch_io_mgr.h> #include <sch_io/sch_io_mgr.h>
#include <pin_type.h> #include <pin_type.h>
#include <layer_ids.h> #include <layer_ids.h>
#include <wx/filename.h>
#include <plotters/plotter.h> #include <plotters/plotter.h>
#include <sch_io/ltspice/ltspice_schematic.h> #include <sch_io/ltspice/ltspice_schematic.h>
class EDA_TEXT; class EDA_TEXT;
class LIB_SHAPE;
class LIB_PIN; class LIB_PIN;
class SCH_LABEL_BASE; class SCH_LABEL_BASE;
class SCH_SYMBOL; class SCH_SYMBOL;
@ -109,7 +107,7 @@ public:
* @param aIndex index. * @param aIndex index.
*/ */
void CreateLines( LIB_SYMBOL* aSymbol, LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, 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 * Method for plotting Schematic Lines from Asy files
@ -244,7 +242,7 @@ public:
/** /**
* Create a symbol rect. * 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. * Create a schematic rect.
@ -259,7 +257,7 @@ public:
/** /**
* Create a symbol arc. * 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. * Create a schematic arc.
@ -269,7 +267,7 @@ public:
/** /**
* Create a symbol circle. * 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. * Create a schematic circle.

View File

@ -25,18 +25,14 @@
*/ */
#include <sch_item.h>
#include <trigo.h> #include <trigo.h>
#include <symbol_library.h>
#include <connection_graph.h> #include <connection_graph.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <callback_gal.h> #include <callback_gal.h>
#include <geometry/shape_segment.h> #include <geometry/shape_segment.h>
#include <geometry/shape_rect.h> #include <geometry/shape_rect.h>
#include <gr_text.h> #include <gr_text.h>
#include <lib_shape.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <lib_textbox.h>
#include <math/util.h> #include <math/util.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <sch_bitmap.h> #include <sch_bitmap.h>
@ -46,6 +42,7 @@
#include <sch_field.h> #include <sch_field.h>
#include <sch_junction.h> #include <sch_junction.h>
#include <sch_line.h> #include <sch_line.h>
#include <sch_shape.h>
#include <sch_marker.h> #include <sch_marker.h>
#include <sch_no_connect.h> #include <sch_no_connect.h>
#include <sch_sheet.h> #include <sch_sheet.h>
@ -60,10 +57,8 @@
#include <default_values.h> #include <default_values.h>
#include <advanced_config.h> #include <advanced_config.h>
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <string_utils.h>
#include <stroke_params.h> #include <stroke_params.h>
#include "sch_painter.h" #include "sch_painter.h"
#include "sch_shape.h"
#include "common.h" #include "common.h"
@ -83,7 +78,7 @@ std::vector<KICAD_T> SCH_PAINTER::g_ScaledSelectionTypes = {
SCH_BUS_WIRE_ENTRY_T, SCH_BUS_WIRE_ENTRY_T,
SCH_BUS_BUS_ENTRY_T, SCH_BUS_BUS_ENTRY_T,
SCH_LINE_T, SCH_LINE_T,
LIB_SHAPE_T, SCH_SHAPE_T, SCH_SHAPE_T,
SCH_BITMAP_T, SCH_BITMAP_T,
SCH_TEXT_T, SCH_TEXT_T,
SCH_GLOBAL_LABEL_T, SCH_GLOBAL_LABEL_T,
@ -118,16 +113,15 @@ static LIB_SYMBOL* dummy()
{ {
symbol = new LIB_SYMBOL( wxEmptyString ); 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->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
square->SetEnd( 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 ); SCH_TEXT* text = new SCH_TEXT( { 0, 0 }, wxT( "??" ), LAYER_DEVICE );
text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) ); text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) );
symbol->AddDrawItem( square );
symbol->AddDrawItem( text ); symbol->AddDrawItem( text );
} }
@ -140,6 +134,7 @@ SCH_PAINTER::SCH_PAINTER( GAL* aGal ) :
m_schematic( nullptr ) m_schematic( nullptr )
{ } { }
bool SCH_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) bool SCH_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
{ {
const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem ); const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
@ -183,16 +178,10 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed )
case LIB_SYMBOL_T: case LIB_SYMBOL_T:
draw( static_cast<const LIB_SYMBOL*>( aItem ), aLayer ); draw( static_cast<const LIB_SYMBOL*>( aItem ), aLayer );
break; break;
case LIB_SHAPE_T:
draw( static_cast<const LIB_SHAPE*>( aItem ), aLayer, aDimmed );
break;
case LIB_PIN_T: case LIB_PIN_T:
drawBoundingBox = false; drawBoundingBox = false;
draw( static_cast<const LIB_PIN*>( aItem ), aLayer, aDimmed ); draw( static_cast<const LIB_PIN*>( aItem ), aLayer, aDimmed );
break; break;
case LIB_TEXTBOX_T:
draw( static_cast<const LIB_TEXTBOX*>( aItem ), aLayer, aDimmed );
break;
case SCH_SYMBOL_T: case SCH_SYMBOL_T:
draw( static_cast<const SCH_SYMBOL*>( aItem ), aLayer ); draw( static_cast<const SCH_SYMBOL*>( aItem ), aLayer );
break; break;
@ -203,16 +192,16 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed )
draw( static_cast<const SCH_LINE*>( aItem ), aLayer ); draw( static_cast<const SCH_LINE*>( aItem ), aLayer );
break; break;
case SCH_SHAPE_T: case SCH_SHAPE_T:
draw( static_cast<const SCH_SHAPE*>( aItem ), aLayer ); draw( static_cast<const SCH_SHAPE*>( aItem ), aLayer, aDimmed );
break; break;
case SCH_TEXT_T: case SCH_TEXT_T:
draw( static_cast<const SCH_TEXT*>( aItem ), aLayer, aDimmed ); draw( static_cast<const SCH_TEXT*>( aItem ), aLayer, aDimmed );
break; break;
case SCH_TEXTBOX_T: case SCH_TEXTBOX_T:
draw( static_cast<const SCH_TEXTBOX*>( aItem ), aLayer ); draw( static_cast<const SCH_TEXTBOX*>( aItem ), aLayer, aDimmed );
break; break;
case SCH_TABLE_T: case SCH_TABLE_T:
draw( static_cast<const SCH_TABLE*>( aItem ), aLayer ); draw( static_cast<const SCH_TABLE*>( aItem ), aLayer, aDimmed );
break; break;
case SCH_LABEL_T: case SCH_LABEL_T:
draw( static_cast<const SCH_LABEL*>( aItem ), aLayer ); draw( static_cast<const SCH_LABEL*>( aItem ), aLayer );
@ -358,7 +347,7 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
{ {
const SCH_SHAPE* shape = static_cast<const SCH_SHAPE*>( aItem ); const SCH_SHAPE* shape = static_cast<const SCH_SHAPE*>( aItem );
if( aLayer == LAYER_NOTES_BACKGROUND ) if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
color = shape->GetFillColor(); color = shape->GetFillColor();
else else
color = shape->GetStroke().GetColor(); color = shape->GetStroke().GetColor();
@ -368,15 +357,6 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
if( color == COLOR4D::UNSPECIFIED ) if( color == COLOR4D::UNSPECIFIED )
color = m_schSettings.GetLayerColor( LAYER_NOTES ); color = m_schSettings.GetLayerColor( LAYER_NOTES );
} }
else if( aItem->Type() == LIB_SHAPE_T )
{
const LIB_SHAPE* shape = static_cast<const LIB_SHAPE*>( 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 } ) ) else if( aItem->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
{ {
color = static_cast<const SCH_LABEL_BASE*>( aItem )->GetLabelColor(); color = static_cast<const SCH_LABEL_BASE*>( aItem )->GetLabelColor();
@ -389,15 +369,6 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
{ {
const SCH_TEXTBOX* textBox = dynamic_cast<const SCH_TEXTBOX*>( aItem ); const SCH_TEXTBOX* textBox = dynamic_cast<const SCH_TEXTBOX*>( 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<const LIB_TEXTBOX*>( aItem );
if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
color = textBox->GetFillColor(); color = textBox->GetFillColor();
else else
@ -511,10 +482,6 @@ float SCH_PAINTER::getTextThickness( const EDA_ITEM* aItem ) const
pen = static_cast<const SCH_TEXTBOX*>( aItem )->GetEffectiveTextPenWidth( pen ); pen = static_cast<const SCH_TEXTBOX*>( aItem )->GetEffectiveTextPenWidth( pen );
break; break;
case LIB_TEXTBOX_T:
pen = std::max( pen, static_cast<const LIB_TEXTBOX*>( aItem )->GetEffectiveTextPenWidth() );
break;
default: default:
UNIMPLEMENTED_FOR( aItem->GetClass() ); UNIMPLEMENTED_FOR( aItem->GetClass() );
} }
@ -533,10 +500,10 @@ int SCH_PAINTER::getOperatingPointTextSize() const
} }
static VECTOR2D mapCoords( const VECTOR2D& aCoord ) //
{ // TODO: nuke symbol editor's upside-down coordinate system
return VECTOR2D( aCoord.x, -aCoord.y ); //
} #define MAP_COORDS( aCoord ) VECTOR2D( aCoord.x, invertY ? -aCoord.y : aCoord.y )
static bool isFieldsLayer( int aLayer ) 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, 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; 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.Inflate( 0, aAttrs.m_StrokeWidth * 2 );
box.Normalize(); // Make h and v sizes always >= 0 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(); box.RevertYAxis();
m_gal->SetIsFill( true ); m_gal->SetIsFill( true );
m_gal->SetIsStroke( false ); 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<VECTOR2D> 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<SHAPE*> 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<SHAPE*> 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 ) int SCH_PAINTER::internalPinDecoSize( const LIB_PIN &aPin )
{ {
if( m_schSettings.m_PinSymbolSize > 0 ) 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 drawingDangling = aLayer == LAYER_DANGLING;
bool drawingOP = aLayer == LAYER_OP_CURRENTS; bool drawingOP = aLayer == LAYER_OP_CURRENTS;
bool isDangling = m_schSettings.m_IsSymbolEditor || aPin->HasFlag( IS_DANGLING ); bool isDangling = m_schSettings.m_IsSymbolEditor || aPin->HasFlag( IS_DANGLING );
bool invertY = true;
if( drawingShadows && !( aPin->IsBrightened() || aPin->IsSelected() ) ) if( drawingShadows && !( aPin->IsBrightened() || aPin->IsSelected() ) )
return; return;
VECTOR2I pos = mapCoords( aPin->GetPosition() ); VECTOR2I pos = MAP_COORDS( aPin->GetPosition() );
COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows, aDimmed ); COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows, aDimmed );
if( !aPin->IsVisible() ) if( !aPin->IsVisible() )
@ -1520,7 +1220,7 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
} }
else if( drawingShadows ) else if( drawingShadows )
{ {
boxText( text[i], aPos, attrs, aPin->GetFontMetrics() ); boxText( text[i], aPos, attrs, aPin->GetFontMetrics(), invertY );
} }
else if( nonCached( aPin ) && renderTextAsBitmap ) 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; bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
if( m_schSettings.IsPrinting() && drawingShadows ) if( m_schSettings.IsPrinting() && drawingShadows )
@ -1807,6 +1513,7 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer )
LINE_STYLE lineStyle = aShape->GetEffectiveLineStyle(); LINE_STYLE lineStyle = aShape->GetEffectiveLineStyle();
COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows ); COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows );
bool invertY = aShape->GetLayer() == LAYER_DEVICE;
if( drawingShadows && !( aShape->IsBrightened() || aShape->IsSelected() ) ) if( drawingShadows && !( aShape->IsBrightened() || aShape->IsSelected() ) )
return; return;
@ -1818,38 +1525,51 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer )
{ {
case SHAPE_T::ARC: case SHAPE_T::ARC:
{ {
EDA_ANGLE startAngle; VECTOR2D start = MAP_COORDS( shape->GetStart() );
EDA_ANGLE endAngle; VECTOR2D mid = MAP_COORDS( shape->GetArcMid() );
aShape->CalcArcAngles( startAngle, endAngle ); VECTOR2D end = MAP_COORDS( shape->GetEnd() );
VECTOR2D center = CalcArcCenter( start, mid, end );
m_gal->DrawArc( aShape->GetCenter(), aShape->GetRadius(), startAngle, EDA_ANGLE startAngle( start - center );
endAngle - startAngle ); 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; break;
} }
case SHAPE_T::CIRCLE: case SHAPE_T::CIRCLE:
m_gal->DrawCircle( shape->GetPosition(), shape->GetRadius() ); m_gal->DrawCircle( MAP_COORDS( shape->GetPosition() ), shape->GetRadius() );
break; break;
case SHAPE_T::RECTANGLE: case SHAPE_T::RECTANGLE:
m_gal->DrawRectangle( shape->GetPosition(), shape->GetEnd() ); m_gal->DrawRectangle( MAP_COORDS( shape->GetPosition() ),
MAP_COORDS( shape->GetEnd() ) );
break; break;
case SHAPE_T::POLY: case SHAPE_T::POLY:
{ {
std::deque<VECTOR2D> pts; const SHAPE_LINE_CHAIN poly = shape->GetPolyShape().Outline( 0 );
std::deque<VECTOR2D> mappedPts;
for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() ) for( const VECTOR2I& pt : poly.CPoints() )
pts.push_back( pt ); mappedPts.push_back( MAP_COORDS( pt ) );
m_gal->DrawPolygon( pts ); m_gal->DrawPolygon( mappedPts );
break; break;
} }
case SHAPE_T::BEZIER: case SHAPE_T::BEZIER:
{ {
m_gal->DrawCurve( shape->GetStart(), shape->GetBezierC1(), shape->GetBezierC2(), m_gal->DrawCurve( MAP_COORDS( shape->GetStart() ),
shape->GetEnd() ); MAP_COORDS( shape->GetBezierC1() ),
MAP_COORDS( shape->GetBezierC2() ),
MAP_COORDS( shape->GetEnd() ) );
break; break;
} }
@ -1882,7 +1602,7 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer )
drawShape( aShape ); 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 // Do not fill the shape in B&W print mode, to avoid to visible items inside the shape
if( aShape->IsFilled() && !m_schSettings.PrintBlackAndWhiteReq() ) if( aShape->IsFilled() && !m_schSettings.PrintBlackAndWhiteReq() )
@ -1894,7 +1614,7 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer )
drawShape( aShape ); drawShape( aShape );
} }
} }
else if( aLayer == LAYER_NOTES ) else if( aLayer == LAYER_DEVICE || aLayer == LAYER_NOTES || aLayer == LAYER_PRIVATE_NOTES )
{ {
float lineWidth = getLineWidth( aShape, drawingShadows ); float lineWidth = getLineWidth( aShape, drawingShadows );
@ -1916,13 +1636,13 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer )
for( SHAPE* shape : shapes ) for( SHAPE* shape : shapes )
{ {
STROKE_PARAMS::Stroke( shape, lineStyle, KiROUND( lineWidth ), &m_schSettings, 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 // DrawLine has problem with 0 length lines so enforce minimum
if( a == b ) if( a == b )
m_gal->DrawLine( a+1, b ); m_gal->DrawLine( MAP_COORDS( (a+1) ), MAP_COORDS( b ) );
else 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 ); VECTOR2I text_offset = aText->GetSchematicTextOffset( &m_schSettings );
TEXT_ATTRIBUTES attrs = aText->GetAttributes(); TEXT_ATTRIBUTES attrs = aText->GetAttributes();
KIFONT::FONT* font = getFont( aText ); KIFONT::FONT* font = getFont( aText );
bool invertY = aText->GetLayer() == LAYER_DEVICE;
attrs.m_Angle = aText->GetDrawRotation(); attrs.m_Angle = aText->GetDrawRotation();
attrs.m_StrokeWidth = KiROUND( getTextThickness( aText ) ); 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->SetIsStroke( false );
m_gal->SetIsFill( true ); 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 ) 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 ) if( aTextBox->Type() == SCH_TABLECELL_T )
{ {
@ -2151,14 +1872,22 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer )
return; return;
} }
if( !isUnitAndConversionShown( aTextBox ) )
return;
if( aTextBox->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
return;
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
if( m_schSettings.IsPrinting() && drawingShadows ) if( m_schSettings.IsPrinting() && drawingShadows )
return; 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 ); float borderWidth = getLineWidth( aTextBox, drawingShadows );
KIFONT::FONT* font = getFont( aTextBox ); KIFONT::FONT* font = getFont( aTextBox );
bool invertY = aTextBox->GetLayer() == LAYER_DEVICE;
auto drawText = auto drawText =
[&]() [&]()
@ -2204,9 +1933,10 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer )
m_gal->SetIsStroke( false ); m_gal->SetIsStroke( false );
m_gal->SetLineWidth( borderWidth ); 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 // Do not fill the shape in B&W print mode, to avoid to visible items
// inside the shape // inside the shape
@ -2216,10 +1946,11 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer )
m_gal->SetIsStroke( false ); m_gal->SetIsStroke( false );
m_gal->SetLineWidth( borderWidth ); 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(); drawText();
@ -2227,6 +1958,7 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer )
{ {
COLOR4D borderColor = aTextBox->GetStroke().GetColor(); COLOR4D borderColor = aTextBox->GetStroke().GetColor();
LINE_STYLE borderStyle = aTextBox->GetEffectiveLineStyle(); LINE_STYLE borderStyle = aTextBox->GetEffectiveLineStyle();
double transparency = aTextBox->GetForcedTransparency();
if( m_schSettings.m_OverrideItemColors || aTextBox->IsBrightened() if( m_schSettings.m_OverrideItemColors || aTextBox->IsBrightened()
|| borderColor == COLOR4D::UNSPECIFIED ) || borderColor == COLOR4D::UNSPECIFIED )
@ -2234,6 +1966,15 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer )
borderColor = m_schSettings.GetLayerColor( 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->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetStrokeColor( borderColor ); 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 ) 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 else
{ {
@ -2251,13 +1993,13 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer )
{ {
STROKE_PARAMS::Stroke( shape, borderStyle, KiROUND( borderWidth ), STROKE_PARAMS::Stroke( shape, borderStyle, KiROUND( borderWidth ),
&m_schSettings, &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 // DrawLine has problem with 0 length lines so enforce minimum
if( a == b ) if( a == b )
m_gal->DrawLine( a+1, b ); m_gal->DrawLine( MAP_COORDS( (a+1) ), MAP_COORDS( b ) );
else 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() ) for( SCH_TABLECELL* cell : aTable->GetCells() )
draw( cell, aLayer ); draw( cell, aLayer, aDimmed );
if( aLayer == LAYER_SELECTION_SHADOWS ) if( aLayer == LAYER_SELECTION_SHADOWS )
return; return;
@ -2303,7 +2045,7 @@ void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer )
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetStrokeColor( color ); m_gal->SetStrokeColor( color );
m_gal->SetLineWidth( lineWidth ); m_gal->SetLineWidth( (float) lineWidth );
}; };
auto strokeShape = 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). // Use dummy symbol if the actual couldn't be found (or couldn't be locked).
LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ? aSymbol->GetLibSymbolRef().get() LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ? aSymbol->GetLibSymbolRef().get()
: dummy(); : dummy();
bool invertY = true;
std::vector<LIB_PIN*> originalPins; std::vector<LIB_PIN*> originalPins;
originalSymbol->GetPins( originalPins, unit, bodyStyle ); 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() ) for( SCH_ITEM& tempItem : tempSymbol.GetDrawItems() )
{ {
tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED, tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
tempItem.Move( mapCoords( aSymbol->GetPosition() ) ); tempItem.Move( MAP_COORDS( aSymbol->GetPosition() ) );
if( tempItem.Type() == SCH_TEXT_T ) if( tempItem.Type() == SCH_TEXT_T )
{ {
@ -2514,9 +2258,9 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer )
if( textItem->HasTextVars() ) if( textItem->HasTextVars() )
textItem->SetText( expandLibItemTextVars( textItem->GetText(), aSymbol ) ); 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<LIB_TEXTBOX*>( &tempItem ); SCH_TEXTBOX* textboxItem = static_cast<SCH_TEXTBOX*>( &tempItem );
if( textboxItem->HasTextVars() ) if( textboxItem->HasTextVars() )
textboxItem->SetText( expandLibItemTextVars( textboxItem->GetText(), aSymbol ) ); 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() ) if( drawingShadows && getFont( aField )->IsOutline() )
{ {
BOX2I shadow_box = bbox; BOX2I shadow_box = bbox;
bool invertY = true;
shadow_box.Inflate( KiROUND( getTextThickness( aField ) * 2 ) ); shadow_box.Inflate( KiROUND( getTextThickness( aField ) * 2 ) );
shadow_box.RevertYAxis(); shadow_box.RevertYAxis();
m_gal->SetIsStroke( false ); m_gal->SetIsStroke( false );
m_gal->SetIsFill( true ); 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 else
{ {

View File

@ -34,10 +34,7 @@
class LIB_PIN; class LIB_PIN;
class LIB_SHAPE;
class LIB_SYMBOL; class LIB_SYMBOL;
class LIB_TEXT;
class LIB_TEXTBOX;
class SCH_SYMBOL; class SCH_SYMBOL;
class SCH_FIELD; class SCH_FIELD;
class SCH_JUNCTION; class SCH_JUNCTION;
@ -84,18 +81,15 @@ private:
void drawItemBoundingBox( const EDA_ITEM* aItem ); void drawItemBoundingBox( const EDA_ITEM* aItem );
void draw( const EDA_ITEM*, int, bool aDimmed ); void draw( const EDA_ITEM*, int, bool aDimmed );
void draw( const LIB_PIN* aPin, int aLayer, 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, void draw( const LIB_SYMBOL* aSymbol, int, bool aDrawFields = true, int aUnit = 0,
int aBodyStyle = 0, bool aDimmed = false ); 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_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_JUNCTION* aJct, int aLayer );
void draw( const SCH_FIELD* aField, int aLayer, bool aDimmed ); 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, bool aDimmed );
void draw( const SCH_TEXTBOX* aTextBox, int aLayer );
void draw( const SCH_TEXT* aText, 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_LABEL* aText, int aLayer );
void draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer ); void draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer );
void draw( const SCH_HIERLABEL* aLabel, int aLayer ); void draw( const SCH_HIERLABEL* aLabel, int aLayer );
@ -139,7 +133,8 @@ private:
void knockoutText( const wxString& aText, const VECTOR2D& aPosition, void knockoutText( const wxString& aText, const VECTOR2D& aPosition,
const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics ); const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics );
void boxText( const wxString& aText, const VECTOR2D& aPosition, 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 ); wxString expandLibItemTextVars( const wxString& aSourceText, const SCH_SYMBOL* aSymbolContext );

View File

@ -32,14 +32,14 @@
#include <general.h> #include <general.h>
#include <schematic.h> #include <schematic.h>
#include <sch_shape.h> #include <sch_shape.h>
#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 ), SCH_ITEM( nullptr, aType ),
EDA_SHAPE( aShape, aLineWidth, aFillType ) EDA_SHAPE( aShape, aLineWidth, aFillType )
{ {
SetLayer( LAYER_NOTES ); SetLayer( aLayer );
} }
@ -111,90 +111,158 @@ 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, void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
{ {
int pen_size = GetEffectivePenWidth( getRenderSettings( aPlotter ) ); if( IsPrivate() )
return;
static std::vector<VECTOR2I> cornerList; SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
int pen_size = GetEffectivePenWidth( renderSettings );
static std::vector<VECTOR2I> ptList;
if( GetShape() == SHAPE_T::POLY ) if( GetShape() == SHAPE_T::POLY )
{ {
cornerList.clear(); ptList.clear();
for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() ) 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( aBackground )
{ {
if( !aPlotter->GetColorMode() ) if( !aPlotter->GetColorMode() )
return; return;
if( IsFilled() ) switch( m_fill )
{ {
if( GetFillColor() != COLOR4D::UNSPECIFIED ) case FILL_T::FILLED_SHAPE:
aPlotter->SetColor( GetFillColor() ); return;
else
aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_NOTES ) );
switch( GetShape() ) case FILL_T::FILLED_WITH_COLOR:
{ color = GetFillColor();
case SHAPE_T::ARC:
aPlotter->Arc( GetStart(), GetArcMid(), GetEnd(), m_fill, 0 );
break; break;
case SHAPE_T::CIRCLE: case FILL_T::FILLED_WITH_BG_BODYCOLOR:
aPlotter->Circle( getCenter(), GetRadius() * 2, m_fill, 0 ); color = renderSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
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; break;
default: default:
UNIMPLEMENTED_FOR( SHAPE_T_asString() ); return;
}
} }
pen_size = 0;
lineStyle = LINE_STYLE::SOLID;
} }
else /* if( aForeground ) */ else /* if( aForeground ) */
{ {
if( aPlotter->GetColorMode() && GetStroke().GetColor() != COLOR4D::UNSPECIFIED ) if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
aPlotter->SetColor( GetStroke().GetColor() ); color = renderSettings->GetLayerColor( m_layer );
else
aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_NOTES ) );
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->SetCurrentLineWidth( pen_size );
aPlotter->SetDash( pen_size, GetEffectiveLineStyle() ); 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() ) switch( GetShape() )
{ {
case SHAPE_T::ARC: case SHAPE_T::ARC:
aPlotter->Arc( GetStart(), GetArcMid(), GetEnd(), FILL_T::NO_FILL, pen_size ); mid = GetArcMid();
if( m_layer == LAYER_DEVICE )
mid = renderSettings->TransformCoordinate( mid ) + aOffset;
aPlotter->Arc( start, mid, end, fill, pen_size );
break; break;
case SHAPE_T::CIRCLE: case SHAPE_T::CIRCLE:
aPlotter->Circle( getCenter(), GetRadius() * 2, FILL_T::NO_FILL, pen_size ); center = getCenter();
if( m_layer == LAYER_DEVICE )
center = renderSettings->TransformCoordinate( center ) + aOffset;
aPlotter->Circle( center, GetRadius() * 2, fill, pen_size );
break; break;
case SHAPE_T::RECTANGLE: case SHAPE_T::RECTANGLE:
aPlotter->Rect( GetStart(), GetEnd(), FILL_T::NO_FILL, pen_size ); aPlotter->Rect( start, end, fill, pen_size );
break; break;
case SHAPE_T::POLY: case SHAPE_T::POLY:
aPlotter->PlotPoly( cornerList, FILL_T::NO_FILL, pen_size );
break;
case SHAPE_T::BEZIER: case SHAPE_T::BEZIER:
aPlotter->PlotPoly( m_bezierPoints, FILL_T::NO_FILL, pen_size ); aPlotter->PlotPoly( ptList, fill, pen_size );
break; break;
default: default:
@ -203,16 +271,15 @@ void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS&
aPlotter->SetDash( pen_size, LINE_STYLE::SOLID ); aPlotter->SetDash( pen_size, LINE_STYLE::SOLID );
} }
}
int SCH_SHAPE::GetPenWidth() const int SCH_SHAPE::GetEffectiveWidth() const
{ {
if( m_stroke.GetWidth() > 0 ) if( GetPenWidth() > 0 )
return m_stroke.GetWidth(); return GetPenWidth();
// Historically 0 meant "default width" and negative numbers meant "don't stroke". // Historically 0 meant "default width" and negative numbers meant "don't stroke".
if( GetWidth() < 0 ) if( GetPenWidth() < 0 )
return 0; return 0;
SCHEMATIC* schematic = Schematic(); 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, void SCH_SHAPE::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
const VECTOR2I& aOffset, bool aDimmed ) const VECTOR2I& aOffset, bool aDimmed )
{ {
if( IsPrivate() )
return;
wxDC* DC = aSettings->GetPrintDC(); wxDC* DC = aSettings->GetPrintDC();
COLOR4D color; COLOR4D color;
unsigned ptCount = 0; static std::vector<VECTOR2I> ptList;
VECTOR2I* buffer = nullptr;
if( GetShape() == SHAPE_T::POLY ) if( GetShape() == SHAPE_T::POLY )
{ {
SHAPE_LINE_CHAIN poly = m_poly.Outline( 0 ); ptList.clear();
ptCount = poly.GetPointCount(); for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
buffer = new VECTOR2I[ptCount]; {
if( m_layer == LAYER_DEVICE )
for( unsigned ii = 0; ii < ptCount; ++ii ) ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
buffer[ii] = poly.CPoint( ii ); else
ptList.push_back( pt );
}
} }
else if( GetShape() == SHAPE_T::BEZIER ) else if( GetShape() == SHAPE_T::BEZIER )
{ {
ptCount = m_bezierPoints.size(); ptList.clear();
buffer = new VECTOR2I[ptCount];
for( size_t ii = 0; ii < ptCount; ++ii ) for( const VECTOR2I& pt : m_bezierPoints )
buffer[ii] = m_bezierPoints[ii]; {
if( m_layer == LAYER_DEVICE )
ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
else
ptList.push_back( pt );
}
} }
if( GetFillMode() == FILL_T::FILLED_WITH_COLOR ) if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
@ -274,57 +360,96 @@ void SCH_SHAPE::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit
break; break;
case SHAPE_T::POLY: case SHAPE_T::POLY:
GRPoly( DC, ptCount, buffer, true, 0, color, color ); GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, color, color );
break; break;
case SHAPE_T::BEZIER: case SHAPE_T::BEZIER:
GRPoly( DC, ptCount, buffer, true, 0, color, color ); GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, color, color );
break; break;
default: default:
UNIMPLEMENTED_FOR( SHAPE_T_asString() ); UNIMPLEMENTED_FOR( SHAPE_T_asString() );
} }
} }
delete[] buffer;
} }
void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
{ {
if( IsPrivate() )
return;
int penWidth = GetEffectivePenWidth( aSettings ); int penWidth = GetEffectivePenWidth( aSettings );
wxDC* DC = aSettings->GetPrintDC(); wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = GetStroke().GetColor(); COLOR4D color = GetStroke().GetColor();
COLOR4D bg = aSettings->GetBackgroundColor();
if( color == COLOR4D::UNSPECIFIED ) if( color == COLOR4D::UNSPECIFIED )
color = aSettings->GetLayerColor( LAYER_NOTES ); color = aSettings->GetLayerColor( LAYER_NOTES );
COLOR4D bg = aSettings->GetBackgroundColor();
if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() ) if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
bg = COLOR4D::WHITE; bg = COLOR4D::WHITE;
unsigned ptCount = 0; if( aDimmed )
VECTOR2I* buffer = nullptr; {
color.Desaturate( );
color = color.Mix( bg, 0.5f );
}
static std::vector<VECTOR2I> ptList;
if( GetShape() == SHAPE_T::POLY ) if( GetShape() == SHAPE_T::POLY )
{ {
SHAPE_LINE_CHAIN poly = m_poly.Outline( 0 ); ptList.clear();
ptCount = poly.GetPointCount(); for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
buffer = new VECTOR2I[ptCount]; {
if( m_layer == LAYER_DEVICE )
for( unsigned ii = 0; ii < ptCount; ++ii ) ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
buffer[ii] = poly.CPoint( ii ); else
ptList.push_back( pt );
}
} }
else if( GetShape() == SHAPE_T::BEZIER ) else if( GetShape() == SHAPE_T::BEZIER )
{ {
ptCount = m_bezierPoints.size(); ptList.clear();
buffer = new VECTOR2I[ptCount];
for( size_t ii = 0; ii < ptCount; ++ii ) for( const VECTOR2I& pt : m_bezierPoints )
buffer[ii] = m_bezierPoints[ii]; {
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; COLOR4D fillColor = COLOR4D::UNSPECIFIED;
@ -333,29 +458,37 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod
fillColor = color; fillColor = color;
else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR ) else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
fillColor = GetFillColor(); fillColor = GetFillColor();
else if( GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
fillColor = aSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
if( fillColor != COLOR4D::UNSPECIFIED && !aForceNoFill ) if( fillColor != COLOR4D::UNSPECIFIED && !aForceNoFill )
{ {
if( aDimmed )
{
fillColor.Desaturate( );
fillColor = fillColor.Mix( bg, 0.5f );
}
switch( GetShape() ) switch( GetShape() )
{ {
case SHAPE_T::ARC: case SHAPE_T::ARC:
GRFilledArc( DC, GetEnd(), GetStart(), getCenter(), 0, fillColor, fillColor ); GRFilledArc( DC, end, start, center, 0, fillColor, fillColor );
break; break;
case SHAPE_T::CIRCLE: case SHAPE_T::CIRCLE:
GRFilledCircle( DC, GetStart(), GetRadius(), 0, fillColor, fillColor ); GRFilledCircle( DC, start, GetRadius(), 0, fillColor, fillColor );
break; break;
case SHAPE_T::RECTANGLE: case SHAPE_T::RECTANGLE:
GRFilledRect( DC, GetStart(), GetEnd(), 0, fillColor, fillColor ); GRFilledRect( DC, start, end, 0, fillColor, fillColor );
break; break;
case SHAPE_T::POLY: case SHAPE_T::POLY:
GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor ); GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, fillColor, fillColor );
break; break;
case SHAPE_T::BEZIER: case SHAPE_T::BEZIER:
GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor ); GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, fillColor, fillColor );
break; break;
default: 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( penWidth > 0 )
{ {
if( GetEffectiveLineStyle() == LINE_STYLE::SOLID ) if( GetEffectiveLineStyle() == LINE_STYLE::SOLID )
@ -370,23 +505,23 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod
switch( GetShape() ) switch( GetShape() )
{ {
case SHAPE_T::ARC: case SHAPE_T::ARC:
GRArc( DC, GetEnd(), GetStart(), getCenter(), penWidth, color ); GRArc( DC, end, start, center, penWidth, color );
break; break;
case SHAPE_T::CIRCLE: case SHAPE_T::CIRCLE:
GRCircle( DC, GetStart(), GetRadius(), penWidth, color ); GRCircle( DC, start, GetRadius(), penWidth, color );
break; break;
case SHAPE_T::RECTANGLE: case SHAPE_T::RECTANGLE:
GRRect( DC, GetStart(), GetEnd(), penWidth, color ); GRRect( DC, start, end, penWidth, color );
break; break;
case SHAPE_T::POLY: case SHAPE_T::POLY:
GRPoly( DC, ptCount, buffer, false, penWidth, color, color ); GRPoly( DC, (int) ptList.size(), ptList.data(), false, penWidth, color, color );
break; break;
case SHAPE_T::BEZIER: case SHAPE_T::BEZIER:
GRPoly( DC, ptCount, buffer, false, penWidth, color, color ); GRPoly( DC, (int) ptList.size(), ptList.data(), false, penWidth, color, color );
break; break;
default: default:
@ -401,8 +536,17 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod
{ {
STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings, STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
[&]( const VECTOR2I& a, const VECTOR2I& b ) [&]( 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 ); GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
}
} ); } );
} }
@ -410,13 +554,14 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod
delete shape; delete shape;
} }
} }
delete[] buffer;
} }
void SCH_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) void SCH_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{ {
if( m_layer == LAYER_DEVICE )
getSymbolEditorMsgPanelInfo( aFrame, aList );
else
SCH_ITEM::GetMsgPanelInfo( aFrame, aList ); SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
ShapeGetMsgPanelInfo( aFrame, aList ); ShapeGetMsgPanelInfo( aFrame, aList );
@ -476,8 +621,15 @@ BITMAPS SCH_SHAPE::GetMenuImage() const
void SCH_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const void SCH_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
aCount = 3; aCount = 3;
aLayers[0] = LAYER_NOTES; aLayers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : m_layer;
if( m_layer == LAYER_PRIVATE_NOTES )
aLayers[1] = LAYER_NOTES_BACKGROUND; 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; aLayers[2] = LAYER_SELECTION_SHADOWS;
} }
@ -505,27 +657,53 @@ bool SCH_SHAPE::operator==( const SCH_ITEM& aOther ) const
const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther ); const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
return EDA_SHAPE::operator==( other ); return SCH_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other );
} }
double SCH_SHAPE::Similarity( const SCH_ITEM& aOther ) const double SCH_SHAPE::Similarity( const SCH_ITEM& aOther ) const
{ {
if( m_Uuid == aOther.m_Uuid )
return 1.0;
if( aOther.Type() != Type() ) if( aOther.Type() != Type() )
return 0.0; return 0.0;
const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther ); const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
double similarity = EDA_SHAPE::Similarity( other ); double similarity = SimilarityBase( other );
similarity *= EDA_SHAPE::Similarity( other );
return similarity; 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<const SCH_SHAPE&>( aOther ) );
}
static struct SCH_SHAPE_DESC static struct SCH_SHAPE_DESC
{ {
SCH_SHAPE_DESC() SCH_SHAPE_DESC()
{ {
ENUM_MAP<FILL_T>& fillEnum = ENUM_MAP<FILL_T>::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(); PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( SCH_SHAPE ); REGISTER_TYPE( SCH_SHAPE );
propMgr.AddTypeCast( new TYPE_CAST<SCH_SHAPE, SCH_ITEM> ); propMgr.AddTypeCast( new TYPE_CAST<SCH_SHAPE, SCH_ITEM> );
@ -544,9 +722,40 @@ static struct SCH_SHAPE_DESC
return false; return false;
}; };
auto isSymbolItem =
[]( INSPECTABLE* aItem ) -> bool
{
if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
return shape->GetLayer() == LAYER_DEVICE;
return false;
};
auto isSchematicItem =
[]( INSPECTABLE* aItem ) -> bool
{
if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
return shape->GetLayer() != LAYER_DEVICE;
return false;
};
propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( SCH_ITEM ), propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( SCH_ITEM ),
_HKI( "Position X" ), isPolygon ); _HKI( "Position X" ), isPolygon );
propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( SCH_ITEM ), propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( SCH_ITEM ),
_HKI( "Position Y" ), isPolygon ); _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<SCH_SHAPE, FILL_T>( _HKI( "Fill" ),
fillModeSetter, fillModeGetter ),
_HKI( "Shape Properties" ) )
.SetAvailableFunc( isSymbolItem );
} }
} _SCH_SHAPE_DESC; } _SCH_SHAPE_DESC;
ENUM_TO_WXANY( FILL_T );

View File

@ -32,13 +32,12 @@
class SCH_SHAPE : public SCH_ITEM, public EDA_SHAPE class SCH_SHAPE : public SCH_ITEM, public EDA_SHAPE
{ {
public: public:
SCH_SHAPE( SHAPE_T aShape = SHAPE_T::UNDEFINED, int aLineWidth = 0, SCH_SHAPE( SHAPE_T aShape = SHAPE_T::UNDEFINED, SCH_LAYER_ID aLayer = LAYER_NOTES,
FILL_T aFillType = FILL_T::NO_FILL, int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL, KICAD_T aType = SCH_SHAPE_T );
KICAD_T aType = SCH_SHAPE_T );
// Do not create a copy constructor. The one generated by the compiler is adequate. // 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 wxString GetClass() const override
{ {
@ -47,24 +46,17 @@ public:
void SwapData( SCH_ITEM* aItem ) override; void SwapData( SCH_ITEM* aItem ) override;
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
{ bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
return hitTest( aPosition, aAccuracy );
}
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override int GetPenWidth() const override { return GetStroke().GetWidth(); }
{
return hitTest( aRect, aContained, aAccuracy );
}
int GetPenWidth() const override;
int GetEffectiveWidth() const override { return GetPenWidth(); }
bool HasLineStroke() const override { return true; } bool HasLineStroke() const override { return true; }
STROKE_PARAMS GetStroke() const override { return m_stroke; } STROKE_PARAMS GetStroke() const override { return m_stroke; }
void SetStroke( const STROKE_PARAMS& aStroke ) override; void SetStroke( const STROKE_PARAMS& aStroke ) override;
int GetEffectiveWidth() const override;
LINE_STYLE GetEffectiveLineStyle() const LINE_STYLE GetEffectiveLineStyle() const
{ {
if( m_stroke.GetLineStyle() == LINE_STYLE::DEFAULT ) if( m_stroke.GetLineStyle() == LINE_STYLE::DEFAULT )
@ -73,7 +65,7 @@ public:
return m_stroke.GetLineStyle(); return m_stroke.GetLineStyle();
} }
const BOX2I GetBoundingBox() const override { return getBoundingBox(); } const BOX2I GetBoundingBox() const override;
VECTOR2I GetPosition() const override { return getPosition(); } VECTOR2I GetPosition() const override { return getPosition(); }
void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); } void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); }
@ -96,6 +88,17 @@ public:
void AddPoint( const VECTOR2I& aPosition ); 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<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override
{
return makeEffectiveShapes( aEdgeOnly, true );
}
void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override; 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; 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;
}; };

View File

@ -27,7 +27,7 @@
#include <bitmaps.h> #include <bitmaps.h>
#include <core/mirror.h> #include <core/mirror.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <lib_shape.h> #include <sch_shape.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <sch_symbol.h> #include <sch_symbol.h>
#include <sch_sheet_path.h> #include <sch_sheet_path.h>
@ -80,16 +80,15 @@ static LIB_SYMBOL* dummy()
{ {
symbol = new LIB_SYMBOL( wxEmptyString ); 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->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
square->SetEnd( 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 ); SCH_TEXT* text = new SCH_TEXT( { 0, 0 }, wxT( "??"), LAYER_DEVICE );
text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) ); text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) );
symbol->AddDrawItem( square );
symbol->AddDrawItem( text ); symbol->AddDrawItem( text );
} }

View File

@ -24,13 +24,12 @@
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <widgets/msgpanel.h> #include <widgets/msgpanel.h>
#include <string_utils.h> #include <string_utils.h>
#include <schematic.h>
#include <sch_table.h> #include <sch_table.h>
#include <sch_tablecell.h> #include <sch_tablecell.h>
SCH_TABLECELL::SCH_TABLECELL( int aLineWidth, FILL_T aFillType ) : 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_colSpan( 1 ),
m_rowSpan( 1 ) m_rowSpan( 1 )
{ {

View File

@ -421,7 +421,7 @@ void SCH_TEXT::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBody
const BOX2I SCH_TEXT::GetBoundingBox() const 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 ); BOX2I bbox = GetTextBox( -1, true );
bbox.RevertYAxis(); bbox.RevertYAxis();
@ -525,7 +525,7 @@ BITMAPS SCH_TEXT::GetMenuImage() const
bool SCH_TEXT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) 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 ); EDA_TEXT tmp_text( *this );
tmp_text.SetTextPos( DefaultTransform.TransformCoordinate( GetTextPos() ) ); 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 ); 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(); BOX2I bBox = GetTextBox();
bBox.RevertYAxis(); bBox.RevertYAxis();

View File

@ -34,18 +34,17 @@
#include <wx/log.h> #include <wx/log.h>
#include <dialogs/html_message_box.h> #include <dialogs/html_message_box.h>
#include <project/project_file.h> #include <project/project_file.h>
#include <project/net_settings.h>
#include <core/kicad_algo.h>
#include <trigo.h> #include <trigo.h>
#include <sch_textbox.h> #include <sch_textbox.h>
#include <tools/sch_navigate_tool.h> #include <tools/sch_navigate_tool.h>
SCH_TEXTBOX::SCH_TEXTBOX( int aLineWidth, FILL_T aFillType, const wxString& text, KICAD_T aType ) : SCH_TEXTBOX::SCH_TEXTBOX( SCH_LAYER_ID aLayer, int aLineWidth, FILL_T aFillType,
SCH_SHAPE( SHAPE_T::RECTANGLE, aLineWidth, aFillType, aType ), const wxString& aText, KICAD_T aType ) :
EDA_TEXT( schIUScale, text ) 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 ); SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
SetVertJustify( GR_TEXT_V_ALIGN_TOP ); SetVertJustify( GR_TEXT_V_ALIGN_TOP );
@ -75,6 +74,9 @@ SCH_TEXTBOX::SCH_TEXTBOX( const SCH_TEXTBOX& aText ) :
int SCH_TEXTBOX::GetLegacyTextMargin() const int SCH_TEXTBOX::GetLegacyTextMargin() const
{ {
if( m_layer == LAYER_DEVICE )
return KiROUND( GetTextSize().y * 0.8 );
else
return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 ); 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 VECTOR2I SCH_TEXTBOX::GetDrawPos() const
{ {
BOX2I bbox( m_start, m_end - m_start ); BOX2I bbox;
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(); bbox.Normalize();
}
VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom ); 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, void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
{ {
if( IsPrivate() )
return;
wxDC* DC = aSettings->GetPrintDC(); wxDC* DC = aSettings->GetPrintDC();
int penWidth = GetPenWidth(); int penWidth = GetEffectivePenWidth( aSettings );
bool blackAndWhiteMode = GetGRForceBlackPenState(); bool blackAndWhiteMode = GetGRForceBlackPenState();
VECTOR2I pt1 = GetStart(); VECTOR2I pt1 = GetStart();
VECTOR2I pt2 = GetEnd(); VECTOR2I pt2 = GetEnd();
COLOR4D color = GetStroke().GetColor(); COLOR4D color = GetStroke().GetColor();
COLOR4D bg = aSettings->GetBackgroundColor();
LINE_STYLE lineStyle = GetStroke().GetLineStyle(); LINE_STYLE lineStyle = GetStroke().GetLineStyle();
if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
bg = COLOR4D::WHITE;
if( GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode && !aForceNoFill ) if( GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode && !aForceNoFill )
GRFilledRect( DC, pt1, pt2, 0, GetFillColor(), GetFillColor() ); 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 ) if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
color = aSettings->GetLayerColor( m_layer ); color = aSettings->GetLayerColor( m_layer );
if( aDimmed )
{
color.Desaturate( );
color = color.Mix( bg, 0.5f );
}
if( lineStyle == LINE_STYLE::DEFAULT ) if( lineStyle == LINE_STYLE::DEFAULT )
lineStyle = LINE_STYLE::SOLID; lineStyle = LINE_STYLE::SOLID;
@ -298,8 +323,17 @@ void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aB
{ {
STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings, STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings,
[&]( const VECTOR2I& a, const VECTOR2I& b ) [&]( 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 ); GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
}
} ); } );
} }
@ -313,8 +347,35 @@ void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aB
if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED ) if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
color = aSettings->GetLayerColor( m_layer ); color = aSettings->GetLayerColor( m_layer );
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 ); EDA_TEXT::Print( aSettings, aOffset, color );
} }
}
wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText, wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
@ -345,11 +406,6 @@ wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtr
text = ExpandTextVars( text, &textResolver ); text = ExpandTextVars( text, &textResolver );
} }
KIFONT::FONT* font = GetFont();
if( !font )
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
VECTOR2I size = GetEnd() - GetStart(); VECTOR2I size = GetEnd() - GetStart();
int colWidth; int colWidth;
@ -358,7 +414,8 @@ wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtr
else else
colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() ); colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() );
font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() ); getDrawFont()->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(),
IsItalic() );
return text; return text;
} }
@ -399,7 +456,7 @@ void SCH_TEXTBOX::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const
wxString SCH_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) 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, void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
{ {
if( IsPrivate() )
return;
if( aBackground ) if( aBackground )
{ {
SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed ); SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
return; return;
} }
SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet(); SCH_SHEET_PATH* sheet = Schematic() ? &Schematic()->CurrentSheet() : nullptr;
SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
int penWidth = GetEffectivePenWidth( renderSettings ); int penWidth = GetEffectivePenWidth( renderSettings );
COLOR4D color = GetStroke().GetColor(); COLOR4D color = GetStroke().GetColor();
COLOR4D bg = renderSettings->GetBackgroundColor();
LINE_STYLE lineStyle = GetStroke().GetLineStyle(); LINE_STYLE lineStyle = GetStroke().GetLineStyle();
if( penWidth > 0 ) 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 ) if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
color = renderSettings->GetLayerColor( m_layer ); color = renderSettings->GetLayerColor( m_layer );
if( aDimmed )
{
color.Desaturate( );
color = color.Mix( bg, 0.5f );
}
if( lineStyle == LINE_STYLE::DEFAULT ) if( lineStyle == LINE_STYLE::DEFAULT )
lineStyle = LINE_STYLE::SOLID; 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 ); aPlotter->SetDash( penWidth, LINE_STYLE::SOLID );
} }
KIFONT::FONT* font = GetFont(); KIFONT::FONT* font = getDrawFont();
if( !font )
font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() );
color = GetTextColor(); color = GetTextColor();
if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
color = renderSettings->GetLayerColor( m_layer ); 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 = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() );
penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() ); penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
aPlotter->SetCurrentLineWidth( penWidth ); 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' ); wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' );
positions.reserve( strings_list.Count() ); positions.reserve( 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() ); GetLinePositions( positions, (int) strings_list.Count() );
}
TEXT_ATTRIBUTES attrs = GetAttributes(); TEXT_ATTRIBUTES attrs = GetAttributes();
attrs.m_StrokeWidth = penWidth; 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 double SCH_TEXTBOX::Similarity( const SCH_ITEM& aOther ) const
{ {
if( m_Uuid == aOther.m_Uuid )
return 1.0;
if( aOther.Type() != Type() ) if( aOther.Type() != Type() )
return 0.0; return 0.0;
auto other = static_cast<const SCH_TEXTBOX&>( aOther ); auto other = static_cast<const SCH_TEXTBOX&>( aOther );
double similarity = 1.0; double similarity = SimilarityBase( other );
if( m_excludedFromSim != other.m_excludedFromSim ) if( m_excludedFromSim != other.m_excludedFromSim )
similarity *= 0.9; 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<const SCH_TEXTBOX*>( &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 static struct SCH_TEXTBOX_DESC
{ {
SCH_TEXTBOX_DESC() SCH_TEXTBOX_DESC()

View File

@ -35,19 +35,20 @@ class HTML_MESSAGE_BOX;
class SCH_TEXTBOX : public SCH_SHAPE, public EDA_TEXT class SCH_TEXTBOX : public SCH_SHAPE, public EDA_TEXT
{ {
public: public:
SCH_TEXTBOX( int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL, SCH_TEXTBOX( SCH_LAYER_ID aLayer = LAYER_NOTES, int aLineWidth = 0,
const wxString& aText = wxEmptyString, KICAD_T aType = SCH_TEXTBOX_T ); 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( const SCH_TEXTBOX& aText );
~SCH_TEXTBOX() { } ~SCH_TEXTBOX() { }
static inline bool ClassOf( const EDA_ITEM* aItem ) static bool ClassOf( const EDA_ITEM* aItem )
{ {
return aItem && SCH_TEXTBOX_T == aItem->Type(); return aItem && SCH_TEXTBOX_T == aItem->Type();
} }
virtual wxString GetClass() const override wxString GetClass() const override
{ {
return wxT( "SCH_TEXTBOX" ); return wxT( "SCH_TEXTBOX" );
} }
@ -74,12 +75,12 @@ public:
wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
{ {
SCHEMATIC* schematic = Schematic(); SCH_SHEET_PATH* sheetPath = nullptr;
if( schematic ) if( SCHEMATIC* schematic = Schematic() )
return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth ); sheetPath = &schematic->CurrentSheet();
else
return GetText(); return GetShownText( sheetPath, aAllowExtraText, aDepth );
} }
bool IsHypertext() const override bool IsHypertext() const override
@ -150,6 +151,8 @@ protected:
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); } const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
protected: protected:
bool m_excludedFromSim; bool m_excludedFromSim;
int m_marginLeft; int m_marginLeft;

View File

@ -24,7 +24,7 @@
#include <vector> #include <vector>
#include <sch_symbol.h> #include <sch_symbol.h>
#include <eda_draw_frame.h> #include <eda_draw_frame.h>
#include <lib_shape.h> #include <sch_shape.h>
#include <macros.h> #include <macros.h>
// helper function to sort pins by pin num // helper function to sort pins by pin num
@ -363,10 +363,10 @@ void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessag
for( const SCH_ITEM& item : aSymbol->GetDrawItems() ) for( const SCH_ITEM& item : aSymbol->GetDrawItems() )
{ {
if( item.Type() != LIB_SHAPE_T ) if( item.Type() != SCH_SHAPE_T )
continue; continue;
const LIB_SHAPE* shape = static_cast<const LIB_SHAPE*>( &item ); const SCH_SHAPE* shape = static_cast<const SCH_SHAPE*>( &item );
switch( shape->GetShape() ) switch( shape->GetShape() )
{ {

View File

@ -380,10 +380,8 @@ GRID_HELPER_GRIDS EE_GRID_HELPER::GetItemGrid( const EDA_ITEM* aItem ) const
case SCH_TEXT_T: case SCH_TEXT_T:
return GRID_TEXT; return GRID_TEXT;
case LIB_SHAPE_T:
case SCH_SHAPE_T: case SCH_SHAPE_T:
// The text box's border lines are what need to be on the graphic grid // 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_TEXTBOX_T:
case SCH_BITMAP_T: case SCH_BITMAP_T:
return GRID_GRAPHICS; return GRID_GRAPHICS;

View File

@ -42,10 +42,7 @@ using namespace std::placeholders;
#include <sch_table.h> #include <sch_table.h>
#include <sch_tablecell.h> #include <sch_tablecell.h>
#include <sch_shape.h> #include <sch_shape.h>
#include <sch_sheet_pin.h>
#include <symbol_edit_frame.h> #include <symbol_edit_frame.h>
#include <lib_shape.h>
#include <lib_textbox.h>
// Few constants to avoid using bare numbers for point indices // 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_START,
BEZIER_CURVE_CONTROL_POINT1, BEZIER_CTRL_PT1,
BEZIER_CURVE_CONTROL_POINT2, BEZIER_CTRL_PT2,
BEZIER_CURVE_END BEZIER_END
}; };
@ -105,116 +102,30 @@ public:
// Generate list of edit points based on the item type // Generate list of edit points based on the item type
switch( aItem->Type() ) switch( aItem->Type() )
{ {
case LIB_SHAPE_T:
{
LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( 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<LIB_TEXTBOX*>( 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: case SCH_SHAPE_T:
{ {
SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem ); SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
bool invertY = shape->GetLayer() == LAYER_DEVICE;
switch( shape->GetShape() ) switch( shape->GetShape() )
{ {
case SHAPE_T::ARC: case SHAPE_T::ARC:
points->AddPoint( shape->GetPosition() ); points->AddPoint( mapCoords( shape->GetPosition(), invertY ) );
points->AddPoint( shape->GetStart() ); points->AddPoint( mapCoords( shape->GetStart(), invertY ) );
points->AddPoint( shape->GetEnd() ); points->AddPoint( mapCoords( shape->GetEnd(), invertY ) );
break; break;
case SHAPE_T::CIRCLE: case SHAPE_T::CIRCLE:
points->AddPoint( shape->GetPosition() ); points->AddPoint( mapCoords( shape->GetPosition(), invertY ) );
points->AddPoint( shape->GetEnd() ); points->AddPoint( mapCoords( shape->GetEnd(), invertY ) );
break; break;
case SHAPE_T::RECTANGLE: case SHAPE_T::RECTANGLE:
{ {
shape->Normalize(); shape->Normalize();
VECTOR2I topLeft = shape->GetPosition(); VECTOR2I topLeft = mapCoords( shape->GetPosition(), invertY );
VECTOR2I botRight = shape->GetEnd(); VECTOR2I botRight = mapCoords( shape->GetEnd(), invertY );
points->AddPoint( topLeft ); points->AddPoint( topLeft );
points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) );
@ -235,15 +146,15 @@ public:
case SHAPE_T::POLY: case SHAPE_T::POLY:
for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() ) for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() )
points->AddPoint( pt ); points->AddPoint( mapCoords( pt, invertY ) );
break; break;
case SHAPE_T::BEZIER: case SHAPE_T::BEZIER:
points->AddPoint( shape->GetStart() ); points->AddPoint( mapCoords( shape->GetStart(), invertY ) );
points->AddPoint( shape->GetBezierC1() ); points->AddPoint( mapCoords( shape->GetBezierC1(), invertY ) );
points->AddPoint( shape->GetBezierC2() ); points->AddPoint( mapCoords( shape->GetBezierC2(), invertY ) );
points->AddPoint( shape->GetEnd() ); points->AddPoint( mapCoords( shape->GetEnd(), invertY ) );
break; break;
default: default:
@ -255,12 +166,13 @@ public:
case SCH_TEXTBOX_T: case SCH_TEXTBOX_T:
{ {
SCH_TEXTBOX* textBox = static_cast<SCH_TEXTBOX*>( aItem ); SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( aItem );
bool invertY = textbox->GetLayer() == LAYER_DEVICE;
textBox->Normalize(); textbox->Normalize();
VECTOR2I topLeft = textBox->GetPosition(); VECTOR2I topLeft = mapCoords( textbox->GetPosition(), invertY );
VECTOR2I botRight = textBox->GetEnd(); VECTOR2I botRight = mapCoords( textbox->GetEnd(), invertY );
points->AddPoint( topLeft ); points->AddPoint( topLeft );
points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); 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(); const EE_SELECTION& selection = m_selectionTool->GetSelection();
if( selection.Size() != 1 || !selection.Front()->IsType( { LIB_SHAPE_T, SCH_SHAPE_T, if( selection.Size() != 1 || !selection.Front()->IsType( { SCH_SHAPE_T,
LIB_TEXTBOX_T, SCH_TEXTBOX_T, SCH_TEXTBOX_T,
SCH_TABLECELL_T, SCH_TABLECELL_T,
SCH_SHEET_T, SCH_SHEET_T,
SCH_ITEM_LOCATE_GRAPHIC_LINE_T, SCH_ITEM_LOCATE_GRAPHIC_LINE_T,
@ -720,168 +632,10 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const
switch( item->Type() ) switch( item->Type() )
{ {
case LIB_SHAPE_T:
{
LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( 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<LIB_TEXTBOX*>( 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: case SCH_SHAPE_T:
{ {
SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( item ); SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( item );
bool invertY = true;
switch( shape->GetShape() ) switch( shape->GetShape() )
{ {
@ -889,23 +643,23 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const
if( getEditedPointIndex() == ARC_CENTER ) if( getEditedPointIndex() == ARC_CENTER )
{ {
shape->SetEditState( 4 ); 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 ) else if( getEditedPointIndex() == ARC_START )
{ {
shape->SetEditState( 2 ); 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 ) else if( getEditedPointIndex() == ARC_END )
{ {
shape->SetEditState( 3 ); shape->SetEditState( 3 );
shape->CalcEdit( m_editPoints->Point( ARC_END ).GetPosition() ); shape->CalcEdit( mapCoords( m_editPoints->Point( ARC_END ).GetPosition(), invertY ) );
} }
break; break;
case SHAPE_T::CIRCLE: case SHAPE_T::CIRCLE:
shape->SetPosition( m_editPoints->Point( CIRC_CENTER ).GetPosition() ); shape->SetPosition( mapCoords( m_editPoints->Point( CIRC_CENTER ).GetPosition(), invertY ) );
shape->SetEnd( m_editPoints->Point( CIRC_END ).GetPosition() ); shape->SetEnd( mapCoords( m_editPoints->Point( CIRC_END ).GetPosition(), invertY ) );
break; break;
case SHAPE_T::POLY: 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 ) 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 ); 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_BOTRIGHT ) )
|| isModified( m_editPoints->Point( RECT_BOTLEFT ) ) ) || isModified( m_editPoints->Point( RECT_BOTLEFT ) ) )
{ {
shape->SetPosition( topLeft ); shape->SetPosition( mapCoords( topLeft, invertY ) );
shape->SetEnd( botRight ); shape->SetEnd( mapCoords( botRight, invertY ) );
} }
else if( isModified( m_editPoints->Line( RECT_TOP ) ) ) 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 ) ) ) 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 ) ) ) 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 ) ) ) 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 ) 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: case SHAPE_T::BEZIER:
shape->SetStart( m_editPoints->Point( BEZIER_CURVE_START ).GetPosition() ); shape->SetStart( mapCoords( m_editPoints->Point( BEZIER_START ).GetPosition(), invertY ) );
shape->SetBezierC1( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition() ); shape->SetBezierC1( mapCoords( m_editPoints->Point( BEZIER_CTRL_PT1 ).GetPosition(), invertY ) );
shape->SetBezierC2( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition() ); shape->SetBezierC2( mapCoords( m_editPoints->Point( BEZIER_CTRL_PT2 ).GetPosition(), invertY ) );
shape->SetEnd( m_editPoints->Point( BEZIER_CURVE_END ).GetPosition() ); shape->SetEnd( mapCoords( m_editPoints->Point( BEZIER_END ).GetPosition(), invertY ) );
shape->RebuildBezierToSegmentsPointsList( shape->GetWidth() ); shape->RebuildBezierToSegmentsPointsList( shape->GetWidth() );
break; break;
@ -988,7 +742,8 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid ) const
case SCH_TEXTBOX_T: case SCH_TEXTBOX_T:
{ {
SCH_TEXTBOX* textBox = static_cast<SCH_TEXTBOX*>( item ); SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
bool invertY = textbox->GetLayer() == LAYER_DEVICE;
EE_GRID_HELPER gridHelper( m_toolMgr ); EE_GRID_HELPER gridHelper( m_toolMgr );
VECTOR2I topLeft = m_editPoints->Point( RECT_TOPLEFT ).GetPosition(); VECTOR2I topLeft = m_editPoints->Point( RECT_TOPLEFT ).GetPosition();
VECTOR2I topRight = m_editPoints->Point( RECT_TOPRIGHT ).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_BOTRIGHT ) )
|| isModified( m_editPoints->Point( RECT_BOTLEFT ) ) ) || isModified( m_editPoints->Point( RECT_BOTLEFT ) ) )
{ {
textBox->SetPosition( topLeft ); textbox->SetPosition( mapCoords( topLeft, invertY ) );
textBox->SetEnd( botRight ); textbox->SetEnd( mapCoords( botRight, invertY ) );
} }
else if( isModified( m_editPoints->Line( RECT_TOP ) ) ) 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 ) ) ) 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 ) ) ) 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 ) ) ) 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 ) 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; break;
} }
@ -1223,112 +978,22 @@ void EE_POINT_EDITOR::updatePoints()
switch( item->Type() ) switch( item->Type() )
{ {
case LIB_SHAPE_T:
{
LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( 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<LIB_TEXTBOX*>( 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: case SCH_SHAPE_T:
{ {
SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( item ); SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( item );
bool invertY = true;
switch( shape->GetShape() ) switch( shape->GetShape() )
{ {
case SHAPE_T::ARC: case SHAPE_T::ARC:
m_editPoints->Point( ARC_CENTER ).SetPosition( shape->GetPosition() ); m_editPoints->Point( ARC_CENTER ).SetPosition( mapCoords( shape->GetPosition(), invertY ) );
m_editPoints->Point( ARC_START ).SetPosition( shape->GetStart() ); m_editPoints->Point( ARC_START ).SetPosition( mapCoords( shape->GetStart(), invertY ) );
m_editPoints->Point( ARC_END ).SetPosition( shape->GetEnd() ); m_editPoints->Point( ARC_END ).SetPosition( mapCoords( shape->GetEnd(), invertY ) );
break; break;
case SHAPE_T::CIRCLE: case SHAPE_T::CIRCLE:
m_editPoints->Point( CIRC_CENTER ).SetPosition( shape->GetPosition() ); m_editPoints->Point( CIRC_CENTER ).SetPosition( mapCoords( shape->GetPosition(), invertY ) );
m_editPoints->Point( CIRC_END ).SetPosition( shape->GetEnd() ); m_editPoints->Point( CIRC_END ).SetPosition( mapCoords( shape->GetEnd(), invertY ) );
break; break;
case SHAPE_T::POLY: case SHAPE_T::POLY:
@ -1345,7 +1010,7 @@ void EE_POINT_EDITOR::updatePoints()
int ii = 0; int ii = 0;
for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() ) for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() )
m_editPoints->Point( ii++ ).SetPosition( pt ); m_editPoints->Point( ii++ ).SetPosition( mapCoords( pt, invertY ) );
} }
break; break;
@ -1357,8 +1022,8 @@ void EE_POINT_EDITOR::updatePoints()
// Some symbols can have rectangles with width or height < 0 // Some symbols can have rectangles with width or height < 0
// So normalize the size: // So normalize the size:
BOX2I dummy; BOX2I dummy;
dummy.SetOrigin( shape->GetPosition() ); dummy.SetOrigin( mapCoords( shape->GetPosition(), invertY ) );
dummy.SetEnd( shape->GetEnd() ); dummy.SetEnd( mapCoords( shape->GetEnd(), invertY ) );
dummy.Normalize(); dummy.Normalize();
VECTOR2I topLeft = dummy.GetPosition(); VECTOR2I topLeft = dummy.GetPosition();
VECTOR2I botRight = dummy.GetEnd(); VECTOR2I botRight = dummy.GetEnd();
@ -1371,10 +1036,10 @@ void EE_POINT_EDITOR::updatePoints()
} }
case SHAPE_T::BEZIER: case SHAPE_T::BEZIER:
m_editPoints->Point( BEZIER_CURVE_START ).SetPosition( shape->GetStart() ); m_editPoints->Point( BEZIER_START ).SetPosition( mapCoords( shape->GetStart(), invertY ) );
m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).SetPosition( shape->GetBezierC1() ); m_editPoints->Point( BEZIER_CTRL_PT1 ).SetPosition( mapCoords( shape->GetBezierC1(), invertY ) );
m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).SetPosition( shape->GetBezierC2() ); m_editPoints->Point( BEZIER_CTRL_PT2 ).SetPosition( mapCoords( shape->GetBezierC2(), invertY ) );
m_editPoints->Point( BEZIER_CURVE_END ).SetPosition( shape->GetEnd() ); m_editPoints->Point( BEZIER_END ).SetPosition( mapCoords( shape->GetEnd(), invertY ) );
break; break;
default: default:
@ -1386,14 +1051,15 @@ void EE_POINT_EDITOR::updatePoints()
case SCH_TEXTBOX_T: case SCH_TEXTBOX_T:
{ {
SCH_TEXTBOX* textBox = static_cast<SCH_TEXTBOX*>( item ); SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
bool invertY = textbox->GetLayer() == LAYER_DEVICE;
// point editor works only with rectangles having width and height > 0 // point editor works only with rectangles having width and height > 0
// Some symbols can have rectangles with width or height < 0 // Some symbols can have rectangles with width or height < 0
// So normalize the size: // So normalize the size:
BOX2I dummy; BOX2I dummy;
dummy.SetOrigin( textBox->GetPosition() ); dummy.SetOrigin( mapCoords( textbox->GetPosition(), invertY ) );
dummy.SetEnd( textBox->GetEnd() ); dummy.SetEnd( mapCoords( textbox->GetEnd(), invertY ) );
dummy.Normalize(); dummy.Normalize();
VECTOR2I topLeft = dummy.GetPosition(); VECTOR2I topLeft = dummy.GetPosition();
VECTOR2I botRight = dummy.GetEnd(); VECTOR2I botRight = dummy.GetEnd();
@ -1483,10 +1149,11 @@ void EE_POINT_EDITOR::setEditedPoint( EDIT_POINT* aPoint )
bool EE_POINT_EDITOR::removeCornerCondition( const SELECTION& ) 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; return false;
LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( m_editPoints->GetParent() ); SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( m_editPoints->GetParent() );
bool invertY = shape->GetLayer() == LAYER_DEVICE;
if( shape->GetPolyShape().IsEmpty() ) if( shape->GetPolyShape().IsEmpty() )
return false; return false;
@ -1498,7 +1165,7 @@ bool EE_POINT_EDITOR::removeCornerCondition( const SELECTION& )
for( const VECTOR2I& pt : poly.CPoints() ) for( const VECTOR2I& pt : poly.CPoints() )
{ {
if( pt == mapCoords( m_editedPoint->GetPosition() ) ) if( pt == mapCoords( m_editedPoint->GetPosition(), invertY ) )
return true; return true;
} }
@ -1508,10 +1175,10 @@ bool EE_POINT_EDITOR::removeCornerCondition( const SELECTION& )
bool EE_POINT_EDITOR::addCornerCondition( 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; return false;
LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( m_editPoints->GetParent() ); SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( m_editPoints->GetParent() );
if( shape->GetShape() != SHAPE_T::POLY ) if( shape->GetShape() != SHAPE_T::POLY )
return false; return false;
@ -1525,17 +1192,18 @@ bool EE_POINT_EDITOR::addCornerCondition( const SELECTION& )
int EE_POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent ) 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; return 0;
LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( m_editPoints->GetParent() ); SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( m_editPoints->GetParent() );
bool invertY = shape->GetLayer() == LAYER_DEVICE;
SHAPE_LINE_CHAIN& poly = shape->GetPolyShape().Outline( 0 ); SHAPE_LINE_CHAIN& poly = shape->GetPolyShape().Outline( 0 );
SCH_COMMIT commit( m_toolMgr ); SCH_COMMIT commit( m_toolMgr );
commit.Modify( shape, m_frame->GetScreen() ); commit.Modify( shape, m_frame->GetScreen() );
VECTOR2I cursor = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() ); VECTOR2I cursor = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
VECTOR2I pos = mapCoords( cursor ); VECTOR2I pos = mapCoords( cursor, invertY );
int currentMinDistance = INT_MAX; int currentMinDistance = INT_MAX;
int closestLineStart = 0; 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 ) 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; return 0;
LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( m_editPoints->GetParent() ); SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( m_editPoints->GetParent() );
SHAPE_LINE_CHAIN& poly = shape->GetPolyShape().Outline( 0 ); SHAPE_LINE_CHAIN& poly = shape->GetPolyShape().Outline( 0 );
SCH_COMMIT commit( m_toolMgr ); SCH_COMMIT commit( m_toolMgr );

View File

@ -45,14 +45,12 @@
#include <sch_item.h> #include <sch_item.h>
#include <sch_line.h> #include <sch_line.h>
#include <sch_bus_entry.h> #include <sch_bus_entry.h>
#include <sch_junction.h>
#include <sch_marker.h> #include <sch_marker.h>
#include <sch_no_connect.h> #include <sch_no_connect.h>
#include <sch_sheet.h> #include <sch_sheet.h>
#include <sch_sheet_pin.h> #include <sch_sheet_pin.h>
#include <sch_table.h> #include <sch_table.h>
#include <sch_tablecell.h> #include <sch_tablecell.h>
#include <lib_shape.h>
#include <schematic.h> #include <schematic.h>
#include <tool/tool_event.h> #include <tool/tool_event.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
@ -570,9 +568,9 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
} }
else else
{ {
m_selection = RequestSelection( { LIB_SHAPE_T, m_selection = RequestSelection( { SCH_SHAPE_T,
SCH_TEXT_T, SCH_TEXT_T,
LIB_TEXTBOX_T, SCH_TEXTBOX_T,
LIB_PIN_T, LIB_PIN_T,
SCH_FIELD_T } ); SCH_FIELD_T } );
} }
@ -1355,7 +1353,7 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
{ {
EDA_ITEM* item = collector[ i ]; EDA_ITEM* item = collector[ i ];
SCH_LINE* line = dynamic_cast<SCH_LINE*>( item ); SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
LIB_SHAPE* shape = dynamic_cast<LIB_SHAPE*>( item ); SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( item );
SCH_TABLE* table = dynamic_cast<SCH_TABLE*>( item ); SCH_TABLE* table = dynamic_cast<SCH_TABLE*>( item );
// Lines are hard to hit. Give them a bit more slop to still be considered "exact". // 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.) // Find the closest item. (Note that at this point all hits are either exact or non-exact.)
VECTOR2I pos( aPos ); VECTOR2I pos( aPos );
SEG poss( m_isSymbolEditor ? mapCoords( pos ) : pos, SEG poss( mapCoords( pos, m_isSymbolEditor ), mapCoords( pos, m_isSymbolEditor ) );
m_isSymbolEditor ? mapCoords( pos ) : pos );
EDA_ITEM* closest = nullptr; EDA_ITEM* closest = nullptr;
int closestDist = INT_MAX / 4; int closestDist = INT_MAX / 4;
@ -1636,7 +1633,6 @@ bool EE_SELECTION_TOOL::itemPassesFilter( EDA_ITEM* aItem )
} }
case SCH_SHAPE_T: case SCH_SHAPE_T:
case LIB_SHAPE_T:
if( !m_filter.graphics ) if( !m_filter.graphics )
return false; return false;
@ -1647,7 +1643,6 @@ bool EE_SELECTION_TOOL::itemPassesFilter( EDA_ITEM* aItem )
case SCH_TABLE_T: case SCH_TABLE_T:
case SCH_TABLECELL_T: case SCH_TABLECELL_T:
case SCH_FIELD_T: case SCH_FIELD_T:
case LIB_TEXTBOX_T:
if( !m_filter.text ) if( !m_filter.text )
return false; 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. case SCH_FIELD_T: // SCH_FIELD objects are not unit/body-style-specific.
break; break;
case LIB_SHAPE_T: case SCH_SHAPE_T:
case SCH_TEXT_T: case SCH_TEXT_T:
case SCH_TEXTBOX_T:
case LIB_PIN_T: case LIB_PIN_T:
if( symEditFrame ) if( symEditFrame )
{ {

View File

@ -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 #endif

View File

@ -1886,7 +1886,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( isTextBox ) 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, textbox->SetTextSize( VECTOR2I( sch_settings.m_DefaultTextSize,
sch_settings.m_DefaultTextSize ) ); sch_settings.m_DefaultTextSize ) );
@ -1907,12 +1907,12 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
} }
else else
{ {
item = new SCH_SHAPE( type, 0, m_lastFillStyle ); item = new SCH_SHAPE( type, LAYER_NOTES, 0, m_lastFillStyle );
item->SetStroke( m_lastStroke ); item->SetStroke( m_lastStroke );
item->SetFillColor( m_lastFillColor ); item->SetFillColor( m_lastFillColor );
item->SetParent( schematic ); item->SetParent( schematic );
description = wxString::Format( _( "Add %s" ), item->EDA_SHAPE::GetFriendlyName() ); description = wxString::Format( _( "Add %s" ), item->GetFriendlyName() );
} }
item->SetFlags( IS_NEW ); item->SetFlags( IS_NEW );

View File

@ -2282,7 +2282,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
case SCH_TEXTBOX_T: 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(); BOX2I bbox = item->GetBoundingBox();
if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item ) ) if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item ) )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2019 CERN * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -31,15 +31,14 @@
#include <tools/symbol_editor_pin_tool.h> #include <tools/symbol_editor_pin_tool.h>
#include <tools/ee_grid_helper.h> #include <tools/ee_grid_helper.h>
#include <dialogs/dialog_text_properties.h> #include <dialogs/dialog_text_properties.h>
#include <lib_shape.h> #include <sch_shape.h>
#include <lib_textbox.h> #include <sch_textbox.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <symbol_editor/symbol_editor_settings.h> #include <symbol_editor/symbol_editor_settings.h>
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <string_utils.h> #include <string_utils.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include <import_gfx/dialog_import_gfx_sch.h> #include <import_gfx/dialog_import_gfx_sch.h>
#include "dialog_lib_textbox_properties.h"
static void* g_lastPinWeakPtr; static void* g_lastPinWeakPtr;
@ -361,7 +360,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::opt
VECTOR2I cursorPos; VECTOR2I cursorPos;
SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType; SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType;
LIB_SYMBOL* symbol = m_frame->GetCurSymbol(); LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
LIB_SHAPE* item = nullptr; SCH_SHAPE* item = nullptr;
wxString description; wxString description;
if( m_inDrawShape ) if( m_inDrawShape )
@ -461,8 +460,9 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::opt
if( isTextBox ) 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 ), textbox->SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
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 else
{ {
item = new LIB_SHAPE( symbol, shapeType, lineWidth, m_lastFillStyle ); item = new SCH_SHAPE( shapeType, LAYER_DEVICE, lineWidth, m_lastFillStyle );
description = wxString::Format( _( "Add %s" ), item->EDA_SHAPE::GetFriendlyName() ); item->SetParent( symbol );
description = wxString::Format( _( "Add %s" ), item->GetFriendlyName() );
} }
item->SetStroke( m_lastStroke ); item->SetStroke( m_lastStroke );
@ -524,8 +525,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::opt
if( isTextBox ) if( isTextBox )
{ {
LIB_TEXTBOX* textbox = static_cast<LIB_TEXTBOX*>( item ); SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
DIALOG_LIB_TEXTBOX_PROPERTIES dlg( m_frame, static_cast<LIB_TEXTBOX*>( item ) ); DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_TEXTBOX*>( item ) );
// QuasiModal required for syntax help and Scintilla auto-complete // QuasiModal required for syntax help and Scintilla auto-complete
if( dlg.ShowQuasiModal() != wxID_OK ) if( dlg.ShowQuasiModal() != wxID_OK )

View File

@ -31,15 +31,14 @@
#include <string_utils.h> #include <string_utils.h>
#include <symbol_edit_frame.h> #include <symbol_edit_frame.h>
#include <sch_commit.h> #include <sch_commit.h>
#include <dialogs/dialog_lib_shape_properties.h> #include <dialogs/dialog_shape_properties.h>
#include <dialogs/dialog_text_properties.h> #include <dialogs/dialog_text_properties.h>
#include <dialogs/dialog_lib_textbox_properties.h>
#include <dialogs/dialog_field_properties.h> #include <dialogs/dialog_field_properties.h>
#include <dialogs/dialog_lib_symbol_properties.h> #include <dialogs/dialog_lib_symbol_properties.h>
#include <dialogs/dialog_lib_edit_pin_table.h> #include <dialogs/dialog_lib_edit_pin_table.h>
#include <dialogs/dialog_update_symbol_fields.h> #include <dialogs/dialog_update_symbol_fields.h>
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h> #include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>
#include <lib_textbox.h> #include <sch_textbox.h>
#include "symbol_editor_edit_tool.h" #include "symbol_editor_edit_tool.h"
#include <wx/textdlg.h> // for wxTextEntryDialog #include <wx/textdlg.h> // for wxTextEntryDialog
#include <math/util.h> // for KiROUND #include <math/util.h> // for KiROUND
@ -166,7 +165,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
if( selection.GetSize() == 1 ) if( selection.GetSize() == 1 )
rotPoint = item->GetPosition(); rotPoint = item->GetPosition();
else else
rotPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter() ) ); rotPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter(), true ) );
for( unsigned ii = 0; ii < selection.GetSize(); ii++ ) for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
{ {
@ -238,7 +237,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
} }
else else
{ {
mirrorPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter() ) ); mirrorPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter(), true ) );
for( unsigned ii = 0; ii < selection.GetSize(); ii++ ) 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<KICAD_T> nonFields = static std::vector<KICAD_T> nonFields =
{ {
LIB_SYMBOL_T, LIB_SYMBOL_T,
LIB_SHAPE_T, SCH_SHAPE_T,
SCH_TEXT_T, SCH_TEXT_T,
LIB_TEXTBOX_T, SCH_TEXTBOX_T,
LIB_PIN_T LIB_PIN_T
}; };
@ -457,15 +456,15 @@ int SYMBOL_EDITOR_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
break; break;
case LIB_SHAPE_T: case SCH_SHAPE_T:
editShapeProperties( static_cast<LIB_SHAPE*>( item ) ); editShapeProperties( static_cast<SCH_SHAPE*>( item ) );
break; break;
case SCH_TEXT_T: case SCH_TEXT_T:
editTextProperties( item ); editTextProperties( item );
break; break;
case LIB_TEXTBOX_T: case SCH_TEXTBOX_T:
editTextBoxProperties( item ); editTextBoxProperties( item );
break; 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 ) if( dlg.ShowModal() != wxID_OK )
return; return;
@ -525,10 +524,10 @@ void SYMBOL_EDITOR_EDIT_TOOL::editTextProperties( SCH_ITEM* aItem )
void SYMBOL_EDITOR_EDIT_TOOL::editTextBoxProperties( 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; return;
DIALOG_LIB_TEXTBOX_PROPERTIES dlg( m_frame, static_cast<LIB_TEXTBOX*>( aItem ) ); DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_TEXTBOX*>( aItem ) );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return; 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::clearSelection );
m_toolMgr->RunAction<EDA_ITEMS*>( EE_ACTIONS::addItemsToSel, &newItems ); m_toolMgr->RunAction<EDA_ITEMS*>( 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 ) ) if( m_toolMgr->RunSynchronousAction( EE_ACTIONS::move, &commit ) )
commit.Push( _( "Duplicate" ) ); commit.Push( _( "Duplicate" ) );

View File

@ -65,7 +65,7 @@ public:
int InteractiveDelete( const TOOL_EVENT& aEvent ); int InteractiveDelete( const TOOL_EVENT& aEvent );
private: private:
void editShapeProperties( LIB_SHAPE* aShape ); void editShapeProperties( SCH_SHAPE* aShape );
void editTextProperties( SCH_ITEM* aItem ); void editTextProperties( SCH_ITEM* aItem );
void editTextBoxProperties( SCH_ITEM* aItem ); void editTextBoxProperties( SCH_ITEM* aItem );
void editFieldProperties( SCH_FIELD* aField ); void editFieldProperties( SCH_FIELD* aField );

View File

@ -28,7 +28,7 @@
#include <ee_grid_helper.h> #include <ee_grid_helper.h>
#include <eda_item.h> #include <eda_item.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <lib_shape.h> #include <sch_shape.h>
#include <sch_commit.h> #include <sch_commit.h>
#include <wx/log.h> #include <wx/log.h>
#include "symbol_editor_move_tool.h" #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() ) if( lib_item->IsNew() )
{ {
m_anchorPos = selection.GetReferencePoint(); 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 // Drag items to the current cursor position
for( EDA_ITEM* item : selection ) 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 ) [&]( EDA_ITEM* item, const VECTOR2I& delta )
{ {
commit.Modify( item, m_frame->GetScreen() ); commit.Modify( item, m_frame->GetScreen() );
static_cast<SCH_ITEM*>( item )->Move( mapCoords( delta ) ); static_cast<SCH_ITEM*>( item )->Move( mapCoords( delta, true ) );
updateItem( item, true ); updateItem( item, true );
}; };
for( EDA_ITEM* item : selection ) for( EDA_ITEM* item : selection )
{ {
if( LIB_SHAPE* shape = dynamic_cast<LIB_SHAPE*>( item ) ) if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( item ) )
{ {
VECTOR2I newStart = grid.AlignGrid( shape->GetStart(), grid.GetItemGrid( shape ) ); VECTOR2I newStart = grid.AlignGrid( shape->GetStart(), grid.GetItemGrid( shape ) );
VECTOR2I newEnd = grid.AlignGrid( shape->GetEnd(), 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;
break;
case SHAPE_T::POLY: case SHAPE_T::POLY:
if( shape->GetPointCount() > 0 ) 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 ) void SYMBOL_EDITOR_MOVE_TOOL::moveItem( EDA_ITEM* aItem, const VECTOR2I& aDelta )
{ {
static_cast<SCH_ITEM*>( aItem )->Move( mapCoords( aDelta ) ); static_cast<SCH_ITEM*>( aItem )->Move( mapCoords( aDelta, true ) );
aItem->SetFlags( IS_MOVING ); aItem->SetFlags( IS_MOVING );
} }

View File

@ -137,6 +137,21 @@ enum KICAD_T
PCB_SHAPE_LOCATE_POLY_T, PCB_SHAPE_LOCATE_POLY_T,
PCB_SHAPE_LOCATE_BEZIER_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. // Schematic draw Items. The order of these items effects the sort order.
// It is currently ordered to mimic the old Eeschema locate behavior where // It is currently ordered to mimic the old Eeschema locate behavior where
// the smallest item is the selected item. // the smallest item is the selected item.
@ -146,17 +161,13 @@ enum KICAD_T
SCH_BUS_WIRE_ENTRY_T, SCH_BUS_WIRE_ENTRY_T,
SCH_BUS_BUS_ENTRY_T, SCH_BUS_BUS_ENTRY_T,
SCH_LINE_T, SCH_LINE_T,
SCH_SHAPE_T,
SCH_BITMAP_T, SCH_BITMAP_T,
SCH_TEXTBOX_T,
SCH_TEXT_T,
SCH_TABLE_T, SCH_TABLE_T,
SCH_TABLECELL_T, SCH_TABLECELL_T,
SCH_LABEL_T, SCH_LABEL_T,
SCH_GLOBAL_LABEL_T, SCH_GLOBAL_LABEL_T,
SCH_HIER_LABEL_T, SCH_HIER_LABEL_T,
SCH_DIRECTIVE_LABEL_T, SCH_DIRECTIVE_LABEL_T,
SCH_FIELD_T,
SCH_SYMBOL_T, SCH_SYMBOL_T,
SCH_SHEET_PIN_T, SCH_SHEET_PIN_T,
SCH_SHEET_T, SCH_SHEET_T,
@ -191,19 +202,6 @@ enum KICAD_T
SCHEMATIC_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: * For GerbView: item types:
*/ */
@ -411,8 +409,6 @@ constexpr bool IsEeschemaType( const KICAD_T aType )
case SCHEMATIC_T: case SCHEMATIC_T:
case LIB_SYMBOL_T: case LIB_SYMBOL_T:
case LIB_SHAPE_T:
case LIB_TEXTBOX_T:
case LIB_PIN_T: case LIB_PIN_T:
return true; return true;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -119,8 +119,6 @@ public:
void SetShape( SHAPE_T aShape ) { m_shape = aShape; } void SetShape( SHAPE_T aShape ) { m_shape = aShape; }
SHAPE_T GetShape() const { return m_shape; } SHAPE_T GetShape() const { return m_shape; }
wxString GetFriendlyName() const;
/** /**
* Return the starting point of the graphic. * Return the starting point of the graphic.
*/ */
@ -346,6 +344,8 @@ public:
bool operator==( const EDA_SHAPE& aOther ) const; bool operator==( const EDA_SHAPE& aOther ) const;
protected: protected:
wxString getFriendlyName() const;
void setPosition( const VECTOR2I& aPos ); void setPosition( const VECTOR2I& aPos );
VECTOR2I getPosition() const; VECTOR2I getPosition() const;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -45,9 +45,9 @@ public:
// Do not create a copy constructor & operator=. // Do not create a copy constructor & operator=.
// The ones generated by the compiler are adequate. // 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(); return aItem && PCB_SHAPE_T == aItem->Type();
} }
@ -62,7 +62,7 @@ public:
bool IsConnected() const override; bool IsConnected() const override;
wxString GetFriendlyName() const override { return EDA_SHAPE::GetFriendlyName(); } wxString GetFriendlyName() const override { return getFriendlyName(); }
bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override; bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override;
@ -150,15 +150,15 @@ public:
int aError, ERROR_LOC aErrorLoc, int aError, ERROR_LOC aErrorLoc,
bool ignoreLineWidth = false ) const override; 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 ///< @copydoc VIEW_ITEM::ViewGetLOD
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
@ -172,7 +172,7 @@ public:
#endif #endif
protected: protected:
virtual void swapData( BOARD_ITEM* aImage ) override; void swapData( BOARD_ITEM* aImage ) override;
struct cmp_drawings struct cmp_drawings
{ {

View File

@ -94,12 +94,12 @@ enum CIRCLE_POINTS
}; };
enum BEZIER_CURVE_POINTS enum BEZIER_POINTS
{ {
BEZIER_CURVE_START, BEZIER_START,
BEZIER_CURVE_CONTROL_POINT1, BEZIER_CTRL_PT1,
BEZIER_CURVE_CONTROL_POINT2, BEZIER_CTRL_PT2,
BEZIER_CURVE_END BEZIER_END
}; };
@ -1398,14 +1398,14 @@ void PCB_POINT_EDITOR::updateItem( BOARD_COMMIT* aCommit )
} }
case SHAPE_T::BEZIER: case SHAPE_T::BEZIER:
if( isModified( m_editPoints->Point( BEZIER_CURVE_START ) ) ) if( isModified( m_editPoints->Point( BEZIER_START ) ) )
shape->SetStart( m_editPoints->Point( BEZIER_CURVE_START ).GetPosition() ); shape->SetStart( m_editPoints->Point( BEZIER_START ).GetPosition() );
else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ) ) ) else if( isModified( m_editPoints->Point( BEZIER_CTRL_PT1 ) ) )
shape->SetBezierC1( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition() ); shape->SetBezierC1( m_editPoints->Point( BEZIER_CTRL_PT1 ).GetPosition() );
else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ) ) ) else if( isModified( m_editPoints->Point( BEZIER_CTRL_PT2 ) ) )
shape->SetBezierC2( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition() ); shape->SetBezierC2( m_editPoints->Point( BEZIER_CTRL_PT2 ).GetPosition() );
else if( isModified( m_editPoints->Point( BEZIER_CURVE_END ) ) ) else if( isModified( m_editPoints->Point( BEZIER_END ) ) )
shape->SetEnd( m_editPoints->Point( BEZIER_CURVE_END ).GetPosition() ); shape->SetEnd( m_editPoints->Point( BEZIER_END ).GetPosition() );
shape->RebuildBezierToSegmentsPointsList( shape->GetWidth() ); shape->RebuildBezierToSegmentsPointsList( shape->GetWidth() );
break; break;
@ -1981,10 +1981,10 @@ void PCB_POINT_EDITOR::updatePoints()
} }
case SHAPE_T::BEZIER: case SHAPE_T::BEZIER:
m_editPoints->Point( BEZIER_CURVE_START ).SetPosition( shape->GetStart() ); m_editPoints->Point( BEZIER_START ).SetPosition( shape->GetStart() );
m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).SetPosition( shape->GetBezierC1() ); m_editPoints->Point( BEZIER_CTRL_PT1 ).SetPosition( shape->GetBezierC1() );
m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).SetPosition( shape->GetBezierC2() ); m_editPoints->Point( BEZIER_CTRL_PT2 ).SetPosition( shape->GetBezierC2() );
m_editPoints->Point( BEZIER_CURVE_END ).SetPosition( shape->GetEnd() ); m_editPoints->Point( BEZIER_END ).SetPosition( shape->GetEnd() );
break; break;
default: // suppress warnings default: // suppress warnings

View File

@ -24,7 +24,6 @@
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <connection_graph.h> #include <connection_graph.h>
#include <lib_textbox.h>
#include <schematic.h> #include <schematic.h>
#include <sch_screen.h> #include <sch_screen.h>

View File

@ -44,8 +44,6 @@
#include <sch_sheet_pin.h> #include <sch_sheet_pin.h>
#include <sch_sheet.h> #include <sch_sheet.h>
#include <lib_shape.h>
#include <lib_textbox.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <erc_settings.h> #include <erc_settings.h>
@ -84,10 +82,10 @@ public:
case SCH_BUS_WIRE_ENTRY_T: return new SCH_BUS_WIRE_ENTRY(); 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_BUS_BUS_ENTRY_T: return new SCH_BUS_BUS_ENTRY();
case SCH_LINE_T: return new SCH_LINE(); 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_BITMAP_T: return new SCH_BITMAP();
case SCH_TEXT_T: return new SCH_TEXT( VECTOR2I( 0, 0 ), "test text" ); 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_TABLECELL_T: return new SCH_TABLECELL();
case SCH_TABLE_T: case SCH_TABLE_T:
{ {
@ -115,8 +113,6 @@ public:
"test aPin" ); "test aPin" );
case SCH_SHEET_T: return new SCH_SHEET(); 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 LIB_PIN_T: return new LIB_PIN( &m_symbol );
case SCHEMATIC_T: case SCHEMATIC_T:

View File

@ -29,7 +29,7 @@
#include <qa_utils/wx_utils/unit_test_utils.h> #include <qa_utils/wx_utils/unit_test_utils.h>
// Code under test // Code under test
#include <lib_shape.h> #include <sch_shape.h>
#include <lib_pin.h> #include <lib_pin.h>
#include "lib_field_test_utils.h" #include "lib_field_test_utils.h"
@ -409,22 +409,22 @@ BOOST_AUTO_TEST_CASE( Compare )
m_part_no_data.SetNormal(); m_part_no_data.SetNormal();
// Draw item list size comparison tests. // Draw item list size comparison tests.
testPart.AddDrawItem( new LIB_SHAPE( &testPart, SHAPE_T::RECTANGLE ) ); testPart.AddDrawItem( new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ) );
m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::RECTANGLE ) ); 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 ); 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 ); BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 );
testPart.RemoveDrawItem( &testPart.GetDrawItems()[LIB_SHAPE_T].front() ); testPart.RemoveDrawItem( &testPart.GetDrawItems()[SCH_SHAPE_T].front() );
m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::RECTANGLE ) ); 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 ); 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. // Draw item list contents comparison tests.
testPart.AddDrawItem( new LIB_SHAPE( &testPart, SHAPE_T::RECTANGLE ) ); testPart.AddDrawItem( new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ) );
m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::ARC ) ); 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 ); 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() );
testPart.RemoveDrawItem( &testPart.GetDrawItems()[LIB_SHAPE_T].front() ); testPart.RemoveDrawItem( &testPart.GetDrawItems()[SCH_SHAPE_T].front() );
m_part_no_data.AddDrawItem( new LIB_PIN( &m_part_no_data ) ); 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 ); 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() ); m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_PIN_T].front() );