2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-11-04 11:13:22 +00:00
|
|
|
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-11-27 15:18:30 +00:00
|
|
|
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
2023-02-09 17:18:56 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-13 19:56:32 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2022-08-27 17:23:43 +00:00
|
|
|
#include <base_units.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <lib_pin.h>
|
2020-04-12 23:09:17 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_editor/symbol_editor_settings.h>
|
2020-10-14 03:37:48 +00:00
|
|
|
#include <trigo.h>
|
2021-09-14 17:29:45 +00:00
|
|
|
#include <string_utils.h>
|
2020-05-03 23:55:31 +00:00
|
|
|
#include "sch_painter.h"
|
2022-09-20 18:41:16 +00:00
|
|
|
#include "plotters/plotter.h"
|
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2016-04-16 07:49:17 +00:00
|
|
|
// small margin in internal units between the pin text and the pin line
|
|
|
|
#define PIN_TEXT_MARGIN 4
|
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
const wxString LIB_PIN::GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType )
|
2010-03-04 09:32:51 +00:00
|
|
|
{
|
2015-04-02 18:51:47 +00:00
|
|
|
// These strings are the canonical name of the electrictal type
|
|
|
|
// Not translated, no space in name, only ASCII chars.
|
|
|
|
// to use when the string name must be known and well defined
|
2016-02-20 19:07:05 +00:00
|
|
|
// must have same order than enum ELECTRICAL_PINTYPE (see lib_pin.h)
|
2015-04-02 18:51:47 +00:00
|
|
|
static const wxChar* msgPinElectricType[] =
|
|
|
|
{
|
|
|
|
wxT( "input" ),
|
|
|
|
wxT( "output" ),
|
2021-01-21 21:46:03 +00:00
|
|
|
wxT( "bidirectional" ),
|
|
|
|
wxT( "tri_state" ),
|
2015-04-02 18:51:47 +00:00
|
|
|
wxT( "passive" ),
|
2021-01-22 13:04:43 +00:00
|
|
|
wxT( "free" ),
|
2021-01-21 21:46:03 +00:00
|
|
|
wxT( "unspecified" ),
|
2015-04-02 18:51:47 +00:00
|
|
|
wxT( "power_in" ),
|
|
|
|
wxT( "power_out" ),
|
2021-01-21 21:46:03 +00:00
|
|
|
wxT( "open_collector" ),
|
|
|
|
wxT( "open_emitter" ),
|
2021-01-22 13:04:43 +00:00
|
|
|
wxT( "no_connect" )
|
2015-04-02 18:51:47 +00:00
|
|
|
};
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
return msgPinElectricType[static_cast<int>( aType )];
|
2015-04-02 18:51:47 +00:00
|
|
|
}
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2014-05-13 19:24:12 +00:00
|
|
|
/// Utility for getting the size of the 'internal' pin decorators (as a radius)
|
|
|
|
// i.e. the clock symbols (falling clock is actually external but is of
|
|
|
|
// the same kind)
|
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
static int internalPinDecoSize( const RENDER_SETTINGS* aSettings, const LIB_PIN &aPin )
|
2014-05-13 19:24:12 +00:00
|
|
|
{
|
2020-12-20 18:18:54 +00:00
|
|
|
const KIGFX::SCH_RENDER_SETTINGS* settings = static_cast<const KIGFX::SCH_RENDER_SETTINGS*>( aSettings );
|
2020-05-03 23:55:31 +00:00
|
|
|
|
|
|
|
if( settings && settings->m_PinSymbolSize )
|
|
|
|
return settings->m_PinSymbolSize;
|
2017-08-19 05:41:48 +00:00
|
|
|
|
|
|
|
return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
|
2014-05-13 19:24:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Utility for getting the size of the 'external' pin decorators (as a radius)
|
|
|
|
// i.e. the negation circle, the polarity 'slopes' and the nonlogic
|
|
|
|
// marker
|
2020-12-20 18:18:54 +00:00
|
|
|
static int externalPinDecoSize( const RENDER_SETTINGS* aSettings, const LIB_PIN &aPin )
|
2014-05-13 19:24:12 +00:00
|
|
|
{
|
2020-12-20 18:18:54 +00:00
|
|
|
const KIGFX::SCH_RENDER_SETTINGS* settings = static_cast<const KIGFX::SCH_RENDER_SETTINGS*>( aSettings );
|
2020-05-03 23:55:31 +00:00
|
|
|
|
|
|
|
if( settings && settings->m_PinSymbolSize )
|
|
|
|
return settings->m_PinSymbolSize;
|
|
|
|
|
2014-05-13 19:24:12 +00:00
|
|
|
return aPin.GetNumberTextSize() / 2;
|
|
|
|
}
|
|
|
|
|
2020-08-03 21:12:29 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent ) :
|
2020-09-13 14:54:19 +00:00
|
|
|
LIB_ITEM( LIB_PIN_T, aParent ),
|
2023-07-27 03:46:15 +00:00
|
|
|
m_orientation( PIN_ORIENTATION::PIN_RIGHT ),
|
2020-11-07 21:55:18 +00:00
|
|
|
m_shape( GRAPHIC_PINSHAPE::LINE ),
|
|
|
|
m_type( ELECTRICAL_PINTYPE::PT_UNSPECIFIED ),
|
|
|
|
m_attributes( 0 )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2020-04-14 16:12:15 +00:00
|
|
|
// Use the application settings for pin sizes if exists.
|
|
|
|
// pgm can be nullptr when running a shared lib from a script, not from a kicad appl
|
|
|
|
PGM_BASE* pgm = PgmOrNull();
|
|
|
|
|
|
|
|
if( pgm )
|
|
|
|
{
|
2020-10-31 01:27:16 +00:00
|
|
|
auto* settings = pgm->GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
2022-09-16 23:42:20 +00:00
|
|
|
m_length = schIUScale.MilsToIU( settings->m_Defaults.pin_length );
|
|
|
|
m_numTextSize = schIUScale.MilsToIU( settings->m_Defaults.pin_num_size );
|
|
|
|
m_nameTextSize = schIUScale.MilsToIU( settings->m_Defaults.pin_name_size );
|
2020-04-14 16:12:15 +00:00
|
|
|
}
|
2020-10-31 01:27:16 +00:00
|
|
|
else // Use hardcoded eeschema defaults: symbol_editor settings are not existing.
|
2020-04-14 16:12:15 +00:00
|
|
|
{
|
2022-09-16 23:42:20 +00:00
|
|
|
m_length = schIUScale.MilsToIU( DEFAULT_PIN_LENGTH );
|
|
|
|
m_numTextSize = schIUScale.MilsToIU( DEFAULT_PINNUM_SIZE );
|
|
|
|
m_nameTextSize = schIUScale.MilsToIU( DEFAULT_PINNAME_SIZE );
|
2020-04-14 16:12:15 +00:00
|
|
|
}
|
2009-06-13 17:06:07 +00:00
|
|
|
}
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aNumber,
|
2023-07-27 03:46:15 +00:00
|
|
|
PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength,
|
|
|
|
int aNameTextSize, int aNumTextSize, int aConvert, const VECTOR2I& aPos,
|
|
|
|
int aUnit ) :
|
2020-09-13 14:54:19 +00:00
|
|
|
LIB_ITEM( LIB_PIN_T, aParent ),
|
|
|
|
m_position( aPos ),
|
|
|
|
m_length( aLength ),
|
|
|
|
m_orientation( aOrientation ),
|
|
|
|
m_shape( GRAPHIC_PINSHAPE::LINE ),
|
|
|
|
m_type( aPinType ),
|
|
|
|
m_attributes( 0 ),
|
|
|
|
m_numTextSize( aNumTextSize ),
|
|
|
|
m_nameTextSize( aNameTextSize )
|
|
|
|
{
|
|
|
|
SetName( aName );
|
|
|
|
SetNumber( aNumber );
|
|
|
|
SetUnit( aUnit );
|
|
|
|
SetConvert( aConvert );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool LIB_PIN::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
2009-06-13 17:06:07 +00:00
|
|
|
{
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I rect = GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE );
|
2011-05-05 17:45:35 +00:00
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
return rect.Inflate( aAccuracy ).Contains( aPosition );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
bool LIB_PIN::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
|
2020-07-13 17:41:30 +00:00
|
|
|
{
|
2020-11-14 18:11:28 +00:00
|
|
|
if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) )
|
2020-07-13 17:41:30 +00:00
|
|
|
return false;
|
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
BOX2I sel = aRect;
|
2020-07-13 17:41:30 +00:00
|
|
|
|
|
|
|
if ( aAccuracy )
|
|
|
|
sel.Inflate( aAccuracy );
|
|
|
|
|
|
|
|
if( aContained )
|
2022-07-23 22:26:03 +00:00
|
|
|
return sel.Contains( GetBoundingBox( false, false, false ) );
|
2020-07-13 17:41:30 +00:00
|
|
|
|
2022-07-23 22:26:03 +00:00
|
|
|
return sel.Intersects( GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE ) );
|
2020-07-13 17:41:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
int LIB_PIN::GetPenWidth() const
|
2009-06-30 17:57:27 +00:00
|
|
|
{
|
2021-08-17 10:59:04 +00:00
|
|
|
return 0;
|
2009-06-30 17:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-12 18:54:34 +00:00
|
|
|
wxString LIB_PIN::GetShownName() const
|
|
|
|
{
|
2022-09-22 17:04:17 +00:00
|
|
|
if( m_name == wxS( "~" ) )
|
2021-06-12 18:54:34 +00:00
|
|
|
return wxEmptyString;
|
|
|
|
else
|
|
|
|
return m_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I LIB_PIN::GetPinRoot() const
|
2021-09-24 15:19:21 +00:00
|
|
|
{
|
|
|
|
switch( m_orientation )
|
|
|
|
{
|
|
|
|
default:
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_RIGHT: return VECTOR2I( m_position.x + m_length, -( m_position.y ) );
|
|
|
|
case PIN_ORIENTATION::PIN_LEFT: return VECTOR2I( m_position.x - m_length, -( m_position.y ) );
|
|
|
|
case PIN_ORIENTATION::PIN_UP: return VECTOR2I( m_position.x, -( m_position.y + m_length ) );
|
|
|
|
case PIN_ORIENTATION::PIN_DOWN: return VECTOR2I( m_position.x, -( m_position.y - m_length ) );
|
2021-09-24 15:19:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_PIN::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
2022-09-16 16:20:36 +00:00
|
|
|
const TRANSFORM& aTransform, bool aDimmed )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL_OPTIONS* opts = (LIB_SYMBOL_OPTIONS*) aData;
|
2021-12-12 21:37:06 +00:00
|
|
|
bool drawHiddenFields = opts ? opts->draw_hidden_fields : false;
|
|
|
|
bool showPinType = opts ? opts->show_elec_type : false;
|
|
|
|
bool show_connect_point = opts ? opts->show_connect_point : false;
|
2020-04-17 20:11:12 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* part = GetParent();
|
2015-07-21 14:07:52 +00:00
|
|
|
|
2022-03-25 19:51:05 +00:00
|
|
|
wxCHECK( part && opts, /* void */ );
|
|
|
|
|
2021-06-14 18:00:08 +00:00
|
|
|
/* Calculate pin orient taking in account the symbol orientation. */
|
2023-07-27 03:46:15 +00:00
|
|
|
PIN_ORIENTATION orient = PinDrawOrient( aTransform );
|
2015-07-21 14:07:52 +00:00
|
|
|
|
|
|
|
/* Calculate the pin position */
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I pos1 = aTransform.TransformCoordinate( m_position ) + aOffset;
|
2015-07-21 14:07:52 +00:00
|
|
|
|
2020-04-17 20:11:12 +00:00
|
|
|
if( IsVisible() || drawHiddenFields )
|
2019-07-16 00:29:25 +00:00
|
|
|
{
|
2022-09-16 16:20:36 +00:00
|
|
|
printPinSymbol( aSettings, pos1, orient, aDimmed );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
printPinTexts( aSettings, pos1, orient, part->GetPinNameOffset(),
|
|
|
|
opts->force_draw_pin_text || part->ShowPinNumbers(),
|
2022-09-16 16:20:36 +00:00
|
|
|
opts->force_draw_pin_text || part->ShowPinNames(),
|
|
|
|
aDimmed );
|
2009-10-01 14:17:47 +00:00
|
|
|
|
2020-04-17 20:11:12 +00:00
|
|
|
if( showPinType )
|
2022-09-16 16:20:36 +00:00
|
|
|
printPinElectricalTypeName( aSettings, pos1, orient, aDimmed );
|
2021-05-27 18:44:06 +00:00
|
|
|
|
2021-12-12 21:37:06 +00:00
|
|
|
if( show_connect_point
|
|
|
|
&& m_type != ELECTRICAL_PINTYPE::PT_NC
|
|
|
|
&& m_type != ELECTRICAL_PINTYPE::PT_NIC )
|
2021-05-27 18:44:06 +00:00
|
|
|
{
|
|
|
|
wxDC* DC = aSettings->GetPrintDC();
|
|
|
|
COLOR4D color = aSettings->GetLayerColor( IsVisible() ? LAYER_PIN : LAYER_HIDDEN );
|
2022-09-16 16:20:36 +00:00
|
|
|
|
|
|
|
COLOR4D bg = aSettings->GetBackgroundColor();
|
|
|
|
|
|
|
|
if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
|
|
|
|
bg = COLOR4D::WHITE;
|
|
|
|
|
|
|
|
if( aDimmed )
|
2023-01-11 20:53:09 +00:00
|
|
|
{
|
|
|
|
color.Desaturate( );
|
2022-09-16 16:20:36 +00:00
|
|
|
color = color.Mix( bg, 0.5f );
|
2023-01-11 20:53:09 +00:00
|
|
|
}
|
2022-09-16 16:20:36 +00:00
|
|
|
|
2022-01-28 22:51:34 +00:00
|
|
|
GRCircle( DC, pos1, TARGET_PIN_RADIUS, 0, color );
|
2021-05-27 18:44:06 +00:00
|
|
|
}
|
2019-07-16 00:29:25 +00:00
|
|
|
}
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
void LIB_PIN::printPinSymbol( const RENDER_SETTINGS* aSettings, const VECTOR2I& aPos,
|
|
|
|
PIN_ORIENTATION aOrient, bool aDimmed )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
wxDC* DC = aSettings->GetPrintDC();
|
2019-04-04 22:49:49 +00:00
|
|
|
int MapX1, MapY1, x1, y1;
|
2021-08-17 10:59:04 +00:00
|
|
|
int width = GetEffectivePenWidth( aSettings );
|
2020-04-14 12:25:00 +00:00
|
|
|
int posX = aPos.x, posY = aPos.y, len = m_length;
|
|
|
|
COLOR4D color = aSettings->GetLayerColor( IsVisible() ? LAYER_PIN : LAYER_HIDDEN );
|
2022-09-16 16:20:36 +00:00
|
|
|
COLOR4D bg = aSettings->GetBackgroundColor();
|
|
|
|
|
|
|
|
if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
|
|
|
|
bg = COLOR4D::WHITE;
|
|
|
|
|
|
|
|
if( !IsVisible() )
|
|
|
|
bg = aSettings->GetLayerColor( LAYER_HIDDEN );
|
|
|
|
|
|
|
|
if( aDimmed )
|
2023-01-11 20:53:09 +00:00
|
|
|
{
|
|
|
|
color.Desaturate( );
|
2022-09-16 16:20:36 +00:00
|
|
|
color = color.Mix( bg, 0.5f );
|
2023-01-11 20:53:09 +00:00
|
|
|
}
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
MapX1 = MapY1 = 0;
|
2011-04-18 20:22:17 +00:00
|
|
|
x1 = posX;
|
|
|
|
y1 = posY;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
switch( aOrient )
|
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_UP: y1 = posY - len; MapY1 = 1; break;
|
|
|
|
case PIN_ORIENTATION::PIN_DOWN: y1 = posY + len; MapY1 = -1; break;
|
|
|
|
case PIN_ORIENTATION::PIN_LEFT: x1 = posX - len; MapX1 = 1; break;
|
|
|
|
case PIN_ORIENTATION::PIN_RIGHT: x1 = posX + len; MapX1 = -1; break;
|
2015-07-21 14:07:52 +00:00
|
|
|
}
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( m_shape == GRAPHIC_PINSHAPE::INVERTED || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
const int radius = externalPinDecoSize( aSettings, *this );
|
2022-01-28 22:51:34 +00:00
|
|
|
GRCircle( DC, VECTOR2I( MapX1 * radius + x1, MapY1 * radius + y1 ), radius, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2019-04-04 22:49:49 +00:00
|
|
|
GRMoveTo( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 );
|
2022-01-28 22:51:34 +00:00
|
|
|
GRLineTo( DC, posX, posY, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GRMoveTo( x1, y1 );
|
2022-01-28 22:51:34 +00:00
|
|
|
GRLineTo( DC, posX, posY, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
2019-10-06 10:59:18 +00:00
|
|
|
// Draw the clock shape (>)inside the symbol
|
2020-11-07 21:55:18 +00:00
|
|
|
if( m_shape == GRAPHIC_PINSHAPE::CLOCK
|
|
|
|
|| m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK
|
2020-01-18 20:51:28 +00:00
|
|
|
|| m_shape == GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK
|
|
|
|
|| m_shape == GRAPHIC_PINSHAPE::CLOCK_LOW )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
const int clock_size = internalPinDecoSize( aSettings, *this );
|
2008-09-13 18:59:57 +00:00
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
2014-05-13 19:24:12 +00:00
|
|
|
GRMoveTo( x1, y1 + clock_size );
|
2022-01-28 22:51:34 +00:00
|
|
|
GRLineTo( DC, x1 - MapX1 * clock_size * 2, y1, width, color );
|
|
|
|
GRLineTo( DC, x1, y1 - clock_size, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
2014-05-13 19:24:12 +00:00
|
|
|
GRMoveTo( x1 + clock_size, y1 );
|
2022-01-28 22:51:34 +00:00
|
|
|
GRLineTo( DC, x1, y1 - MapY1 * clock_size * 2, width, color );
|
|
|
|
GRLineTo( DC, x1 - clock_size, y1, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-06 10:59:18 +00:00
|
|
|
// Draw the active low (or H to L active transition)
|
2020-11-07 21:55:18 +00:00
|
|
|
if( m_shape == GRAPHIC_PINSHAPE::INPUT_LOW
|
|
|
|
|| m_shape == GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK
|
2020-01-18 20:51:28 +00:00
|
|
|
|| m_shape == GRAPHIC_PINSHAPE::CLOCK_LOW )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
const int deco_size = externalPinDecoSize( aSettings, *this );
|
2008-09-13 18:59:57 +00:00
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
GRMoveTo( x1 + MapX1 * deco_size * 2, y1 );
|
2022-01-28 22:51:34 +00:00
|
|
|
GRLineTo( DC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width, color );
|
|
|
|
GRLineTo( DC, x1, y1, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
GRMoveTo( x1, y1 + MapY1 * deco_size * 2 );
|
2022-01-28 22:51:34 +00:00
|
|
|
GRLineTo( DC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width, color );
|
|
|
|
GRLineTo( DC, x1, y1, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( m_shape == GRAPHIC_PINSHAPE::OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
const int deco_size = externalPinDecoSize( aSettings, *this );
|
2008-09-13 18:59:57 +00:00
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
GRMoveTo( x1, y1 - deco_size * 2 );
|
2022-01-28 22:51:34 +00:00
|
|
|
GRLineTo( DC, x1 + MapX1 * deco_size * 2, y1, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
GRMoveTo( x1 - deco_size * 2, y1 );
|
2022-01-28 22:51:34 +00:00
|
|
|
GRLineTo( DC, x1, y1 + MapY1 * deco_size * 2, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-18 20:51:28 +00:00
|
|
|
else if( m_shape == GRAPHIC_PINSHAPE::NONLOGIC ) /* NonLogic pin symbol */
|
2010-09-24 16:00:40 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
const int deco_size = externalPinDecoSize( aSettings, *this );
|
2019-04-08 14:59:52 +00:00
|
|
|
GRMoveTo( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size );
|
2022-01-28 22:51:34 +00:00
|
|
|
GRLineTo( DC, x1 + (MapX1 + MapY1) * deco_size, y1 + ( MapY1 - MapX1 ) * deco_size, width,
|
|
|
|
color );
|
2019-04-08 14:59:52 +00:00
|
|
|
GRMoveTo( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size );
|
2022-01-28 22:51:34 +00:00
|
|
|
GRLineTo( DC, x1 + (MapX1 - MapY1) * deco_size, y1 + ( MapY1 + MapX1 ) * deco_size, width,
|
|
|
|
color );
|
2010-09-24 16:00:40 +00:00
|
|
|
}
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( m_type == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
|
2010-10-22 07:52:55 +00:00
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
const int deco_size = TARGET_PIN_RADIUS;
|
2022-01-28 22:51:34 +00:00
|
|
|
GRLine( DC, posX - deco_size, posY - deco_size, posX + deco_size, posY + deco_size, width,
|
|
|
|
color );
|
|
|
|
GRLine( DC, posX + deco_size, posY - deco_size, posX - deco_size, posY + deco_size, width,
|
|
|
|
color );
|
2010-10-22 07:52:55 +00:00
|
|
|
}
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos,
|
|
|
|
PIN_ORIENTATION aPinOrient, int aTextInside, bool aDrawPinNum,
|
|
|
|
bool aDrawPinName, bool aDimmed )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2020-11-07 21:55:18 +00:00
|
|
|
if( !aDrawPinName && !aDrawPinNum )
|
2015-07-13 18:36:06 +00:00
|
|
|
return;
|
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
KIFONT::FONT* font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), false, false );
|
2023-08-30 09:35:17 +00:00
|
|
|
wxString name = GetShownName();
|
|
|
|
wxString number = GetShownNumber();
|
|
|
|
VECTOR2I nameSize( m_nameTextSize, m_nameTextSize );
|
|
|
|
VECTOR2I numSize( m_numTextSize, m_numTextSize );
|
|
|
|
int nameWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_nameTextSize, true ),
|
|
|
|
aSettings->GetDefaultPenWidth() );
|
|
|
|
int numWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_numTextSize, true ),
|
|
|
|
aSettings->GetDefaultPenWidth() );
|
|
|
|
int name_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + nameWidth;
|
|
|
|
int num_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + numWidth;
|
2016-04-16 07:49:17 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
/* Get the num and name colors */
|
2022-09-16 16:20:36 +00:00
|
|
|
COLOR4D nameColor = aSettings->GetLayerColor( IsVisible() ? LAYER_PINNAM : LAYER_HIDDEN );
|
|
|
|
COLOR4D numColor = aSettings->GetLayerColor( IsVisible() ? LAYER_PINNUM : LAYER_HIDDEN );
|
|
|
|
COLOR4D bg = aSettings->GetBackgroundColor();
|
|
|
|
|
|
|
|
if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
|
|
|
|
bg = COLOR4D::WHITE;
|
|
|
|
|
|
|
|
if( !IsVisible() )
|
|
|
|
bg = aSettings->GetLayerColor( LAYER_HIDDEN );
|
|
|
|
|
|
|
|
if( aDimmed )
|
|
|
|
{
|
2023-01-11 20:53:09 +00:00
|
|
|
nameColor.Desaturate();
|
|
|
|
numColor.Desaturate();
|
2022-09-16 16:20:36 +00:00
|
|
|
nameColor = nameColor.Mix( bg, 0.5f );
|
|
|
|
numColor = numColor.Mix( bg, 0.5f );
|
|
|
|
}
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
int x1 = aPinPos.x;
|
|
|
|
int y1 = aPinPos.y;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
switch( aPinOrient )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_UP: y1 -= m_length; break;
|
|
|
|
case PIN_ORIENTATION::PIN_DOWN: y1 += m_length; break;
|
|
|
|
case PIN_ORIENTATION::PIN_LEFT: x1 -= m_length; break;
|
|
|
|
case PIN_ORIENTATION::PIN_RIGHT: x1 += m_length; break;
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
2022-11-02 14:49:17 +00:00
|
|
|
if( name.IsEmpty() || m_nameTextSize == 0 )
|
2020-11-07 21:55:18 +00:00
|
|
|
aDrawPinName = false;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2022-11-02 14:49:17 +00:00
|
|
|
if( number.IsEmpty() || m_numTextSize == 0 )
|
2021-06-12 18:54:34 +00:00
|
|
|
aDrawPinNum = false;
|
|
|
|
|
2023-08-30 09:35:17 +00:00
|
|
|
auto printName =
|
|
|
|
[&]( int x, int y, const EDA_ANGLE& angle, enum GR_TEXT_H_ALIGN_T hAlign,
|
|
|
|
enum GR_TEXT_V_ALIGN_T vAlign )
|
|
|
|
{
|
|
|
|
GRPrintText( aSettings->GetPrintDC(), VECTOR2I( x, y ), nameColor, name, angle,
|
|
|
|
nameSize, hAlign, vAlign, nameWidth, false, false, font, GetFontMetrics() );
|
|
|
|
};
|
|
|
|
|
|
|
|
auto printNum =
|
|
|
|
[&]( int x, int y, const EDA_ANGLE& angle, enum GR_TEXT_H_ALIGN_T hAlign,
|
|
|
|
enum GR_TEXT_V_ALIGN_T vAlign )
|
|
|
|
{
|
|
|
|
GRPrintText( aSettings->GetPrintDC(), VECTOR2I( x, y ), numColor, number, angle,
|
|
|
|
numSize, hAlign, vAlign, numWidth, false, false, font, GetFontMetrics() );
|
|
|
|
};
|
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aTextInside ) // Draw the text inside, but the pin numbers outside.
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
|
|
|
|
|| ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
// It is an horizontal line
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinName )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
if( aPinOrient == PIN_ORIENTATION::PIN_RIGHT )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
printName( x1 + aTextInside, y1, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
else // Orient == PIN_LEFT
|
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
printName( x1 - aTextInside, y1, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinNum )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
printNum( ( x1 + aPinPos.x ) / 2, y1 - num_offset, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Its a vertical line. */
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
// Text is drawn from bottom to top (i.e. to negative value for Y axis)
|
2023-07-27 03:46:15 +00:00
|
|
|
if( aPinOrient == PIN_ORIENTATION::PIN_DOWN )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinName )
|
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
printName( x1, y1 + aTextInside, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER );
|
2020-11-07 21:55:18 +00:00
|
|
|
}
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinNum )
|
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
printNum( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2020-11-07 21:55:18 +00:00
|
|
|
}
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
|
|
|
else /* PIN_UP */
|
|
|
|
{
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinName )
|
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
printName( x1, y1 - aTextInside, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER );
|
2020-11-07 21:55:18 +00:00
|
|
|
}
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinNum )
|
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
printNum( x1 - num_offset, ( y1 + aPinPos.y) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2020-11-07 21:55:18 +00:00
|
|
|
}
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /**** Draw num & text pin outside ****/
|
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
|
|
|
|
|| ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
/* Its an horizontal line. */
|
2023-08-30 09:35:17 +00:00
|
|
|
if( aDrawPinName && aDrawPinNum )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
printName( ( x1 + aPinPos.x ) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
|
|
|
|
|
|
|
printNum( ( x1 + aPinPos.x ) / 2, y1 + num_offset, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
2023-08-30 09:35:17 +00:00
|
|
|
else if( aDrawPinName )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
printName( ( x1 + aPinPos.x ) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
|
|
|
}
|
|
|
|
else if( aDrawPinNum )
|
|
|
|
{
|
|
|
|
printNum( ( x1 + aPinPos.x ) / 2, y1 - num_offset, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Its a vertical line. */
|
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
if( aDrawPinName && aDrawPinNum )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
printName( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2023-08-30 09:35:17 +00:00
|
|
|
printNum( x1 + num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP );
|
|
|
|
}
|
|
|
|
else if( aDrawPinName )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
printName( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
|
|
|
}
|
|
|
|
else if( aDrawPinNum )
|
|
|
|
{
|
|
|
|
printNum( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECTOR2I& aPosition,
|
2023-07-27 03:46:15 +00:00
|
|
|
PIN_ORIENTATION aOrientation, bool aDimmed )
|
2016-11-04 11:13:22 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
wxDC* DC = aSettings->GetPrintDC();
|
2019-04-04 22:49:49 +00:00
|
|
|
wxString typeName = GetElectricalTypeName();
|
2016-11-05 10:39:22 +00:00
|
|
|
|
|
|
|
// Use a reasonable (small) size to draw the text
|
2020-04-14 12:25:00 +00:00
|
|
|
int textSize = ( m_nameTextSize * 3 ) / 4;
|
2016-11-04 11:13:22 +00:00
|
|
|
|
2022-09-16 11:33:56 +00:00
|
|
|
#define ETXT_MAX_SIZE schIUScale.mmToIU( 0.7 )
|
2020-11-07 21:55:18 +00:00
|
|
|
|
2019-04-04 22:49:49 +00:00
|
|
|
if( textSize > ETXT_MAX_SIZE )
|
|
|
|
textSize = ETXT_MAX_SIZE;
|
2016-11-04 11:13:22 +00:00
|
|
|
|
|
|
|
// Use a reasonable pen size to draw the text
|
2019-04-04 22:49:49 +00:00
|
|
|
int pensize = textSize/6;
|
2016-11-04 11:13:22 +00:00
|
|
|
|
2016-11-05 10:39:22 +00:00
|
|
|
// Get a suitable color
|
2022-07-07 04:51:23 +00:00
|
|
|
COLOR4D color = aSettings->GetLayerColor( IsVisible() ? LAYER_PRIVATE_NOTES : LAYER_HIDDEN );
|
2022-09-16 16:20:36 +00:00
|
|
|
COLOR4D bg = aSettings->GetBackgroundColor();
|
|
|
|
|
|
|
|
if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
|
|
|
|
bg = COLOR4D::WHITE;
|
|
|
|
|
|
|
|
if( !IsVisible() )
|
|
|
|
bg = aSettings->GetLayerColor( LAYER_HIDDEN );
|
|
|
|
|
|
|
|
if( aDimmed )
|
2023-01-11 20:53:09 +00:00
|
|
|
{
|
|
|
|
color.Desaturate( );
|
2022-09-16 16:20:36 +00:00
|
|
|
color = color.Mix( bg, 0.5f );
|
2023-01-11 20:53:09 +00:00
|
|
|
}
|
2016-11-04 11:13:22 +00:00
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
VECTOR2I txtpos = aPosition;
|
2022-09-16 11:33:56 +00:00
|
|
|
int offset = schIUScale.mmToIU( 0.4 );
|
2021-12-28 22:13:54 +00:00
|
|
|
GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_LEFT;
|
2022-10-22 20:32:10 +00:00
|
|
|
EDA_ANGLE orient = ANGLE_HORIZONTAL;
|
|
|
|
KIFONT::FONT* font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), false, false );
|
2016-11-04 11:13:22 +00:00
|
|
|
|
|
|
|
switch( aOrientation )
|
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_UP:
|
2016-11-04 11:13:22 +00:00
|
|
|
txtpos.y += offset;
|
2022-01-13 12:29:46 +00:00
|
|
|
orient = ANGLE_VERTICAL;
|
2021-12-28 22:13:54 +00:00
|
|
|
hjustify = GR_TEXT_H_ALIGN_RIGHT;
|
2016-11-04 11:13:22 +00:00
|
|
|
break;
|
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_DOWN:
|
2016-11-04 11:13:22 +00:00
|
|
|
txtpos.y -= offset;
|
2022-01-13 12:29:46 +00:00
|
|
|
orient = ANGLE_VERTICAL;
|
2016-11-04 11:13:22 +00:00
|
|
|
break;
|
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_LEFT:
|
2016-11-04 11:13:22 +00:00
|
|
|
txtpos.x += offset;
|
|
|
|
break;
|
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_RIGHT:
|
2016-11-04 11:13:22 +00:00
|
|
|
txtpos.x -= offset;
|
2021-12-28 22:13:54 +00:00
|
|
|
hjustify = GR_TEXT_H_ALIGN_RIGHT;
|
2016-11-04 11:13:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
GRPrintText( DC, txtpos, color, typeName, orient, VECTOR2I( textSize, textSize ), hjustify,
|
2023-08-06 19:20:53 +00:00
|
|
|
GR_TEXT_V_ALIGN_CENTER, pensize, false, false, font, GetFontMetrics() );
|
2016-11-04 11:13:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
void LIB_PIN::PlotSymbol( PLOTTER *aPlotter, const VECTOR2I &aPosition,
|
|
|
|
PIN_ORIENTATION aOrientation, bool aDimmed ) const
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
int MapX1, MapY1, x1, y1;
|
|
|
|
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( LAYER_PIN );
|
2022-09-16 16:20:36 +00:00
|
|
|
COLOR4D bg = aPlotter->RenderSettings()->GetBackgroundColor();
|
2021-08-17 10:59:04 +00:00
|
|
|
int penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
|
|
|
|
bg = COLOR4D::WHITE;
|
|
|
|
|
|
|
|
if( aDimmed )
|
2023-01-11 20:53:09 +00:00
|
|
|
{
|
|
|
|
color.Desaturate( );
|
2022-09-16 16:20:36 +00:00
|
|
|
color = color.Mix( bg, 0.5f );
|
2023-01-11 20:53:09 +00:00
|
|
|
}
|
2022-09-16 16:20:36 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->SetColor( color );
|
2020-04-14 12:25:00 +00:00
|
|
|
aPlotter->SetCurrentLineWidth( penWidth );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
|
|
|
MapX1 = MapY1 = 0;
|
|
|
|
x1 = aPosition.x; y1 = aPosition.y;
|
|
|
|
|
|
|
|
switch( aOrientation )
|
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_UP: y1 = aPosition.y - m_length; MapY1 = 1; break;
|
|
|
|
case PIN_ORIENTATION::PIN_DOWN: y1 = aPosition.y + m_length; MapY1 = -1; break;
|
|
|
|
case PIN_ORIENTATION::PIN_LEFT: x1 = aPosition.x - m_length; MapX1 = 1; break;
|
|
|
|
case PIN_ORIENTATION::PIN_RIGHT: x1 = aPosition.x + m_length; MapX1 = -1; break;
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( m_shape == GRAPHIC_PINSHAPE::INVERTED || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK )
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
const int radius = externalPinDecoSize( aPlotter->RenderSettings(), *this );
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->Circle( VECTOR2I( MapX1 * radius + x1, MapY1 * radius + y1 ), radius * 2,
|
2021-07-18 23:08:54 +00:00
|
|
|
FILL_T::NO_FILL, penWidth );
|
2019-04-04 22:49:49 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ) );
|
2014-05-13 19:24:12 +00:00
|
|
|
aPlotter->FinishTo( aPosition );
|
|
|
|
}
|
2020-01-18 20:51:28 +00:00
|
|
|
else if( m_shape == GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK )
|
2014-05-13 19:24:12 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
const int deco_size = internalPinDecoSize( aPlotter->RenderSettings(), *this );
|
2014-05-13 19:24:12 +00:00
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( x1, y1 + deco_size ) );
|
|
|
|
aPlotter->LineTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( x1, y1 - deco_size ) );
|
2014-05-13 19:24:12 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( x1 + deco_size, y1 ) );
|
|
|
|
aPlotter->LineTo( VECTOR2I( x1, y1 + MapY1 * deco_size * 2 ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( x1 - deco_size, y1 ) );
|
2014-05-13 19:24:12 +00:00
|
|
|
}
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 ) );
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->FinishTo( aPosition );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( x1, y1 ) );
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->FinishTo( aPosition );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
if( m_shape == GRAPHIC_PINSHAPE::CLOCK
|
|
|
|
|| m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK
|
2020-01-18 20:51:28 +00:00
|
|
|
|| m_shape == GRAPHIC_PINSHAPE::CLOCK_LOW )
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
const int deco_size = internalPinDecoSize( aPlotter->RenderSettings(), *this );
|
2011-06-17 13:24:22 +00:00
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( x1, y1 + deco_size ) );
|
|
|
|
aPlotter->LineTo( VECTOR2I( x1 - MapX1 * deco_size * 2, y1 ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( x1, y1 - deco_size ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( x1 + deco_size, y1 ) );
|
|
|
|
aPlotter->LineTo( VECTOR2I( x1, y1 - MapY1 * deco_size * 2 ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( x1 - deco_size, y1 ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( m_shape == GRAPHIC_PINSHAPE::INPUT_LOW
|
|
|
|
|| m_shape == GRAPHIC_PINSHAPE::CLOCK_LOW ) /* IEEE symbol "Active Low Input" */
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
const int deco_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
|
2015-07-13 18:36:06 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 ) );
|
|
|
|
aPlotter->LineTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 - deco_size * 2 ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( x1, y1 ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( x1, y1 + MapY1 * deco_size * 2 ) );
|
|
|
|
aPlotter->LineTo( VECTOR2I( x1 - deco_size * 2, y1 + MapY1 * deco_size * 2 ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( x1, y1 ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( m_shape == GRAPHIC_PINSHAPE::OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
const int symbol_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
|
2015-07-13 18:36:06 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( x1, y1 - symbol_size * 2 ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( x1 + MapX1 * symbol_size * 2, y1 ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( x1 - symbol_size * 2, y1 ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( x1, y1 + MapY1 * symbol_size * 2 ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-18 20:51:28 +00:00
|
|
|
else if( m_shape == GRAPHIC_PINSHAPE::NONLOGIC ) /* NonLogic pin symbol */
|
2014-05-13 19:24:12 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
const int deco_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( x1 - ( MapX1 + MapY1 ) * deco_size,
|
|
|
|
y1 - ( MapY1 - MapX1 ) * deco_size ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( x1 + ( MapX1 + MapY1 ) * deco_size,
|
|
|
|
y1 + ( MapY1 - MapX1 ) * deco_size ) );
|
|
|
|
aPlotter->MoveTo( VECTOR2I( x1 - ( MapX1 - MapY1 ) * deco_size,
|
|
|
|
y1 - ( MapY1 + MapX1 ) * deco_size ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( x1 + ( MapX1 - MapY1 ) * deco_size,
|
|
|
|
y1 + ( MapY1 + MapX1 ) * deco_size ) );
|
2014-05-13 19:24:12 +00:00
|
|
|
}
|
2020-11-07 21:55:18 +00:00
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( m_type == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
|
2014-05-13 19:24:12 +00:00
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
const int deco_size = TARGET_PIN_RADIUS;
|
2014-05-13 19:24:12 +00:00
|
|
|
const int ex1 = aPosition.x;
|
|
|
|
const int ey1 = aPosition.y;
|
2022-01-01 06:04:08 +00:00
|
|
|
aPlotter->MoveTo( VECTOR2I( ex1 - deco_size, ey1 - deco_size ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( ex1 + deco_size, ey1 + deco_size ) );
|
|
|
|
aPlotter->MoveTo( VECTOR2I( ex1 + deco_size, ey1 - deco_size ) );
|
|
|
|
aPlotter->FinishTo( VECTOR2I( ex1 - deco_size, ey1 + deco_size ) );
|
2014-05-13 19:24:12 +00:00
|
|
|
}
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
|
|
|
|
void LIB_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient,
|
|
|
|
int aTextInside, bool aDrawPinNum, bool aDrawPinName,
|
|
|
|
bool aDimmed ) const
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2022-10-22 20:32:10 +00:00
|
|
|
RENDER_SETTINGS* settings = aPlotter->RenderSettings();
|
|
|
|
KIFONT::FONT* font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), false, false );
|
|
|
|
wxString name = GetShownName();
|
|
|
|
wxString number = GetShownNumber();
|
2021-06-12 18:54:34 +00:00
|
|
|
|
2022-11-02 14:49:17 +00:00
|
|
|
if( name.IsEmpty() || m_nameTextSize == 0 )
|
2020-11-07 21:55:18 +00:00
|
|
|
aDrawPinName = false;
|
2015-07-13 18:36:06 +00:00
|
|
|
|
2022-11-02 14:49:17 +00:00
|
|
|
if( number.IsEmpty() || m_numTextSize == 0 )
|
2020-11-07 21:55:18 +00:00
|
|
|
aDrawPinNum = false;
|
2015-07-13 18:36:06 +00:00
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
if( !aDrawPinNum && !aDrawPinName )
|
2015-07-13 18:36:06 +00:00
|
|
|
return;
|
|
|
|
|
2022-09-07 10:05:23 +00:00
|
|
|
int namePenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_nameTextSize, true ),
|
2022-10-22 20:32:10 +00:00
|
|
|
settings->GetDefaultPenWidth() );
|
2022-09-07 10:05:23 +00:00
|
|
|
int numPenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_numTextSize, true ),
|
2022-10-22 20:32:10 +00:00
|
|
|
settings->GetDefaultPenWidth() );
|
2022-09-16 23:42:20 +00:00
|
|
|
int name_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + namePenWidth;
|
|
|
|
int num_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + numPenWidth;
|
2016-04-16 07:49:17 +00:00
|
|
|
|
2008-09-13 19:06:31 +00:00
|
|
|
/* Get the num and name colors */
|
2022-10-22 20:32:10 +00:00
|
|
|
COLOR4D nameColor = settings->GetLayerColor( LAYER_PINNAM );
|
|
|
|
COLOR4D numColor = settings->GetLayerColor( LAYER_PINNUM );
|
|
|
|
COLOR4D bg = settings->GetBackgroundColor();
|
2022-09-16 16:20:36 +00:00
|
|
|
|
|
|
|
if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
|
|
|
|
bg = COLOR4D::WHITE;
|
|
|
|
|
|
|
|
if( aDimmed )
|
|
|
|
{
|
2023-01-11 20:53:09 +00:00
|
|
|
nameColor.Desaturate( );
|
|
|
|
numColor.Desaturate( );
|
2022-09-16 16:20:36 +00:00
|
|
|
nameColor = nameColor.Mix( bg, 0.5f );
|
|
|
|
numColor = numColor.Mix( bg, 0.5f );
|
|
|
|
}
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
int x1 = aPinPos.x;
|
|
|
|
int y1 = aPinPos.y;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
switch( aPinOrient )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_UP: y1 -= m_length; break;
|
|
|
|
case PIN_ORIENTATION::PIN_DOWN: y1 += m_length; break;
|
|
|
|
case PIN_ORIENTATION::PIN_LEFT: x1 -= m_length; break;
|
|
|
|
case PIN_ORIENTATION::PIN_RIGHT: x1 += m_length; break;
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
|
2023-08-30 10:09:11 +00:00
|
|
|
auto plotName =
|
|
|
|
[&]( int x, int y, const EDA_ANGLE& angle, GR_TEXT_H_ALIGN_T hJustify,
|
|
|
|
GR_TEXT_V_ALIGN_T vJustify )
|
2022-02-10 20:32:02 +00:00
|
|
|
{
|
2023-02-24 08:44:25 +00:00
|
|
|
TEXT_ATTRIBUTES attrs;
|
2023-08-30 10:09:11 +00:00
|
|
|
attrs.m_StrokeWidth = namePenWidth;
|
2023-02-24 08:44:25 +00:00
|
|
|
attrs.m_Angle = angle;
|
2023-08-30 10:09:11 +00:00
|
|
|
attrs.m_Size = VECTOR2I( m_nameTextSize, m_nameTextSize );
|
2023-02-24 08:44:25 +00:00
|
|
|
attrs.m_Halign = hJustify;
|
|
|
|
attrs.m_Valign = vJustify;
|
|
|
|
attrs.m_Multiline = false;
|
|
|
|
|
2023-08-30 10:09:11 +00:00
|
|
|
aPlotter->PlotText( VECTOR2I( x, y ), nameColor, name, attrs, font, GetFontMetrics() );
|
2023-08-30 09:35:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto plotNum =
|
2023-08-30 10:09:11 +00:00
|
|
|
[&]( int x, int y, const EDA_ANGLE& angle, GR_TEXT_H_ALIGN_T hJustify,
|
2023-08-30 09:35:17 +00:00
|
|
|
GR_TEXT_V_ALIGN_T vJustify )
|
|
|
|
{
|
2023-08-30 10:09:11 +00:00
|
|
|
TEXT_ATTRIBUTES attrs;
|
|
|
|
attrs.m_StrokeWidth = numPenWidth;
|
|
|
|
attrs.m_Angle = angle;
|
|
|
|
attrs.m_Size = VECTOR2I( m_numTextSize, m_numTextSize );
|
|
|
|
attrs.m_Halign = hJustify;
|
|
|
|
attrs.m_Valign = vJustify;
|
|
|
|
attrs.m_Multiline = false;
|
|
|
|
|
|
|
|
aPlotter->PlotText( VECTOR2I( x, y ), numColor, number, attrs, font, GetFontMetrics() );
|
2023-08-30 09:35:17 +00:00
|
|
|
};
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/* Draw the text inside, but the pin numbers outside. */
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aTextInside )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
|
|
|
|
|| ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) ) /* Its an horizontal line. */
|
2009-04-06 10:56:17 +00:00
|
|
|
{
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinName )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
if( aPinOrient == PIN_ORIENTATION::PIN_RIGHT )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotName( x1 + aTextInside, y1, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
else // orient == PIN_LEFT
|
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotName( x1 - aTextInside, y1, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER );
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
2009-09-25 13:59:42 +00:00
|
|
|
}
|
2022-02-10 20:32:02 +00:00
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinNum )
|
2009-09-25 13:59:42 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotNum( ( x1 + aPinPos.x) / 2, y1 - num_offset, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Its a vertical line. */
|
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
if( aPinOrient == PIN_ORIENTATION::PIN_DOWN )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinName )
|
2022-02-10 20:32:02 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotName( x1, y1 + aTextInside, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER );
|
2022-02-10 20:32:02 +00:00
|
|
|
}
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinNum )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotNum( x1 - num_offset, ( y1 + aPinPos.y) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* PIN_UP */
|
|
|
|
{
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinName )
|
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotName( x1, y1 - aTextInside, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER );
|
2020-11-07 21:55:18 +00:00
|
|
|
}
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2020-11-07 21:55:18 +00:00
|
|
|
if( aDrawPinNum )
|
2009-05-12 12:12:34 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotNum( x1 - num_offset, ( y1 + aPinPos.y) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Draw num & text pin outside */
|
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
|
|
|
|
|| ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
/* Its an horizontal line. */
|
2023-08-29 10:07:17 +00:00
|
|
|
if( aDrawPinName && aDrawPinNum )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotName( ( x1 + aPinPos.x) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2023-08-30 09:35:17 +00:00
|
|
|
plotNum( ( x1 + aPinPos.x) / 2, y1 + num_offset, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
2023-08-29 10:07:17 +00:00
|
|
|
else if( aDrawPinName )
|
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotName( ( x1 + aPinPos.x) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2023-08-29 10:07:17 +00:00
|
|
|
}
|
|
|
|
else if( aDrawPinNum )
|
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotNum( ( x1 + aPinPos.x) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2023-08-29 10:07:17 +00:00
|
|
|
}
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
2023-08-29 10:07:17 +00:00
|
|
|
else
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2023-08-29 10:07:17 +00:00
|
|
|
/* Its a vertical line. */
|
|
|
|
if( aDrawPinName && aDrawPinNum )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotName( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2023-08-30 09:35:17 +00:00
|
|
|
plotNum( x1 + num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP );
|
2023-08-29 10:07:17 +00:00
|
|
|
}
|
|
|
|
else if( aDrawPinName )
|
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotName( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2023-08-29 10:07:17 +00:00
|
|
|
}
|
|
|
|
else if( aDrawPinNum )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2023-08-30 09:35:17 +00:00
|
|
|
plotNum( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
PIN_ORIENTATION LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
PIN_ORIENTATION orient;
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I end; // position of pin end starting at 0,0 according to its orientation, length = 1
|
2008-09-14 04:27:22 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
switch( m_orientation )
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_UP: end.y = 1; break;
|
|
|
|
case PIN_ORIENTATION::PIN_DOWN: end.y = -1; break;
|
|
|
|
case PIN_ORIENTATION::PIN_LEFT: end.x = -1; break;
|
|
|
|
case PIN_ORIENTATION::PIN_RIGHT: end.x = 1; break;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
2021-06-14 18:00:08 +00:00
|
|
|
// = pos of end point, according to the symbol orientation.
|
2011-04-18 20:22:17 +00:00
|
|
|
end = aTransform.TransformCoordinate( end );
|
2023-07-27 03:46:15 +00:00
|
|
|
orient = PIN_ORIENTATION::PIN_UP;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
if( end.x == 0 )
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
if( end.y > 0 )
|
2023-07-27 03:46:15 +00:00
|
|
|
orient = PIN_ORIENTATION::PIN_DOWN;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
orient = PIN_ORIENTATION::PIN_RIGHT;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
if( end.x < 0 )
|
2023-07-27 03:46:15 +00:00
|
|
|
orient = PIN_ORIENTATION::PIN_LEFT;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return orient;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* LIB_PIN::Clone() const
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
return new LIB_PIN( *this );
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
2022-03-03 12:20:30 +00:00
|
|
|
int LIB_PIN::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2020-02-13 13:39:52 +00:00
|
|
|
wxASSERT( aOther.Type() == LIB_PIN_T );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2020-02-13 13:39:52 +00:00
|
|
|
int retv = LIB_ITEM::compare( aOther, aCompareFlags );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2020-02-13 13:39:52 +00:00
|
|
|
if( retv )
|
|
|
|
return retv;
|
|
|
|
|
|
|
|
const LIB_PIN* tmp = (LIB_PIN*) &aOther;
|
|
|
|
|
|
|
|
// When comparing units, we do not compare the part numbers. If everything else is
|
|
|
|
// identical, then we can just renumber the parts for the inherited symbol.
|
|
|
|
if( !( aCompareFlags & COMPARE_FLAGS::UNIT ) && m_number != tmp->m_number )
|
2017-08-10 15:00:28 +00:00
|
|
|
return m_number.Cmp( tmp->m_number );
|
2009-10-01 14:17:47 +00:00
|
|
|
|
2022-09-09 17:30:19 +00:00
|
|
|
int result = m_name.Cmp( tmp->m_name );
|
2009-10-01 14:17:47 +00:00
|
|
|
|
2020-02-13 13:39:52 +00:00
|
|
|
if( result )
|
2009-10-01 14:17:47 +00:00
|
|
|
return result;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_position.x != tmp->m_position.x )
|
|
|
|
return m_position.x - tmp->m_position.x;
|
2009-10-01 14:17:47 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_position.y != tmp->m_position.y )
|
|
|
|
return m_position.y - tmp->m_position.y;
|
2009-10-01 14:17:47 +00:00
|
|
|
|
2020-02-13 13:39:52 +00:00
|
|
|
if( m_length != tmp->m_length )
|
|
|
|
return m_length - tmp->m_length;
|
|
|
|
|
|
|
|
if( m_orientation != tmp->m_orientation )
|
2023-07-27 03:46:15 +00:00
|
|
|
return static_cast<int>( m_orientation ) - static_cast<int>( tmp->m_orientation );
|
2020-02-13 13:39:52 +00:00
|
|
|
|
|
|
|
if( m_shape != tmp->m_shape )
|
|
|
|
return static_cast<int>( m_shape ) - static_cast<int>( tmp->m_shape );
|
|
|
|
|
|
|
|
if( m_type != tmp->m_type )
|
|
|
|
return static_cast<int>( m_type ) - static_cast<int>( tmp->m_type );
|
|
|
|
|
|
|
|
if( m_attributes != tmp->m_attributes )
|
|
|
|
return m_attributes - tmp->m_attributes;
|
|
|
|
|
|
|
|
if( m_numTextSize != tmp->m_numTextSize )
|
|
|
|
return m_numTextSize - tmp->m_numTextSize;
|
|
|
|
|
|
|
|
if( m_nameTextSize != tmp->m_nameTextSize )
|
|
|
|
return m_nameTextSize - tmp->m_nameTextSize;
|
|
|
|
|
2021-01-28 11:15:47 +00:00
|
|
|
if( m_alternates.size() != tmp->m_alternates.size() )
|
|
|
|
return m_alternates.size() - tmp->m_alternates.size();
|
|
|
|
|
|
|
|
auto lhsItem = m_alternates.begin();
|
|
|
|
auto rhsItem = tmp->m_alternates.begin();
|
|
|
|
|
|
|
|
while( lhsItem != m_alternates.end() )
|
|
|
|
{
|
|
|
|
const ALT& lhsAlt = lhsItem->second;
|
|
|
|
const ALT& rhsAlt = rhsItem->second;
|
|
|
|
|
|
|
|
retv = lhsAlt.m_Name.Cmp( rhsAlt.m_Name );
|
|
|
|
|
|
|
|
if( retv )
|
|
|
|
return retv;
|
|
|
|
|
|
|
|
if( lhsAlt.m_Type != rhsAlt.m_Type )
|
|
|
|
return static_cast<int>( lhsAlt.m_Type ) - static_cast<int>( rhsAlt.m_Type );
|
|
|
|
|
|
|
|
if( lhsAlt.m_Shape != rhsAlt.m_Shape )
|
|
|
|
return static_cast<int>( lhsAlt.m_Shape ) - static_cast<int>( rhsAlt.m_Shape );
|
|
|
|
|
|
|
|
++lhsItem;
|
|
|
|
++rhsItem;
|
|
|
|
}
|
|
|
|
|
2009-10-01 14:17:47 +00:00
|
|
|
return 0;
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
2022-07-11 17:55:54 +00:00
|
|
|
void LIB_PIN::ChangeLength( int aLength )
|
|
|
|
{
|
|
|
|
int lengthChange = m_length - aLength;
|
|
|
|
int offsetX = 0;
|
|
|
|
int offsetY = 0;
|
|
|
|
|
|
|
|
switch( m_orientation )
|
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_RIGHT:
|
2022-07-11 17:55:54 +00:00
|
|
|
offsetX = lengthChange;
|
|
|
|
break;
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_LEFT:
|
2022-07-11 17:55:54 +00:00
|
|
|
offsetX = -1 * lengthChange;
|
|
|
|
break;
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_UP:
|
2022-07-11 17:55:54 +00:00
|
|
|
offsetY = lengthChange;
|
|
|
|
break;
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_DOWN:
|
2022-07-11 17:55:54 +00:00
|
|
|
offsetY = -1 * lengthChange;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
VECTOR2I offset = VECTOR2I( offsetX, offsetY );
|
2022-07-11 17:55:54 +00:00
|
|
|
Offset( offset );
|
|
|
|
|
|
|
|
m_length = aLength;
|
|
|
|
}
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_PIN::Offset( const VECTOR2I& aOffset )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2012-02-27 23:02:08 +00:00
|
|
|
m_position += aOffset;
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_PIN::MoveTo( const VECTOR2I& aNewPosition )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2023-06-25 14:57:33 +00:00
|
|
|
m_position = aNewPosition;
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_PIN::MirrorHorizontal( const VECTOR2I& aCenter )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2020-11-07 21:55:18 +00:00
|
|
|
m_position.x -= aCenter.x;
|
2010-12-07 16:10:42 +00:00
|
|
|
m_position.x *= -1;
|
2020-11-07 21:55:18 +00:00
|
|
|
m_position.x += aCenter.x;
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
if( m_orientation == PIN_ORIENTATION::PIN_RIGHT )
|
|
|
|
m_orientation = PIN_ORIENTATION::PIN_LEFT;
|
|
|
|
else if( m_orientation == PIN_ORIENTATION::PIN_LEFT )
|
|
|
|
m_orientation = PIN_ORIENTATION::PIN_RIGHT;
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
2020-07-13 17:41:30 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_PIN::MirrorVertical( const VECTOR2I& aCenter )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
2020-11-07 21:55:18 +00:00
|
|
|
m_position.y -= aCenter.y;
|
2011-05-20 18:29:35 +00:00
|
|
|
m_position.y *= -1;
|
2020-11-07 21:55:18 +00:00
|
|
|
m_position.y += aCenter.y;
|
2011-05-20 18:29:35 +00:00
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
if( m_orientation == PIN_ORIENTATION::PIN_UP )
|
|
|
|
m_orientation = PIN_ORIENTATION::PIN_DOWN;
|
|
|
|
else if( m_orientation == PIN_ORIENTATION::PIN_DOWN )
|
|
|
|
m_orientation = PIN_ORIENTATION::PIN_UP;
|
2011-05-20 18:29:35 +00:00
|
|
|
}
|
|
|
|
|
2020-07-13 17:41:30 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_PIN::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
2022-01-16 21:15:20 +00:00
|
|
|
EDA_ANGLE rot_angle = aRotateCCW ? -ANGLE_90 : ANGLE_90;
|
2011-05-20 18:29:35 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
RotatePoint( m_position, aCenter, rot_angle );
|
2011-05-22 19:08:34 +00:00
|
|
|
|
|
|
|
if( aRotateCCW )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
2011-05-22 19:08:34 +00:00
|
|
|
switch( m_orientation )
|
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_RIGHT: m_orientation = PIN_ORIENTATION::PIN_UP; break;
|
|
|
|
case PIN_ORIENTATION::PIN_UP: m_orientation = PIN_ORIENTATION::PIN_LEFT; break;
|
|
|
|
case PIN_ORIENTATION::PIN_LEFT: m_orientation = PIN_ORIENTATION::PIN_DOWN; break;
|
|
|
|
case PIN_ORIENTATION::PIN_DOWN: m_orientation = PIN_ORIENTATION::PIN_RIGHT; break;
|
2011-05-22 19:08:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( m_orientation )
|
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_RIGHT: m_orientation = PIN_ORIENTATION::PIN_DOWN; break;
|
|
|
|
case PIN_ORIENTATION::PIN_UP: m_orientation = PIN_ORIENTATION::PIN_RIGHT; break;
|
|
|
|
case PIN_ORIENTATION::PIN_LEFT: m_orientation = PIN_ORIENTATION::PIN_UP; break;
|
|
|
|
case PIN_ORIENTATION::PIN_DOWN: m_orientation = PIN_ORIENTATION::PIN_LEFT; break;
|
2011-05-22 19:08:34 +00:00
|
|
|
}
|
2011-05-20 18:29:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2022-02-10 19:49:25 +00:00
|
|
|
void LIB_PIN::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,
|
2022-09-16 16:20:36 +00:00
|
|
|
const TRANSFORM& aTransform, bool aDimmed ) const
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2022-02-10 19:49:25 +00:00
|
|
|
if( !IsVisible() || aBackground )
|
2009-10-05 17:52:41 +00:00
|
|
|
return;
|
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
PIN_ORIENTATION orient = PinDrawOrient( aTransform );
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I pos = aTransform.TransformCoordinate( m_position ) + aOffset;
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
PlotSymbol( aPlotter, pos, orient, aDimmed );
|
2020-11-07 21:55:18 +00:00
|
|
|
PlotPinTexts( aPlotter, pos, orient, GetParent()->GetPinNameOffset(),
|
2022-09-16 16:20:36 +00:00
|
|
|
GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(),
|
|
|
|
aDimmed );
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-26 23:22:32 +00:00
|
|
|
void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2020-04-24 13:36:10 +00:00
|
|
|
LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2021-09-28 13:28:35 +00:00
|
|
|
aList.emplace_back( _( "Name" ), UnescapeString( GetShownName() ) );
|
|
|
|
aList.emplace_back( _( "Number" ), GetShownNumber() );
|
|
|
|
aList.emplace_back( _( "Type" ), ElectricalPinTypeGetText( m_type ) );
|
|
|
|
aList.emplace_back( _( "Style" ), PinShapeGetText( m_shape ) );
|
2015-01-18 11:49:32 +00:00
|
|
|
|
2021-09-28 13:28:35 +00:00
|
|
|
aList.emplace_back( _( "Style" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
// Display pin length
|
2022-09-19 09:25:20 +00:00
|
|
|
aList.emplace_back( _( "Length" ), aFrame->MessageTextFromValue( m_length, true ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
aList.emplace_back( _( "Orientation" ), PinOrientationName( m_orientation ) );
|
2016-10-18 16:59:26 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I pinpos = GetPosition();
|
2021-09-28 13:28:35 +00:00
|
|
|
pinpos.y = -pinpos.y; // Display coords are top to bottom; lib item coords are bottom to top
|
2016-10-18 16:59:26 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
aList.emplace_back( _( "Pos X" ), aFrame->MessageTextFromValue( pinpos.x, true ) );
|
|
|
|
aList.emplace_back( _( "Pos Y" ), aFrame->MessageTextFromValue( pinpos.y, true ) );
|
2023-04-06 09:08:01 +00:00
|
|
|
|
|
|
|
#if 0 // For debug purpose only
|
|
|
|
aList.emplace_back( _( "Flags" ), wxString::Format( "%8.8X", (long)GetFlags() ) );
|
|
|
|
#endif
|
2016-10-18 16:59:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
|
2022-07-23 22:26:03 +00:00
|
|
|
const BOX2I LIB_PIN::ViewBBox() const
|
|
|
|
{
|
2022-08-31 12:56:58 +00:00
|
|
|
return GetBoundingBox( false, true, true );
|
2022-07-23 22:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-06 17:45:17 +00:00
|
|
|
void LIB_PIN::ViewGetLayers( int aLayers[], int& aCount ) const
|
|
|
|
{
|
2023-09-05 19:11:13 +00:00
|
|
|
aCount = 6;
|
2022-02-06 17:45:17 +00:00
|
|
|
aLayers[0] = LAYER_DANGLING; // We don't really show dangling vs non-dangling (since there
|
|
|
|
// are no connections in the symbol editor), but it's still
|
|
|
|
// a good visual indication of which end of the pin is which.
|
|
|
|
aLayers[1] = LAYER_DEVICE;
|
|
|
|
aLayers[2] = LAYER_SELECTION_SHADOWS;
|
2023-02-09 17:18:56 +00:00
|
|
|
aLayers[3] = LAYER_OP_CURRENTS;
|
2023-09-05 19:11:13 +00:00
|
|
|
aLayers[4] = LAYER_PINNAM;
|
|
|
|
aLayers[5] = LAYER_PINNUM;
|
2022-02-06 17:45:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-27 15:30:12 +00:00
|
|
|
void LIB_PIN::validateExtentsCache( KIFONT::FONT* aFont, int aSize, const wxString& aText,
|
|
|
|
EXTENTS_CACHE* aCache ) const
|
|
|
|
{
|
|
|
|
if( aCache->m_Font == aFont
|
|
|
|
&& aCache->m_FontSize == aSize
|
|
|
|
&& aCache->m_Extents != VECTOR2I() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aCache->m_Font = aFont;
|
|
|
|
aCache->m_FontSize = aSize;
|
|
|
|
|
|
|
|
// Get maximum height including ascenders and descenders
|
|
|
|
static wxString hText = wxT( "Xg" );
|
|
|
|
|
|
|
|
VECTOR2D fontSize( aSize, aSize );
|
|
|
|
int penWidth = GetPenSizeForNormal( aSize );
|
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
aCache->m_Extents.x = aFont->StringBoundaryLimits( aText, fontSize, penWidth, false, false,
|
|
|
|
GetFontMetrics() ).x;
|
|
|
|
aCache->m_Extents.y = aFont->StringBoundaryLimits( hText, fontSize, penWidth, false, false,
|
|
|
|
GetFontMetrics() ).y;
|
2023-05-27 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I LIB_PIN::GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber,
|
|
|
|
bool aIncludeElectricalType ) const
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2022-09-27 10:09:43 +00:00
|
|
|
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
|
|
|
KIFONT::FONT* font = KIFONT::FONT::GetFont( cfg->m_Appearance.default_font );
|
2021-12-02 21:33:47 +00:00
|
|
|
|
2023-05-27 15:30:12 +00:00
|
|
|
BOX2I bbox;
|
|
|
|
VECTOR2I begin;
|
|
|
|
VECTOR2I end;
|
|
|
|
int pinNameOffset = 0;
|
|
|
|
int nameTextLength = 0;
|
|
|
|
int nameTextHeight = 0;
|
|
|
|
int numberTextLength = 0;
|
|
|
|
int numberTextHeight = 0;
|
|
|
|
int typeTextLength = 0;
|
|
|
|
bool includeName = aIncludeNameAndNumber && !GetShownName().IsEmpty();
|
|
|
|
bool includeNumber = aIncludeNameAndNumber && !GetShownNumber().IsEmpty();
|
|
|
|
bool includeType = aIncludeElectricalType;
|
|
|
|
int minsizeV = TARGET_PIN_RADIUS;
|
2011-05-25 10:42:56 +00:00
|
|
|
|
2022-07-23 22:26:03 +00:00
|
|
|
if( !aIncludeInvisiblePins && !IsVisible() )
|
|
|
|
{
|
|
|
|
includeName = false;
|
|
|
|
includeType = false;
|
|
|
|
}
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2020-05-09 13:09:50 +00:00
|
|
|
if( GetParent() )
|
2011-04-27 19:44:32 +00:00
|
|
|
{
|
2020-05-09 13:09:50 +00:00
|
|
|
if( GetParent()->ShowPinNames() )
|
2023-02-07 15:06:20 +00:00
|
|
|
pinNameOffset = GetParent()->GetPinNameOffset();
|
2011-04-27 19:44:32 +00:00
|
|
|
else
|
2022-07-23 22:26:03 +00:00
|
|
|
includeName = false;
|
2011-05-05 17:45:35 +00:00
|
|
|
|
2020-05-09 13:09:50 +00:00
|
|
|
if( !GetParent()->ShowPinNumbers() )
|
2022-07-23 22:26:03 +00:00
|
|
|
includeNumber = false;
|
2020-07-13 17:41:30 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 22:26:03 +00:00
|
|
|
if( includeNumber )
|
2021-12-02 21:33:47 +00:00
|
|
|
{
|
2023-05-27 15:30:12 +00:00
|
|
|
validateExtentsCache( font, m_numTextSize, GetShownNumber(), &m_numExtentsCache );
|
|
|
|
numberTextLength = m_numExtentsCache.m_Extents.x;
|
|
|
|
numberTextHeight = m_numExtentsCache.m_Extents.y;
|
2021-12-02 21:33:47 +00:00
|
|
|
}
|
2011-04-27 19:44:32 +00:00
|
|
|
|
2022-07-23 22:26:03 +00:00
|
|
|
if( includeName )
|
2011-04-27 19:44:32 +00:00
|
|
|
{
|
2023-05-27 15:30:12 +00:00
|
|
|
validateExtentsCache( font, m_nameTextSize, GetShownName(), &m_nameExtentsCache );
|
|
|
|
nameTextLength = m_nameExtentsCache.m_Extents.x + pinNameOffset;
|
|
|
|
nameTextHeight = m_nameExtentsCache.m_Extents.y + schIUScale.MilsToIU( PIN_TEXT_MARGIN );
|
2011-04-27 19:44:32 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 22:26:03 +00:00
|
|
|
if( includeType )
|
|
|
|
{
|
2022-09-16 11:33:56 +00:00
|
|
|
double fontSize = std::max( m_nameTextSize * 3 / 4, schIUScale.mmToIU( 0.7 ) );
|
2023-02-07 15:06:20 +00:00
|
|
|
double stroke = fontSize / 8.0;
|
2022-07-23 22:26:03 +00:00
|
|
|
VECTOR2I typeTextSize = font->StringBoundaryLimits( GetElectricalTypeName(),
|
|
|
|
VECTOR2D( fontSize, fontSize ),
|
2023-08-06 19:20:53 +00:00
|
|
|
KiROUND( stroke ), false, false,
|
|
|
|
GetFontMetrics() );
|
2022-07-23 22:26:03 +00:00
|
|
|
|
2022-09-16 23:42:20 +00:00
|
|
|
typeTextLength = typeTextSize.x + schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + TARGET_PIN_RADIUS;
|
2022-07-23 22:26:03 +00:00
|
|
|
minsizeV = std::max( minsizeV, typeTextSize.y / 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// First, calculate boundary box corners position
|
|
|
|
if( m_shape == GRAPHIC_PINSHAPE::INVERTED || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK )
|
|
|
|
minsizeV = std::max( TARGET_PIN_RADIUS, externalPinDecoSize( nullptr, *this ) );
|
|
|
|
|
2023-02-07 15:06:20 +00:00
|
|
|
// Attempt to mimic SCH_PAINTER's algorithm without actually knowing the schematic text
|
|
|
|
// offset ratio.
|
2023-05-27 15:30:12 +00:00
|
|
|
int PIN_TEXT_OFFSET = schIUScale.MilsToIU( 24 );
|
2022-07-23 22:26:03 +00:00
|
|
|
|
2023-02-07 15:06:20 +00:00
|
|
|
// Calculate topLeft & bottomRight corner positions for the default pin orientation (PIN_RIGHT)
|
|
|
|
if( pinNameOffset || !includeName )
|
2011-05-25 10:42:56 +00:00
|
|
|
{
|
2023-02-07 15:06:20 +00:00
|
|
|
// pin name is inside the body (or invisible)
|
|
|
|
// pin number is above the line
|
|
|
|
begin.y = std::max( minsizeV, numberTextHeight + PIN_TEXT_OFFSET );
|
2023-08-06 19:20:53 +00:00
|
|
|
begin.x = std::min( -typeTextLength, m_length - ( numberTextLength / 2 ) );
|
2023-02-07 15:06:20 +00:00
|
|
|
|
2021-09-19 10:05:58 +00:00
|
|
|
end.x = m_length + nameTextLength;
|
2012-09-22 11:19:37 +00:00
|
|
|
end.y = std::min( -minsizeV, -nameTextHeight / 2 );
|
2011-05-25 10:42:56 +00:00
|
|
|
}
|
2023-02-07 15:06:20 +00:00
|
|
|
else
|
2011-05-25 10:42:56 +00:00
|
|
|
{
|
2023-02-07 15:06:20 +00:00
|
|
|
// pin name is above pin line
|
|
|
|
// pin number is below line
|
|
|
|
begin.y = std::max( minsizeV, nameTextHeight + PIN_TEXT_OFFSET );
|
2023-05-31 11:51:56 +00:00
|
|
|
begin.x = -typeTextLength;
|
|
|
|
begin.x = std::min( begin.x, ( m_length - numberTextLength ) / 2 );
|
|
|
|
begin.x = std::min( begin.x, ( m_length - nameTextLength ) / 2 );
|
2023-02-07 15:06:20 +00:00
|
|
|
|
2023-05-31 11:51:56 +00:00
|
|
|
end.x = m_length;
|
|
|
|
end.x = std::max( end.x, ( m_length + nameTextLength ) / 2 );
|
|
|
|
end.x = std::max( end.x, ( m_length + numberTextLength ) / 2 );
|
2023-02-07 15:06:20 +00:00
|
|
|
end.y = std::min( -minsizeV, -numberTextHeight - PIN_TEXT_OFFSET );
|
2011-05-25 10:42:56 +00:00
|
|
|
}
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
// Now, calculate boundary box corners position for the actual pin orientation
|
2023-07-27 03:46:15 +00:00
|
|
|
PIN_ORIENTATION orient = PinDrawOrient( DefaultTransform );
|
2011-05-25 10:42:56 +00:00
|
|
|
|
|
|
|
/* Calculate the pin position */
|
|
|
|
switch( orient )
|
2011-04-18 20:22:17 +00:00
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_UP:
|
2011-04-18 20:22:17 +00:00
|
|
|
// Pin is rotated and texts positions are mirrored
|
2022-01-16 21:15:20 +00:00
|
|
|
RotatePoint( begin, VECTOR2I( 0, 0 ), -ANGLE_90 );
|
|
|
|
RotatePoint( end, VECTOR2I( 0, 0 ), -ANGLE_90 );
|
2011-04-18 20:22:17 +00:00
|
|
|
break;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_DOWN:
|
2022-01-16 21:15:20 +00:00
|
|
|
RotatePoint( begin, VECTOR2I( 0, 0 ), ANGLE_90 );
|
|
|
|
RotatePoint( end, VECTOR2I( 0, 0 ), ANGLE_90 );
|
2015-06-26 13:41:56 +00:00
|
|
|
begin.x = -begin.x;
|
|
|
|
end.x = -end.x;
|
2011-04-18 20:22:17 +00:00
|
|
|
break;
|
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_LEFT:
|
2015-06-26 13:41:56 +00:00
|
|
|
begin.x = -begin.x;
|
|
|
|
end.x = -end.x;
|
2011-04-18 20:22:17 +00:00
|
|
|
break;
|
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_RIGHT:
|
2011-04-18 20:22:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-06-18 14:56:08 +00:00
|
|
|
begin += m_position;
|
|
|
|
end += m_position;
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2011-05-05 17:45:35 +00:00
|
|
|
bbox.SetOrigin( begin );
|
|
|
|
bbox.SetEnd( end );
|
2011-04-18 20:22:17 +00:00
|
|
|
bbox.Normalize();
|
2020-04-14 12:25:00 +00:00
|
|
|
bbox.Inflate( ( GetPenWidth() / 2 ) + 1 );
|
2015-06-18 14:56:08 +00:00
|
|
|
|
|
|
|
// Draw Y axis is reversed in schematic:
|
|
|
|
bbox.RevertYAxis();
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
return bbox;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS LIB_PIN::GetMenuImage() const
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
2020-07-29 15:03:40 +00:00
|
|
|
return ElectricalPinTypeGetBitmap( m_type );
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString LIB_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
2023-02-19 03:40:07 +00:00
|
|
|
// This code previously checked "m_name.IsEmpty()" to choose the correct
|
2023-01-09 00:51:46 +00:00
|
|
|
// formatting path, but that check fails if the pin is called "~" which is
|
2023-02-19 03:40:07 +00:00
|
|
|
// the default for an empty pin name. Instead we get the final display string
|
2023-01-09 00:51:46 +00:00
|
|
|
// that will be shown and check if it's empty.
|
|
|
|
|
|
|
|
wxString shownName = UnescapeString( GetShownName() );
|
|
|
|
|
2022-10-24 10:34:47 +00:00
|
|
|
if( IsVisible() )
|
2020-09-19 16:12:00 +00:00
|
|
|
{
|
2023-01-09 00:51:46 +00:00
|
|
|
if ( !shownName.IsEmpty() )
|
2022-10-24 10:34:47 +00:00
|
|
|
{
|
|
|
|
return wxString::Format( _( "Pin %s [%s, %s, %s]" ),
|
|
|
|
GetShownNumber(),
|
2023-01-09 00:51:46 +00:00
|
|
|
shownName,
|
2022-10-24 10:34:47 +00:00
|
|
|
GetElectricalTypeName(),
|
|
|
|
PinShapeGetText( m_shape ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return wxString::Format( _( "Pin %s [%s, %s]" ),
|
|
|
|
GetShownNumber(),
|
|
|
|
GetElectricalTypeName(),
|
|
|
|
PinShapeGetText( m_shape ) );
|
|
|
|
}
|
2020-09-19 16:12:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-09 00:51:46 +00:00
|
|
|
if( !shownName.IsEmpty() )
|
2022-10-24 10:34:47 +00:00
|
|
|
{
|
|
|
|
return wxString::Format( _( "Hidden pin %s [%s, %s, %s]" ),
|
|
|
|
GetShownNumber(),
|
2023-01-09 00:51:46 +00:00
|
|
|
shownName,
|
2022-10-24 10:34:47 +00:00
|
|
|
GetElectricalTypeName(),
|
|
|
|
PinShapeGetText( m_shape ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return wxString::Format( _( "Hidden pin %s [%s, %s]" ),
|
|
|
|
GetShownNumber(),
|
|
|
|
GetElectricalTypeName(),
|
|
|
|
PinShapeGetText( m_shape ) );
|
|
|
|
}
|
2020-09-19 16:12:00 +00:00
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2023-04-08 19:28:45 +00:00
|
|
|
std::ostream& LIB_PIN::operator<<( std::ostream& aStream )
|
|
|
|
{
|
|
|
|
aStream << "LIB_PIN:" << std::endl
|
|
|
|
<< " Name: \"" << m_name << "\"" << std::endl
|
|
|
|
<< " Number: \"" << m_number << "\"" << std::endl
|
|
|
|
<< " Position: " << m_position << std::endl
|
|
|
|
<< " Length: " << m_length << std::endl
|
|
|
|
<< " Orientation: " << PinOrientationName( m_orientation ) << std::endl
|
|
|
|
<< " Shape: " << PinShapeGetText( m_shape ) << std::endl
|
|
|
|
<< " Type: " << ElectricalPinTypeGetText( m_type ) << std::endl
|
|
|
|
<< " Name Text Size: " << m_nameTextSize << std::endl
|
|
|
|
<< " Number Text Size: " << m_numTextSize << std::endl;
|
|
|
|
|
|
|
|
return aStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-03 05:11:05 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
void LIB_PIN::Show( int nestLevel, std::ostream& os ) const
|
2010-08-03 05:11:05 +00:00
|
|
|
{
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
|
2017-08-10 15:00:28 +00:00
|
|
|
<< " num=\"" << m_number.mb_str()
|
2010-08-03 05:11:05 +00:00
|
|
|
<< '"' << "/>\n";
|
|
|
|
|
|
|
|
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_PIN::CalcEdit( const VECTOR2I& aPosition )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
if( IsMoving() )
|
2019-05-09 07:57:07 +00:00
|
|
|
MoveTo( aPosition );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
2023-07-26 22:32:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
static struct LIB_PIN_DESC
|
|
|
|
{
|
|
|
|
LIB_PIN_DESC()
|
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
auto& pinTypeEnum = ENUM_MAP<ELECTRICAL_PINTYPE>::Instance();
|
|
|
|
|
|
|
|
if( pinTypeEnum.Choices().GetCount() == 0 )
|
|
|
|
{
|
|
|
|
pinTypeEnum.Map( ELECTRICAL_PINTYPE::PT_INPUT, _HKI( "Input" ) )
|
|
|
|
.Map( ELECTRICAL_PINTYPE::PT_OUTPUT, _HKI( "Output" ) )
|
|
|
|
.Map( ELECTRICAL_PINTYPE::PT_BIDI, _HKI( "Bidirectional" ) )
|
|
|
|
.Map( ELECTRICAL_PINTYPE::PT_TRISTATE, _HKI( "Tri-state" ) )
|
|
|
|
.Map( ELECTRICAL_PINTYPE::PT_PASSIVE, _HKI( "Passive" ) )
|
|
|
|
.Map( ELECTRICAL_PINTYPE::PT_NIC, _HKI( "Free" ) )
|
|
|
|
.Map( ELECTRICAL_PINTYPE::PT_UNSPECIFIED, _HKI( "Unspecified" ) )
|
|
|
|
.Map( ELECTRICAL_PINTYPE::PT_POWER_IN, _HKI( "Power input" ) )
|
|
|
|
.Map( ELECTRICAL_PINTYPE::PT_POWER_OUT, _HKI( "Power output" ) )
|
|
|
|
.Map( ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR, _HKI( "Open collector" ) )
|
|
|
|
.Map( ELECTRICAL_PINTYPE::PT_OPENEMITTER, _HKI( "Open emitter" ) )
|
|
|
|
.Map( ELECTRICAL_PINTYPE::PT_NC, _HKI( "Unconnected" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
auto& pinShapeEnum = ENUM_MAP<GRAPHIC_PINSHAPE>::Instance();
|
|
|
|
|
|
|
|
if( pinShapeEnum.Choices().GetCount() == 0 )
|
|
|
|
{
|
|
|
|
pinShapeEnum.Map( GRAPHIC_PINSHAPE::LINE, _HKI( "Line" ) )
|
|
|
|
.Map( GRAPHIC_PINSHAPE::INVERTED, _HKI( "Inverted" ) )
|
|
|
|
.Map( GRAPHIC_PINSHAPE::CLOCK, _HKI( "Clock" ) )
|
|
|
|
.Map( GRAPHIC_PINSHAPE::INVERTED_CLOCK, _HKI( "Inverted clock" ) )
|
|
|
|
.Map( GRAPHIC_PINSHAPE::INPUT_LOW, _HKI( "Input low" ) )
|
|
|
|
.Map( GRAPHIC_PINSHAPE::CLOCK_LOW, _HKI( "Clock low" ) )
|
|
|
|
.Map( GRAPHIC_PINSHAPE::OUTPUT_LOW, _HKI( "Output low" ) )
|
|
|
|
.Map( GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK, _HKI( "Falling edge clock" ) )
|
|
|
|
.Map( GRAPHIC_PINSHAPE::NONLOGIC, _HKI( "NonLogic" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
auto& orientationEnum = ENUM_MAP<PIN_ORIENTATION>::Instance();
|
|
|
|
|
|
|
|
if( orientationEnum.Choices().GetCount() == 0 )
|
|
|
|
{
|
|
|
|
orientationEnum.Map( PIN_ORIENTATION::PIN_RIGHT, _( "Right" ) )
|
|
|
|
.Map( PIN_ORIENTATION::PIN_LEFT, _( "Left" ) )
|
|
|
|
.Map( PIN_ORIENTATION::PIN_UP, _( "Up" ) )
|
|
|
|
.Map( PIN_ORIENTATION::PIN_DOWN, _( "Down" ) );
|
|
|
|
}
|
|
|
|
|
2023-07-26 22:32:06 +00:00
|
|
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
|
|
|
REGISTER_TYPE( LIB_PIN );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( LIB_PIN ), TYPE_HASH( SCH_ITEM ) );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, wxString>( _HKI( "Pin Name" ),
|
2023-07-27 03:46:15 +00:00
|
|
|
&LIB_PIN::SetName, &LIB_PIN::GetName ) );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Name Text Size" ),
|
|
|
|
&LIB_PIN::SetNameTextSize, &LIB_PIN::GetNameTextSize, PROPERTY_DISPLAY::PT_SIZE ) );
|
2023-07-26 22:32:06 +00:00
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, wxString>( _HKI( "Pin Number" ),
|
2023-07-27 03:46:15 +00:00
|
|
|
&LIB_PIN::SetNumber, &LIB_PIN::GetNumber ) );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Number Text Size" ),
|
|
|
|
&LIB_PIN::SetNumberTextSize, &LIB_PIN::GetNumberTextSize,
|
|
|
|
PROPERTY_DISPLAY::PT_SIZE ) );
|
2023-07-26 22:32:06 +00:00
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Length" ),
|
2023-07-27 03:46:15 +00:00
|
|
|
&LIB_PIN::SetLength, &LIB_PIN::GetLength, PROPERTY_DISPLAY::PT_SIZE ) );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<LIB_PIN,
|
|
|
|
ELECTRICAL_PINTYPE>( _HKI( "Electrical Type" ),
|
|
|
|
&LIB_PIN::SetType, &LIB_PIN::GetType ) );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<LIB_PIN, GRAPHIC_PINSHAPE>( _HKI( "Graphic Style" ),
|
|
|
|
&LIB_PIN::SetShape, &LIB_PIN::GetShape ) );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Position X" ),
|
|
|
|
&LIB_PIN::SetX, &LIB_PIN::GetX, PROPERTY_DISPLAY::PT_COORD ) );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Position Y" ),
|
|
|
|
&LIB_PIN::SetY, &LIB_PIN::GetY, PROPERTY_DISPLAY::PT_COORD ) );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<LIB_PIN, PIN_ORIENTATION>( _HKI( "Orientation" ),
|
|
|
|
&LIB_PIN::SetOrientation, &LIB_PIN::GetOrientation ) );
|
2023-07-26 22:32:06 +00:00
|
|
|
}
|
|
|
|
} _LIB_PIN_DESC;
|
2023-07-27 03:46:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
ENUM_TO_WXANY( PIN_ORIENTATION )
|
|
|
|
ENUM_TO_WXANY( GRAPHIC_PINSHAPE )
|
|
|
|
ENUM_TO_WXANY( ELECTRICAL_PINTYPE )
|