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>
|
2019-04-04 22:49:49 +00:00
|
|
|
* Copyright (C) 1992-2019 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file lib_pin.cpp
|
|
|
|
*/
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2017-12-01 16:49:19 +00:00
|
|
|
#include <wx/tokenzr.h>
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.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>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <trigo.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2019-05-31 12:15:25 +00:00
|
|
|
#include <gr_text.h>
|
2018-01-28 18:12:26 +00:00
|
|
|
#include <plotter.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <lib_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_libentry.h>
|
|
|
|
#include <lib_pin.h>
|
|
|
|
#include <transform.h>
|
|
|
|
#include <sch_component.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <sch_sheet_path.h>
|
2018-04-17 16:25:19 +00:00
|
|
|
#include <trace_helpers.h>
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2015-04-03 09:13:06 +00:00
|
|
|
static const int pin_orientation_codes[] =
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2015-04-02 18:51:47 +00:00
|
|
|
PIN_RIGHT,
|
|
|
|
PIN_LEFT,
|
|
|
|
PIN_UP,
|
|
|
|
PIN_DOWN
|
2009-10-30 19:26:25 +00:00
|
|
|
};
|
2019-01-06 16:43:12 +00:00
|
|
|
#define PIN_ORIENTATION_CNT arrayDim( pin_orientation_codes )
|
2015-04-02 18:51:47 +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
|
|
|
|
|
2010-03-04 09:32:51 +00:00
|
|
|
// bitmaps to show pins orientations in dialog editor
|
|
|
|
// must have same order than pin_orientation_names
|
2015-04-03 09:13:06 +00:00
|
|
|
static const BITMAP_DEF iconsPinsOrientations[] =
|
2010-03-04 09:32:51 +00:00
|
|
|
{
|
|
|
|
pinorient_right_xpm,
|
|
|
|
pinorient_left_xpm,
|
|
|
|
pinorient_up_xpm,
|
|
|
|
pinorient_down_xpm,
|
|
|
|
};
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
const wxString LIB_PIN::GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType )
|
2010-03-04 09:32:51 +00:00
|
|
|
{
|
2016-03-15 11:29:16 +00:00
|
|
|
if( aType < 0 || aType >= (int) PINTYPE_COUNT )
|
2016-03-06 08:31:00 +00:00
|
|
|
return wxT( "???" );
|
2009-10-30 19:26:25 +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" ),
|
|
|
|
wxT( "BiDi" ),
|
|
|
|
wxT( "3state" ),
|
|
|
|
wxT( "passive" ),
|
|
|
|
wxT( "unspc" ),
|
|
|
|
wxT( "power_in" ),
|
|
|
|
wxT( "power_out" ),
|
|
|
|
wxT( "openCol" ),
|
|
|
|
wxT( "openEm" ),
|
2016-02-28 17:33:29 +00:00
|
|
|
wxT( "NotConnected" )
|
2015-04-02 18:51:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return msgPinElectricType[ aType ];
|
|
|
|
}
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2015-04-02 18:51:47 +00:00
|
|
|
// Helper functions to get the pin orientation name from pin_orientation_codes
|
|
|
|
// Note: the strings are *not* static because they are translated and must be built
|
|
|
|
// on the fly, to be properly translated
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2015-04-07 13:19:30 +00:00
|
|
|
static const wxString getPinOrientationName( unsigned aPinOrientationCode )
|
2009-06-13 17:06:07 +00:00
|
|
|
{
|
2015-04-02 18:51:47 +00:00
|
|
|
/* Note: The following name lists are sentence capitalized per the GNOME UI
|
|
|
|
* standards for list controls. Please do not change the capitalization
|
|
|
|
* of these strings unless the GNOME UI standards are changed.
|
|
|
|
*/
|
|
|
|
const wxString pin_orientation_names[] =
|
|
|
|
{
|
|
|
|
_( "Right" ),
|
|
|
|
_( "Left" ),
|
|
|
|
_( "Up" ),
|
2015-04-03 09:13:06 +00:00
|
|
|
_( "Down" ),
|
|
|
|
wxT( "???" )
|
2015-04-02 18:51:47 +00:00
|
|
|
};
|
|
|
|
|
2015-04-07 13:19:30 +00:00
|
|
|
if( aPinOrientationCode > PIN_ORIENTATION_CNT )
|
2015-04-03 09:13:06 +00:00
|
|
|
aPinOrientationCode = PIN_ORIENTATION_CNT;
|
|
|
|
|
|
|
|
return pin_orientation_names[ aPinOrientationCode ];
|
2015-04-02 18:51:47 +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)
|
|
|
|
|
|
|
|
static int InternalPinDecoSize( const LIB_PIN &aPin )
|
|
|
|
{
|
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
|
|
|
|
static int ExternalPinDecoSize( const LIB_PIN &aPin )
|
|
|
|
{
|
|
|
|
return aPin.GetNumberTextSize() / 2;
|
|
|
|
}
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_PIN::LIB_PIN( LIB_PART* aParent ) :
|
2016-02-28 17:33:29 +00:00
|
|
|
LIB_ITEM( LIB_PIN_T, aParent ),
|
|
|
|
m_shape( PINSHAPE_LINE )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2014-08-25 16:31:32 +00:00
|
|
|
m_length = LIB_EDIT_FRAME::GetDefaultPinLength();
|
2013-05-19 19:35:49 +00:00
|
|
|
m_orientation = PIN_RIGHT; // Pin orient: Up, Down, Left, Right
|
|
|
|
m_type = PIN_UNSPECIFIED; // electrical type of pin
|
|
|
|
m_attributes = 0; // bit 0 != 0: pin invisible
|
2014-08-25 16:31:32 +00:00
|
|
|
m_numTextSize = LIB_EDIT_FRAME::GetPinNumDefaultSize();
|
|
|
|
m_nameTextSize = LIB_EDIT_FRAME::GetPinNameDefaultSize();
|
2011-12-08 21:05:43 +00:00
|
|
|
m_width = 0;
|
2009-06-13 17:06:07 +00:00
|
|
|
}
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
void LIB_PIN::SetName( const wxString& aName, bool aTestOtherPins )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
wxString tmp = ( aName.IsEmpty() ) ? wxT( "~" ) : aName;
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2017-11-28 20:02:00 +00:00
|
|
|
// pin name string does not support spaces
|
2009-10-30 19:26:25 +00:00
|
|
|
tmp.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_name != tmp )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name = tmp;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
if( !aTestOtherPins )
|
|
|
|
return;
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_name == m_name )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
pinList[i]->m_name = m_name;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
void LIB_PIN::SetNameTextSize( int size, bool aTestOtherPins )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2011-12-08 21:05:43 +00:00
|
|
|
if( size != m_nameTextSize )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2011-12-08 21:05:43 +00:00
|
|
|
m_nameTextSize = size;
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
if( !aTestOtherPins )
|
|
|
|
return;
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2011-12-08 21:05:43 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_nameTextSize == size )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2011-12-08 21:05:43 +00:00
|
|
|
pinList[i]->m_nameTextSize = size;
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-28 20:02:00 +00:00
|
|
|
void LIB_PIN::SetNumber( const wxString& aNumber )
|
|
|
|
{
|
|
|
|
// Unlike SetName, others pin numbers marked by EnableEditMode() are
|
|
|
|
// not modified because each pin has its own number, so set number
|
|
|
|
// only for this.
|
|
|
|
|
|
|
|
wxString tmp = ( aNumber.IsEmpty() ) ? wxT( "~" ) : aNumber;
|
|
|
|
|
|
|
|
// pin number string does not support spaces
|
|
|
|
tmp.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
|
|
|
if( m_number != tmp )
|
|
|
|
{
|
|
|
|
m_number = tmp;
|
|
|
|
SetModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
void LIB_PIN::SetNumberTextSize( int size, bool aTestOtherPins )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2011-12-08 21:05:43 +00:00
|
|
|
if( size != m_numTextSize )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2011-12-08 21:05:43 +00:00
|
|
|
m_numTextSize = size;
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
if( !aTestOtherPins )
|
|
|
|
return;
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2011-12-08 21:05:43 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_numTextSize == size )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2011-12-08 21:05:43 +00:00
|
|
|
pinList[i]->m_numTextSize = size;
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
void LIB_PIN::SetOrientation( int orientation, bool aTestOtherPins )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_orientation != orientation )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_orientation = orientation;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
if( !aTestOtherPins )
|
|
|
|
return;
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2013-06-27 19:12:01 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 ||
|
|
|
|
pinList[i]->m_orientation == orientation )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
pinList[i]->m_orientation = orientation;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
void LIB_PIN::SetShape( GRAPHIC_PINSHAPE aShape )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2016-02-28 17:33:29 +00:00
|
|
|
assert( aShape >= 0 && aShape < int( PINSHAPE_COUNT ) );
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_shape != aShape )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_shape = aShape;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2011-02-16 10:14:02 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0
|
2011-04-18 20:22:17 +00:00
|
|
|
|| pinList[i]->m_Convert != m_Convert
|
|
|
|
|| pinList[i]->m_shape == aShape )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
pinList[i]->m_shape = aShape;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
void LIB_PIN::SetType( ELECTRICAL_PINTYPE aType, bool aTestOtherPins )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2016-02-28 18:16:59 +00:00
|
|
|
assert( aType >= 0 && aType < (int)PINTYPE_COUNT );
|
2016-02-28 17:33:29 +00:00
|
|
|
|
2016-02-19 16:51:23 +00:00
|
|
|
if( aType < PIN_INPUT )
|
|
|
|
aType = PIN_INPUT;
|
2013-06-28 06:31:24 +00:00
|
|
|
|
2016-02-28 18:16:59 +00:00
|
|
|
if( aType >= (int)PINTYPE_COUNT )
|
2016-02-19 16:51:23 +00:00
|
|
|
aType = PIN_NC;
|
2013-06-28 06:31:24 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_type != aType )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = aType;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
if( !aTestOtherPins )
|
|
|
|
return;
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_type == aType )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
pinList[i]->m_type = aType;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
void LIB_PIN::SetLength( int length, bool aTestOtherPins )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_length != length )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_length = length;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
2017-09-28 09:47:02 +00:00
|
|
|
if( !aTestOtherPins )
|
|
|
|
return;
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0
|
2011-04-18 20:22:17 +00:00
|
|
|
|| pinList[i]->m_Convert != m_Convert
|
|
|
|
|| pinList[i]->m_length == length )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
pinList[i]->m_length = length;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-18 16:59:26 +00:00
|
|
|
void LIB_PIN::SetPinPosition( wxPoint aPosition )
|
|
|
|
{
|
|
|
|
if( m_position != aPosition )
|
|
|
|
{
|
|
|
|
m_position = aPosition;
|
|
|
|
SetModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
LIB_PINS pinList;
|
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0
|
|
|
|
|| pinList[i]->m_Convert != m_Convert
|
|
|
|
|| pinList[i]->m_position == aPosition )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pinList[i]->m_position = aPosition;
|
|
|
|
SetModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
void LIB_PIN::SetPartNumber( int part )
|
|
|
|
{
|
|
|
|
if( m_Unit == part )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_Unit = part;
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
if( m_Unit == 0 )
|
|
|
|
{
|
|
|
|
LIB_PIN* pin;
|
|
|
|
LIB_PIN* tmp = GetParent()->GetNextPin();
|
|
|
|
|
|
|
|
while( tmp != NULL )
|
|
|
|
{
|
|
|
|
pin = tmp;
|
|
|
|
tmp = GetParent()->GetNextPin( pin );
|
|
|
|
|
|
|
|
if( pin->m_Flags == 0 || pin == this
|
2011-04-18 20:22:17 +00:00
|
|
|
|| ( m_Convert && ( m_Convert != pin->m_Convert ) )
|
|
|
|
|| ( m_position != pin->m_position )
|
|
|
|
|| ( pin->m_orientation != m_orientation ) )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
GetParent()->RemoveDrawItem( (LIB_ITEM*) pin );
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_PIN::SetConversion( int style )
|
|
|
|
{
|
|
|
|
if( m_Convert == style )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_Convert = style;
|
2013-03-30 19:55:26 +00:00
|
|
|
SetFlags( IS_CHANGED );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
if( style == 0 )
|
|
|
|
{
|
|
|
|
LIB_PIN* pin;
|
|
|
|
LIB_PIN* tmp = GetParent()->GetNextPin();
|
|
|
|
|
|
|
|
while( tmp != NULL )
|
|
|
|
{
|
|
|
|
pin = tmp;
|
|
|
|
tmp = GetParent()->GetNextPin( pin );
|
|
|
|
|
|
|
|
if( ( pin->m_Flags & IS_LINKED ) == 0
|
2011-04-18 20:22:17 +00:00
|
|
|
|| ( pin == this )
|
|
|
|
|| ( m_Unit && ( m_Unit != pin->m_Unit ) )
|
|
|
|
|| ( m_position != pin->m_position )
|
|
|
|
|| ( pin->m_orientation != m_orientation ) )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
GetParent()->RemoveDrawItem( (LIB_ITEM*) pin );
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_PIN::SetVisible( bool visible )
|
|
|
|
{
|
|
|
|
if( visible == IsVisible() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( visible )
|
2011-05-06 13:56:26 +00:00
|
|
|
m_attributes &= ~PIN_INVISIBLE;
|
2009-10-30 19:26:25 +00:00
|
|
|
else
|
2011-05-06 13:56:26 +00:00
|
|
|
m_attributes |= PIN_INVISIBLE;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->IsVisible() == visible )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if( visible )
|
2011-05-06 13:56:26 +00:00
|
|
|
pinList[i]->m_attributes &= ~PIN_INVISIBLE;
|
2009-10-30 19:26:25 +00:00
|
|
|
else
|
2011-05-06 13:56:26 +00:00
|
|
|
pinList[i]->m_attributes |= PIN_INVISIBLE;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-22 12:33:24 +00:00
|
|
|
void LIB_PIN::EnableEditMode( bool aEnable, bool aEditPinByPin )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
|
|
|
if( pinList[i] == this )
|
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( pinList[i]->m_position == m_position )
|
2018-01-22 12:33:24 +00:00
|
|
|
&& ( pinList[i]->m_orientation == m_orientation )
|
|
|
|
&& !IsNew() && !aEditPinByPin && aEnable )
|
|
|
|
{
|
2013-03-30 19:55:26 +00:00
|
|
|
pinList[i]->SetFlags( IS_LINKED | IN_EDIT );
|
2018-01-22 12:33:24 +00:00
|
|
|
}
|
2009-10-30 19:26:25 +00:00
|
|
|
else
|
2013-03-30 19:55:26 +00:00
|
|
|
pinList[i]->ClearFlags( IS_LINKED | IN_EDIT );
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
bool LIB_PIN::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
2009-06-13 17:06:07 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
EDA_RECT rect = GetBoundingBox();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
int LIB_PIN::GetPenSize() const
|
2009-06-30 17:57:27 +00:00
|
|
|
{
|
2018-10-20 11:08:33 +00:00
|
|
|
if( m_width > 0 )
|
|
|
|
return m_width;
|
|
|
|
|
|
|
|
if( m_width == 0 )
|
|
|
|
return GetDefaultLineThickness();
|
|
|
|
|
|
|
|
return 0;
|
2009-06-30 17:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
void LIB_PIN::print( wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2019-07-16 00:29:25 +00:00
|
|
|
PART_DRAW_OPTIONS* opts = (PART_DRAW_OPTIONS*) aData;
|
|
|
|
LIB_PART* part = GetParent();
|
2015-07-21 14:07:52 +00:00
|
|
|
|
|
|
|
/* Calculate pin orient taking in account the component orientation. */
|
|
|
|
int orient = PinDrawOrient( aTransform );
|
|
|
|
|
|
|
|
/* Calculate the pin position */
|
|
|
|
wxPoint pos1 = aTransform.TransformCoordinate( m_position ) + aOffset;
|
|
|
|
|
2019-07-16 00:29:25 +00:00
|
|
|
if( IsVisible() || ( opts && opts->draw_hidden_fields ) )
|
|
|
|
{
|
|
|
|
PrintPinSymbol( aDC, pos1, orient );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2019-07-16 00:29:25 +00:00
|
|
|
PrintPinTexts( aDC, pos1, orient, part->GetPinNameOffset(), part->ShowPinNumbers(),
|
|
|
|
part->ShowPinNames() );
|
2009-10-01 14:17:47 +00:00
|
|
|
|
2019-07-16 00:29:25 +00:00
|
|
|
if( opts && opts->show_elec_type )
|
|
|
|
PrintPinElectricalTypeName( aDC, pos1, orient );
|
|
|
|
}
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
void LIB_PIN::PrintPinSymbol( wxDC* aDC, const wxPoint& aPos, int aOrient )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2019-04-04 22:49:49 +00:00
|
|
|
int MapX1, MapY1, x1, y1;
|
|
|
|
int width = GetPenSize();
|
|
|
|
int posX = aPos.x, posY = aPos.y, len = m_length;
|
|
|
|
COLOR4D color = IsVisible() ? GetLayerColor( LAYER_PIN ) : GetInvisibleItemColor();
|
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 )
|
|
|
|
{
|
2019-04-04 22:49:49 +00:00
|
|
|
case PIN_UP: y1 = posY - len; MapY1 = 1; break;
|
|
|
|
case PIN_DOWN: y1 = posY + len; MapY1 = -1; break;
|
|
|
|
case PIN_LEFT: x1 = posX - len; MapX1 = 1; break;
|
|
|
|
case PIN_RIGHT: x1 = posX + len; MapX1 = -1; break;
|
2015-07-21 14:07:52 +00:00
|
|
|
}
|
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
if( m_shape == PINSHAPE_INVERTED || m_shape == PINSHAPE_INVERTED_CLOCK )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2014-05-13 19:24:12 +00:00
|
|
|
const int radius = ExternalPinDecoSize( *this );
|
2019-05-31 12:15:25 +00:00
|
|
|
GRCircle( nullptr, aDC, 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 );
|
2019-05-31 12:15:25 +00:00
|
|
|
GRLineTo( nullptr, aDC, posX, posY, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GRMoveTo( x1, y1 );
|
2019-05-31 12:15:25 +00:00
|
|
|
GRLineTo( nullptr, aDC, 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
|
|
|
|
if( m_shape == PINSHAPE_CLOCK || m_shape == PINSHAPE_INVERTED_CLOCK ||
|
|
|
|
m_shape == PINSHAPE_FALLING_EDGE_CLOCK || m_shape == PINSHAPE_CLOCK_LOW )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2014-05-13 19:24:12 +00:00
|
|
|
const int clock_size = InternalPinDecoSize( *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 );
|
2019-05-31 12:15:25 +00:00
|
|
|
GRLineTo( nullptr, aDC, x1 - MapX1 * clock_size * 2, y1, width, color );
|
|
|
|
GRLineTo( nullptr, aDC, 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 );
|
2019-05-31 12:15:25 +00:00
|
|
|
GRLineTo( nullptr, aDC, x1, y1 - MapY1 * clock_size * 2, width, color );
|
|
|
|
GRLineTo( nullptr, aDC, 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)
|
|
|
|
if( m_shape == PINSHAPE_INPUT_LOW ||
|
|
|
|
m_shape == PINSHAPE_FALLING_EDGE_CLOCK || m_shape == PINSHAPE_CLOCK_LOW )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
const int deco_size = ExternalPinDecoSize( *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 );
|
2019-05-31 12:15:25 +00:00
|
|
|
GRLineTo( nullptr, aDC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width, color );
|
|
|
|
GRLineTo( nullptr, aDC, 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 );
|
2019-05-31 12:15:25 +00:00
|
|
|
GRLineTo( nullptr, aDC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width, color );
|
|
|
|
GRLineTo( nullptr, aDC, x1, y1, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
if( m_shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
const int deco_size = ExternalPinDecoSize( *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 );
|
2019-05-31 12:15:25 +00:00
|
|
|
GRLineTo( nullptr, aDC, 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 );
|
2019-05-31 12:15:25 +00:00
|
|
|
GRLineTo( nullptr, aDC, x1, y1 + MapY1 * deco_size * 2, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-28 17:33:29 +00:00
|
|
|
else if( m_shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
|
2010-09-24 16:00:40 +00:00
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
const int deco_size = ExternalPinDecoSize( *this );
|
|
|
|
GRMoveTo( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size );
|
2019-05-31 12:15:25 +00:00
|
|
|
GRLineTo( nullptr, aDC, x1 + (MapX1 + MapY1) * deco_size, y1 + (MapY1 - MapX1) * deco_size, width,
|
2019-04-04 22:49:49 +00:00
|
|
|
color );
|
2019-04-08 14:59:52 +00:00
|
|
|
GRMoveTo( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size );
|
2019-05-31 12:15:25 +00:00
|
|
|
GRLineTo( nullptr, aDC, x1 + (MapX1 - MapY1) * deco_size, y1 + (MapY1 + MapX1) * deco_size, width,
|
2019-04-04 22:49:49 +00:00
|
|
|
color );
|
2010-09-24 16:00:40 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_type == PIN_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;
|
2019-05-31 12:15:25 +00:00
|
|
|
GRLine( nullptr, aDC, posX - deco_size, posY - deco_size, posX + deco_size, posY + deco_size, width, color );
|
|
|
|
GRLine( nullptr, aDC, 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
void LIB_PIN::PrintPinTexts( wxDC* DC, wxPoint& pin_pos, int orient, int TextInside,
|
|
|
|
bool DrawPinNum, bool DrawPinName )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2015-07-13 18:36:06 +00:00
|
|
|
if( !DrawPinName && !DrawPinNum )
|
|
|
|
return;
|
|
|
|
|
2019-04-04 22:49:49 +00:00
|
|
|
int x, y;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2019-04-04 22:49:49 +00:00
|
|
|
wxSize PinNameSize( m_nameTextSize, m_nameTextSize );
|
|
|
|
wxSize PinNumSize( m_numTextSize, m_numTextSize );
|
|
|
|
int nameLineWidth = Clamp_Text_PenSize( GetPenSize(), m_nameTextSize, false );
|
|
|
|
int numLineWidth = Clamp_Text_PenSize( GetPenSize(), m_numTextSize, false );
|
2019-12-30 18:28:00 +00:00
|
|
|
int name_offset = Mils2iu( PIN_TEXT_MARGIN ) +
|
|
|
|
( nameLineWidth + GetDefaultLineThickness() ) / 2;
|
|
|
|
int num_offset = Mils2iu( PIN_TEXT_MARGIN ) +
|
|
|
|
( numLineWidth + GetDefaultLineThickness() ) / 2;
|
2016-04-16 07:49:17 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
/* Get the num and name colors */
|
2019-04-04 22:49:49 +00:00
|
|
|
COLOR4D NameColor = IsVisible() ? GetLayerColor( LAYER_PINNAM ) : GetInvisibleItemColor();
|
|
|
|
COLOR4D NumColor = IsVisible() ? GetLayerColor( LAYER_PINNUM ) : GetInvisibleItemColor();
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2015-07-13 18:36:06 +00:00
|
|
|
int x1 = pin_pos.x;
|
|
|
|
int y1 = pin_pos.y;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
switch( orient )
|
|
|
|
{
|
2019-04-04 22:49:49 +00:00
|
|
|
case PIN_UP: y1 -= m_length; break;
|
|
|
|
case PIN_DOWN: y1 += m_length; break;
|
|
|
|
case PIN_LEFT: x1 -= m_length; break;
|
|
|
|
case PIN_RIGHT: x1 += m_length; break;
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_name.IsEmpty() )
|
2012-01-22 17:20:22 +00:00
|
|
|
DrawPinName = false;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2015-07-13 18:36:06 +00:00
|
|
|
if( TextInside ) // Draw the text inside, but the pin numbers outside.
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
// It is an horizontal line
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
if( orient == PIN_RIGHT )
|
|
|
|
{
|
|
|
|
x = x1 + TextInside;
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( DC, wxPoint( x, y1 ), NameColor, m_name, TEXT_ANGLE_HORIZ,
|
|
|
|
PinNameSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
nameLineWidth, false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
else // Orient == PIN_LEFT
|
|
|
|
{
|
|
|
|
x = x1 - TextInside;
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( DC, wxPoint( x, y1 ), NameColor, m_name, TEXT_ANGLE_HORIZ,
|
|
|
|
PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
nameLineWidth, false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( DC, wxPoint( (x1 + pin_pos.x) / 2, y1 - num_offset ), NumColor, m_number,
|
|
|
|
TEXT_ANGLE_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false );
|
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)
|
2009-05-12 12:12:34 +00:00
|
|
|
if( orient == PIN_DOWN )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2009-05-12 12:12:34 +00:00
|
|
|
y = y1 + TextInside;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinName )
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( DC, wxPoint( x1, y ), NameColor, m_name, TEXT_ANGLE_VERT, PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false,
|
|
|
|
false );
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinNum )
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor,
|
|
|
|
m_number, TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false );
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
|
|
|
else /* PIN_UP */
|
|
|
|
{
|
|
|
|
y = y1 - TextInside;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinName )
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( DC, wxPoint( x1, y ), NameColor, m_name, TEXT_ANGLE_VERT, PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false,
|
|
|
|
false );
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinNum )
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor,
|
|
|
|
m_number, TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /**** Draw num & text pin outside ****/
|
|
|
|
{
|
|
|
|
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
/* Its an horizontal line. */
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
x = (x1 + pin_pos.x) / 2;
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( DC, wxPoint( x, y1 - name_offset ), NameColor, m_name, TEXT_ANGLE_HORIZ,
|
|
|
|
PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
nameLineWidth, false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
|
|
|
x = (x1 + pin_pos.x) / 2;
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( DC, wxPoint( x, y1 + num_offset ), NumColor, m_number, TEXT_ANGLE_HORIZ,
|
|
|
|
PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, numLineWidth,
|
|
|
|
false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Its a vertical line. */
|
|
|
|
{
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
y = (y1 + pin_pos.y) / 2;
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( DC, wxPoint( x1 - name_offset, y ), NameColor, m_name, TEXT_ANGLE_VERT,
|
|
|
|
PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
nameLineWidth, false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( DC, wxPoint( x1 + num_offset, (y1 + pin_pos.y) / 2 ), NumColor, m_number,
|
|
|
|
TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP,
|
|
|
|
numLineWidth, false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2016-11-04 11:13:22 +00:00
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
void LIB_PIN::PrintPinElectricalTypeName( wxDC* aDC, wxPoint& aPosition, int aOrientation )
|
2016-11-04 11:13:22 +00:00
|
|
|
{
|
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
|
2019-04-04 22:49:49 +00:00
|
|
|
int textSize = (m_nameTextSize*3)/4;
|
2016-11-04 11:13:22 +00:00
|
|
|
|
|
|
|
#define ETXT_MAX_SIZE Millimeter2iu(0.7 )
|
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
|
2019-04-04 22:49:49 +00:00
|
|
|
COLOR4D color = IsVisible() ? GetLayerColor( LAYER_NOTES ) : GetInvisibleItemColor();
|
2016-11-04 11:13:22 +00:00
|
|
|
|
|
|
|
wxPoint txtpos = aPosition;
|
|
|
|
int offset = Millimeter2iu( 0.4 );
|
|
|
|
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_LEFT;
|
2017-01-23 20:30:11 +00:00
|
|
|
int orient = TEXT_ANGLE_HORIZ;
|
2016-11-04 11:13:22 +00:00
|
|
|
|
|
|
|
switch( aOrientation )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
|
|
|
txtpos.y += offset;
|
2017-01-23 20:30:11 +00:00
|
|
|
orient = TEXT_ANGLE_VERT;
|
2016-11-04 11:13:22 +00:00
|
|
|
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_DOWN:
|
|
|
|
txtpos.y -= offset;
|
2017-01-23 20:30:11 +00:00
|
|
|
orient = TEXT_ANGLE_VERT;
|
2016-11-04 11:13:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_LEFT:
|
|
|
|
txtpos.x += offset;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_RIGHT:
|
|
|
|
txtpos.x -= offset;
|
|
|
|
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
GRText( aDC, txtpos, color, typeName, orient, wxSize( textSize, textSize ), hjustify,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER, pensize, false, false );
|
2016-11-04 11:13:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
|
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
int MapX1, MapY1, x1, y1;
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D color = GetLayerColor( LAYER_PIN );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->SetColor( color );
|
2015-07-13 18:36:06 +00:00
|
|
|
aPlotter->SetCurrentLineWidth( GetPenSize() );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
|
|
|
MapX1 = MapY1 = 0;
|
|
|
|
x1 = aPosition.x; y1 = aPosition.y;
|
|
|
|
|
|
|
|
switch( aOrientation )
|
|
|
|
{
|
2019-04-04 22:49:49 +00:00
|
|
|
case PIN_UP: y1 = aPosition.y - m_length; MapY1 = 1; break;
|
|
|
|
case PIN_DOWN: y1 = aPosition.y + m_length; MapY1 = -1; break;
|
|
|
|
case PIN_LEFT: x1 = aPosition.x - m_length; MapX1 = 1; break;
|
|
|
|
case PIN_RIGHT: x1 = aPosition.x + m_length; MapX1 = -1; break;
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
if( m_shape == PINSHAPE_INVERTED || m_shape == PINSHAPE_INVERTED_CLOCK )
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2014-05-13 19:24:12 +00:00
|
|
|
const int radius = ExternalPinDecoSize( *this );
|
2019-04-04 22:49:49 +00:00
|
|
|
aPlotter->Circle( wxPoint( MapX1 * radius + x1, MapY1 * radius + y1 ),
|
|
|
|
radius * 2, NO_FILL, GetPenSize() );
|
|
|
|
|
|
|
|
aPlotter->MoveTo( wxPoint( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ) );
|
2014-05-13 19:24:12 +00:00
|
|
|
aPlotter->FinishTo( aPosition );
|
|
|
|
}
|
2016-02-28 17:33:29 +00:00
|
|
|
else if( m_shape == PINSHAPE_FALLING_EDGE_CLOCK )
|
2014-05-13 19:24:12 +00:00
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
const int deco_size = InternalPinDecoSize( *this );
|
2014-05-13 19:24:12 +00:00
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( x1, y1 + deco_size ) );
|
|
|
|
aPlotter->LineTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( x1, y1 - deco_size ) );
|
2014-05-13 19:24:12 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( x1 + deco_size, y1 ) );
|
|
|
|
aPlotter->LineTo( wxPoint( x1, y1 + MapY1 * deco_size * 2 ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( x1 - deco_size, y1 ) );
|
2014-05-13 19:24:12 +00:00
|
|
|
}
|
|
|
|
|
2019-04-08 14:59:52 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( 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
|
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( x1, y1 ) );
|
|
|
|
aPlotter->FinishTo( aPosition );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
if( m_shape == PINSHAPE_CLOCK || m_shape == PINSHAPE_INVERTED_CLOCK ||
|
|
|
|
m_shape == PINSHAPE_CLOCK_LOW )
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
const int deco_size = InternalPinDecoSize( *this );
|
2011-06-17 13:24:22 +00:00
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( x1, y1 + deco_size ) );
|
|
|
|
aPlotter->LineTo( wxPoint( x1 - MapX1 * deco_size * 2, y1 ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( x1, y1 - deco_size ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( x1 + deco_size, y1 ) );
|
|
|
|
aPlotter->LineTo( wxPoint( x1, y1 - MapY1 * deco_size * 2 ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( x1 - deco_size, y1 ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
if( m_shape == PINSHAPE_INPUT_LOW || m_shape == PINSHAPE_CLOCK_LOW ) /* IEEE symbol "Active Low Input" */
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
const int deco_size = ExternalPinDecoSize( *this );
|
2015-07-13 18:36:06 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 ) );
|
|
|
|
aPlotter->LineTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 - deco_size * 2 ) );
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->FinishTo( wxPoint( x1, y1 ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( x1, y1 + MapY1 * deco_size * 2 ) );
|
|
|
|
aPlotter->LineTo( wxPoint( x1 - deco_size * 2, y1 + MapY1 * deco_size * 2 ) );
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->FinishTo( wxPoint( x1, y1 ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
if( m_shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2014-05-13 19:24:12 +00:00
|
|
|
const int symbol_size = ExternalPinDecoSize( *this );
|
2015-07-13 18:36:06 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
2014-05-13 19:24:12 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( x1, y1 - symbol_size * 2 ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( x1 + MapX1 * symbol_size * 2, y1 ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
2014-05-13 19:24:12 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( x1 - symbol_size * 2, y1 ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( x1, y1 + MapY1 * symbol_size * 2 ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-28 17:33:29 +00:00
|
|
|
else if( m_shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
|
2014-05-13 19:24:12 +00:00
|
|
|
{
|
2019-04-08 14:59:52 +00:00
|
|
|
const int deco_size = ExternalPinDecoSize( *this );
|
|
|
|
aPlotter->MoveTo( wxPoint( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( x1 + (MapX1 + MapY1) * deco_size, y1 + (MapY1 - MapX1) * deco_size ) );
|
|
|
|
aPlotter->MoveTo( wxPoint( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( x1 + (MapX1 - MapY1) * deco_size, y1 + (MapY1 + MapX1) * deco_size ) );
|
2014-05-13 19:24:12 +00:00
|
|
|
}
|
|
|
|
if( m_type == PIN_NC ) // Draw a N.C. symbol
|
|
|
|
{
|
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;
|
2019-04-08 14:59:52 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( ex1 - deco_size, ey1 - deco_size ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( ex1 + deco_size, ey1 + deco_size ) );
|
|
|
|
aPlotter->MoveTo( wxPoint( ex1 + deco_size, ey1 - deco_size ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( ex1 - deco_size, ey1 + deco_size ) );
|
2014-05-13 19:24:12 +00:00
|
|
|
}
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-13 18:36:06 +00:00
|
|
|
void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
|
|
|
|
int TextInside, bool DrawPinNum,
|
|
|
|
bool DrawPinName, int aWidth )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2015-07-13 18:36:06 +00:00
|
|
|
if( m_name.IsEmpty() || m_name == wxT( "~" ) )
|
|
|
|
DrawPinName = false;
|
|
|
|
|
2017-08-10 15:00:28 +00:00
|
|
|
if( m_number.IsEmpty() )
|
2015-07-13 18:36:06 +00:00
|
|
|
DrawPinNum = false;
|
|
|
|
|
|
|
|
if( !DrawPinNum && !DrawPinName )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int x, y;
|
|
|
|
wxSize PinNameSize = wxSize( m_nameTextSize, m_nameTextSize );
|
|
|
|
wxSize PinNumSize = wxSize( m_numTextSize, m_numTextSize );
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2016-04-16 07:49:17 +00:00
|
|
|
int nameLineWidth = GetPenSize();
|
|
|
|
nameLineWidth = Clamp_Text_PenSize( nameLineWidth, m_nameTextSize, false );
|
|
|
|
int numLineWidth = GetPenSize();
|
|
|
|
numLineWidth = Clamp_Text_PenSize( numLineWidth, m_numTextSize, false );
|
|
|
|
|
2019-12-30 18:28:00 +00:00
|
|
|
int name_offset = Mils2iu( PIN_TEXT_MARGIN ) +
|
2016-04-16 07:49:17 +00:00
|
|
|
( nameLineWidth + GetDefaultLineThickness() ) / 2;
|
2019-12-30 18:28:00 +00:00
|
|
|
int num_offset = Mils2iu( PIN_TEXT_MARGIN ) +
|
2016-04-16 07:49:17 +00:00
|
|
|
( numLineWidth + GetDefaultLineThickness() ) / 2;
|
|
|
|
|
2008-09-13 19:06:31 +00:00
|
|
|
/* Get the num and name colors */
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D NameColor = GetLayerColor( LAYER_PINNAM );
|
|
|
|
COLOR4D NumColor = GetLayerColor( LAYER_PINNUM );
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2015-07-13 18:36:06 +00:00
|
|
|
int x1 = pin_pos.x;
|
|
|
|
int y1 = pin_pos.y;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
|
|
|
switch( orient )
|
|
|
|
{
|
2019-04-04 22:49:49 +00:00
|
|
|
case PIN_UP: y1 -= m_length; break;
|
|
|
|
case PIN_DOWN: y1 += m_length; break;
|
|
|
|
case PIN_LEFT: x1 -= m_length; break;
|
|
|
|
case PIN_RIGHT: x1 += m_length; break;
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/* Draw the text inside, but the pin numbers outside. */
|
|
|
|
if( TextInside )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) /* Its an horizontal line. */
|
|
|
|
{
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
|
|
|
if( orient == PIN_RIGHT )
|
|
|
|
{
|
|
|
|
x = x1 + TextInside;
|
2012-05-03 18:37:56 +00:00
|
|
|
plotter->Text( wxPoint( x, y1 ), NameColor,
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name,
|
2017-01-23 20:30:11 +00:00
|
|
|
TEXT_ANGLE_HORIZ,
|
2009-09-02 18:12:45 +00:00
|
|
|
PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_LEFT,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
else // orient == PIN_LEFT
|
|
|
|
{
|
|
|
|
x = x1 - TextInside;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinName )
|
2012-05-03 18:37:56 +00:00
|
|
|
plotter->Text( wxPoint( x, y1 ),
|
2017-01-23 20:30:11 +00:00
|
|
|
NameColor, m_name, TEXT_ANGLE_HORIZ,
|
2009-09-02 18:12:45 +00:00
|
|
|
PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_RIGHT,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
aWidth, false, false );
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
2009-09-25 13:59:42 +00:00
|
|
|
}
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2016-04-16 07:49:17 +00:00
|
|
|
plotter->Text( wxPoint( (x1 + pin_pos.x) / 2,
|
|
|
|
y1 - num_offset ),
|
2017-08-10 15:00:28 +00:00
|
|
|
NumColor, m_number,
|
2017-01-23 20:30:11 +00:00
|
|
|
TEXT_ANGLE_HORIZ, PinNumSize,
|
2009-09-25 13:59:42 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Its a vertical line. */
|
|
|
|
{
|
2009-05-12 12:12:34 +00:00
|
|
|
if( orient == PIN_DOWN )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2009-05-12 12:12:34 +00:00
|
|
|
y = y1 + TextInside;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinName )
|
2012-05-03 18:37:56 +00:00
|
|
|
plotter->Text( wxPoint( x1, y ), NameColor,
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name,
|
2017-01-23 20:30:11 +00:00
|
|
|
TEXT_ANGLE_VERT, PinNameSize,
|
2009-09-02 18:12:45 +00:00
|
|
|
GR_TEXT_HJUSTIFY_RIGHT,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
aWidth, false, false );
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinNum )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2016-04-16 07:49:17 +00:00
|
|
|
plotter->Text( wxPoint( x1 - num_offset,
|
|
|
|
(y1 + pin_pos.y) / 2 ),
|
2017-08-10 15:00:28 +00:00
|
|
|
NumColor, m_number,
|
2017-01-23 20:30:11 +00:00
|
|
|
TEXT_ANGLE_VERT, PinNumSize,
|
2009-09-02 18:12:45 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
aWidth, false, false );
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* PIN_UP */
|
|
|
|
{
|
|
|
|
y = y1 - TextInside;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinName )
|
2012-05-03 18:37:56 +00:00
|
|
|
plotter->Text( wxPoint( x1, y ), NameColor,
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name,
|
2017-01-23 20:30:11 +00:00
|
|
|
TEXT_ANGLE_VERT, PinNameSize,
|
2009-09-02 18:12:45 +00:00
|
|
|
GR_TEXT_HJUSTIFY_LEFT,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
aWidth, false, false );
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2016-04-16 07:49:17 +00:00
|
|
|
plotter->Text( wxPoint( x1 - num_offset,
|
|
|
|
(y1 + pin_pos.y) / 2 ),
|
2017-08-10 15:00:28 +00:00
|
|
|
NumColor, m_number,
|
2017-01-23 20:30:11 +00:00
|
|
|
TEXT_ANGLE_VERT, PinNumSize,
|
2009-09-02 18:12:45 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Draw num & text pin outside */
|
|
|
|
{
|
|
|
|
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
/* Its an horizontal line. */
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
|
|
|
x = (x1 + pin_pos.x) / 2;
|
2016-04-16 07:49:17 +00:00
|
|
|
plotter->Text( wxPoint( x, y1 - name_offset ),
|
2010-12-07 16:10:42 +00:00
|
|
|
NameColor, m_name,
|
2017-01-23 20:30:11 +00:00
|
|
|
TEXT_ANGLE_HORIZ, PinNameSize,
|
2009-09-02 18:12:45 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2008-09-13 19:06:31 +00:00
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2010-11-18 21:10:52 +00:00
|
|
|
x = ( x1 + pin_pos.x ) / 2;
|
2016-04-16 07:49:17 +00:00
|
|
|
plotter->Text( wxPoint( x, y1 + num_offset ),
|
2017-08-10 15:00:28 +00:00
|
|
|
NumColor, m_number,
|
2017-01-23 20:30:11 +00:00
|
|
|
TEXT_ANGLE_HORIZ, PinNumSize,
|
2009-09-02 18:12:45 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_TOP,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Its a vertical line. */
|
|
|
|
{
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2010-11-18 21:10:52 +00:00
|
|
|
y = ( y1 + pin_pos.y ) / 2;
|
2016-04-16 07:49:17 +00:00
|
|
|
plotter->Text( wxPoint( x1 - name_offset, y ),
|
2010-12-07 16:10:42 +00:00
|
|
|
NameColor, m_name,
|
2017-01-23 20:30:11 +00:00
|
|
|
TEXT_ANGLE_VERT, PinNameSize,
|
2009-09-02 18:12:45 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2016-04-16 07:49:17 +00:00
|
|
|
plotter->Text( wxPoint( x1 + num_offset,
|
|
|
|
( y1 + pin_pos.y ) / 2 ),
|
2017-08-10 15:00:28 +00:00
|
|
|
NumColor, m_number,
|
2017-01-23 20:30:11 +00:00
|
|
|
TEXT_ANGLE_VERT, PinNumSize,
|
2009-09-02 18:12:45 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_TOP,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
|
* 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
|
|
|
wxPoint LIB_PIN::PinEndPoint() const
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
wxPoint pos = m_position;
|
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
|
|
|
{
|
2019-04-04 22:49:49 +00:00
|
|
|
case PIN_UP: pos.y += m_length; break;
|
|
|
|
case PIN_DOWN: pos.y -= m_length; break;
|
|
|
|
case PIN_LEFT: pos.x -= m_length; break;
|
|
|
|
case PIN_RIGHT: pos.x += m_length; break;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
* 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
|
|
|
int LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
int orient;
|
2010-12-07 16:10:42 +00:00
|
|
|
wxPoint 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
|
|
|
{
|
2019-04-04 22:49:49 +00:00
|
|
|
case PIN_UP: end.y = 1; break;
|
|
|
|
case PIN_DOWN: end.y = -1; break;
|
|
|
|
case PIN_LEFT: end.x = -1; break;
|
|
|
|
case PIN_RIGHT: end.x = 1; break;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
// = pos of end point, according to the component orientation
|
2011-04-18 20:22:17 +00:00
|
|
|
end = aTransform.TransformCoordinate( end );
|
2008-09-14 04:27:22 +00:00
|
|
|
orient = 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 )
|
2008-09-14 04:27:22 +00:00
|
|
|
orient = PIN_DOWN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
orient = PIN_RIGHT;
|
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
|
|
|
orient = PIN_LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2012-02-27 23:02:08 +00:00
|
|
|
int LIB_PIN::compare( const LIB_ITEM& other ) const
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
wxASSERT( other.Type() == LIB_PIN_T );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
const LIB_PIN* tmp = (LIB_PIN*) &other;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( 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
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
int result = m_name.CmpNoCase( tmp->m_name );
|
2009-10-01 14:17:47 +00:00
|
|
|
|
|
|
|
if( result != 0 )
|
|
|
|
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
|
|
|
|
|
|
|
return 0;
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-09 07:57:07 +00:00
|
|
|
void LIB_PIN::Offset( const wxPoint& 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-27 23:02:08 +00:00
|
|
|
bool LIB_PIN::Inside( EDA_RECT& rect ) const
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
* 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
|
|
|
wxPoint end = PinEndPoint();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
return rect.Contains( m_position.x, -m_position.y ) || rect.Contains( end.x, -end.y );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-09 07:57:07 +00:00
|
|
|
void LIB_PIN::MoveTo( const wxPoint& newPosition )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_position != newPosition )
|
|
|
|
{
|
|
|
|
m_position = newPosition;
|
|
|
|
SetModified();
|
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-27 23:02:08 +00:00
|
|
|
void LIB_PIN::MirrorHorizontal( const wxPoint& center )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_position.x -= center.x;
|
|
|
|
m_position.x *= -1;
|
|
|
|
m_position.x += center.x;
|
|
|
|
|
|
|
|
if( m_orientation == PIN_RIGHT )
|
|
|
|
m_orientation = PIN_LEFT;
|
|
|
|
else if( m_orientation == PIN_LEFT )
|
|
|
|
m_orientation = PIN_RIGHT;
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
2012-02-27 23:02:08 +00:00
|
|
|
void LIB_PIN::MirrorVertical( const wxPoint& center )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
|
|
|
m_position.y -= center.y;
|
|
|
|
m_position.y *= -1;
|
|
|
|
m_position.y += center.y;
|
|
|
|
|
|
|
|
if( m_orientation == PIN_UP )
|
|
|
|
m_orientation = PIN_DOWN;
|
|
|
|
else if( m_orientation == PIN_DOWN )
|
|
|
|
m_orientation = PIN_UP;
|
|
|
|
}
|
|
|
|
|
2012-02-27 23:02:08 +00:00
|
|
|
void LIB_PIN::Rotate( const wxPoint& center, bool aRotateCCW )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
2011-05-22 19:08:34 +00:00
|
|
|
int rot_angle = aRotateCCW ? -900 : 900;
|
2011-05-20 18:29:35 +00:00
|
|
|
|
2011-05-22 19:08:34 +00:00
|
|
|
RotatePoint( &m_position, center, rot_angle );
|
|
|
|
|
|
|
|
if( aRotateCCW )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
2011-05-22 19:08:34 +00:00
|
|
|
switch( m_orientation )
|
|
|
|
{
|
2019-04-04 22:49:49 +00:00
|
|
|
case PIN_RIGHT: m_orientation = PIN_UP; break;
|
|
|
|
case PIN_UP: m_orientation = PIN_LEFT; break;
|
|
|
|
case PIN_LEFT: m_orientation = PIN_DOWN; break;
|
|
|
|
case PIN_DOWN: m_orientation = PIN_RIGHT; break;
|
2011-05-22 19:08:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( m_orientation )
|
|
|
|
{
|
2019-04-04 22:49:49 +00:00
|
|
|
case PIN_RIGHT: m_orientation = PIN_DOWN; break;
|
|
|
|
case PIN_UP: m_orientation = PIN_RIGHT; break;
|
|
|
|
case PIN_LEFT: m_orientation = PIN_UP; break;
|
|
|
|
case PIN_DOWN: m_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
|
|
|
|
2012-02-27 23:02:08 +00:00
|
|
|
void LIB_PIN::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
|
|
|
|
const TRANSFORM& aTransform )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2011-05-06 13:56:26 +00:00
|
|
|
if( ! IsVisible() )
|
2009-10-05 17:52:41 +00:00
|
|
|
return;
|
|
|
|
|
* 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
|
|
|
int orient = PinDrawOrient( aTransform );
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
wxPoint pos = aTransform.TransformCoordinate( m_position ) + offset;
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
PlotSymbol( plotter, pos, orient );
|
2010-06-24 18:31:43 +00:00
|
|
|
PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(),
|
2019-04-04 22:49:49 +00:00
|
|
|
GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(), GetPenSize() );
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-27 23:02:08 +00:00
|
|
|
void LIB_PIN::SetWidth( int aWidth )
|
2010-12-07 16:10:42 +00:00
|
|
|
{
|
|
|
|
if( m_width != aWidth )
|
|
|
|
{
|
|
|
|
m_width = aWidth;
|
|
|
|
SetModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
void LIB_PIN::getMsgPanelInfoBase( EDA_UNITS aUnits, MSG_PANEL_ITEMS& aList )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2017-08-10 15:00:28 +00:00
|
|
|
wxString text = m_number.IsEmpty() ? wxT( "?" ) : m_number;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
LIB_ITEM::GetMsgPanelInfo( aUnits, aList );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Name" ), m_name, DARKCYAN ) );
|
2015-01-18 11:49:32 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Number" ), text, DARKCYAN ) );
|
2018-04-10 10:52:12 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), GetText( m_type ), RED ) );
|
2015-01-18 11:49:32 +00:00
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
text = GetText( m_shape );
|
2015-01-18 11:49:32 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Style" ), text, BLUE ) );
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2019-04-04 22:49:49 +00:00
|
|
|
text = IsVisible() ? _( "Yes" ) : _( "No" );
|
2015-01-18 11:49:32 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Visible" ), text, DARKGREEN ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
// Display pin length
|
2018-04-10 10:52:12 +00:00
|
|
|
text = StringFromValue( aUnits, m_length, true );
|
2015-01-18 11:49:32 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Length" ), text, MAGENTA ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2018-02-08 12:16:07 +00:00
|
|
|
text = getPinOrientationName( (unsigned) GetOrientationIndex( m_orientation ) );
|
2015-01-18 11:49:32 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), text, DARKMAGENTA ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
void LIB_PIN::GetMsgPanelInfo( EDA_UNITS aUnits, MSG_PANEL_ITEMS& aList )
|
2016-10-18 16:59:26 +00:00
|
|
|
{
|
2018-04-10 10:52:12 +00:00
|
|
|
getMsgPanelInfoBase( aUnits, aList );
|
2016-10-18 16:59:26 +00:00
|
|
|
|
|
|
|
wxString text;
|
|
|
|
wxPoint pinpos = GetPosition();
|
|
|
|
pinpos.y = -pinpos.y; // Display coord are top to bottom
|
|
|
|
// lib items coord are bottom to top
|
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
text = MessageTextFromValue( aUnits, pinpos.x, true );
|
2016-10-18 16:59:26 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Pos X" ), text, DARKMAGENTA ) );
|
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
text = MessageTextFromValue( aUnits, pinpos.y, true );
|
2016-10-18 16:59:26 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Pos Y" ), text, DARKMAGENTA ) );
|
|
|
|
}
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
void LIB_PIN::GetMsgPanelInfo(
|
|
|
|
EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList, SCH_COMPONENT* aComponent )
|
2016-10-18 16:59:26 +00:00
|
|
|
{
|
2018-04-10 10:52:12 +00:00
|
|
|
getMsgPanelInfoBase( aUnits, aList );
|
2016-10-18 16:59:26 +00:00
|
|
|
|
|
|
|
if( !aComponent )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString text;
|
|
|
|
wxPoint pinpos = aComponent->GetTransform().TransformCoordinate( GetPosition() )
|
|
|
|
+ aComponent->GetPosition();
|
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
text = MessageTextFromValue( aUnits, pinpos.x, true );
|
2019-12-05 15:41:21 +00:00
|
|
|
aList.emplace_back( _( "Pos X" ), text, DARKMAGENTA );
|
2016-10-18 16:59:26 +00:00
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
text = MessageTextFromValue( aUnits, pinpos.y, true );
|
2019-12-05 15:41:21 +00:00
|
|
|
aList.emplace_back( _( "Pos Y" ), text, DARKMAGENTA );
|
2016-10-18 16:59:26 +00:00
|
|
|
|
2019-12-05 15:41:21 +00:00
|
|
|
aList.emplace_back( aComponent->GetField( REFERENCE )->GetShownText(),
|
|
|
|
aComponent->GetField( VALUE )->GetShownText(), DARKCYAN );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
|
2019-03-08 00:16:59 +00:00
|
|
|
auto conn = aComponent->GetConnectionForPin( this, *g_CurrentSheet );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-03-08 00:16:59 +00:00
|
|
|
if( conn )
|
2019-03-11 21:32:05 +00:00
|
|
|
conn->AppendDebugInfoToMsgPanel( aList );
|
|
|
|
|
|
|
|
#endif
|
2016-10-18 16:59:26 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles ) const
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_PART* entry = (LIB_PART* ) m_Parent;
|
2011-04-18 20:22:17 +00:00
|
|
|
EDA_RECT bbox;
|
|
|
|
wxPoint begin;
|
|
|
|
wxPoint end;
|
2011-04-27 19:44:32 +00:00
|
|
|
int nameTextOffset = 0;
|
|
|
|
bool showName = !m_name.IsEmpty() && (m_name != wxT( "~" ));
|
2017-08-10 15:00:28 +00:00
|
|
|
bool showNum = !m_number.IsEmpty();
|
2011-05-25 10:42:56 +00:00
|
|
|
int minsizeV = TARGET_PIN_RADIUS;
|
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
if( !aIncludeInvisibles && !IsVisible() )
|
|
|
|
showName = false;
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
if( entry )
|
2011-04-27 19:44:32 +00:00
|
|
|
{
|
|
|
|
if( entry->ShowPinNames() )
|
|
|
|
nameTextOffset = entry->GetPinNameOffset();
|
|
|
|
else
|
|
|
|
showName = false;
|
2011-05-05 17:45:35 +00:00
|
|
|
|
|
|
|
showNum = entry->ShowPinNumbers();
|
2011-04-27 19:44:32 +00:00
|
|
|
}
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
// First, calculate boundary box corners position
|
2017-08-10 15:00:28 +00:00
|
|
|
int numberTextLength = showNum ? m_numTextSize * m_number.Len() : 0;
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2011-05-25 10:42:56 +00:00
|
|
|
// Actual text height is bigger than text size
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
int numberTextHeight = showNum ? KiROUND( m_numTextSize * 1.1 ) : 0;
|
2011-04-27 19:44:32 +00:00
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
if( m_shape == PINSHAPE_INVERTED || m_shape == PINSHAPE_INVERTED_CLOCK )
|
2014-05-13 19:24:12 +00:00
|
|
|
minsizeV = std::max( TARGET_PIN_RADIUS, ExternalPinDecoSize( *this ) );
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
// calculate top left corner position
|
|
|
|
// for the default pin orientation (PIN_RIGHT)
|
2019-12-30 18:28:00 +00:00
|
|
|
begin.y = std::max( minsizeV, numberTextHeight + Mils2iu( PIN_TEXT_MARGIN ) );
|
2012-09-22 11:19:37 +00:00
|
|
|
begin.x = std::min( -TARGET_PIN_RADIUS, m_length - (numberTextLength / 2) );
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
// calculate bottom right corner position and adjust top left corner position
|
2011-04-27 19:44:32 +00:00
|
|
|
int nameTextLength = 0;
|
2011-05-05 17:45:35 +00:00
|
|
|
int nameTextHeight = 0;
|
2011-04-27 19:44:32 +00:00
|
|
|
|
|
|
|
if( showName )
|
|
|
|
{
|
|
|
|
int length = m_name.Len();
|
|
|
|
|
|
|
|
// Don't count the line over text symbol.
|
|
|
|
if( m_name.Left( 1 ) == wxT( "~" ) )
|
|
|
|
length -= 1;
|
|
|
|
|
2011-12-08 21:05:43 +00:00
|
|
|
nameTextLength = ( m_nameTextSize * length ) + nameTextOffset;
|
|
|
|
|
2011-05-05 17:45:35 +00:00
|
|
|
// Actual text height are bigger than text size
|
2019-12-30 18:28:00 +00:00
|
|
|
nameTextHeight = KiROUND( m_nameTextSize * 1.1 ) + Mils2iu( PIN_TEXT_MARGIN );
|
2011-04-27 19:44:32 +00:00
|
|
|
}
|
|
|
|
|
2011-05-25 10:42:56 +00:00
|
|
|
if( nameTextOffset ) // for values > 0, pin name is inside the body
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
else // if value == 0:
|
2011-10-31 20:49:48 +00:00
|
|
|
// pin name is outside the body, and above the pin line
|
2011-05-25 10:42:56 +00:00
|
|
|
// pin num is below the pin line
|
|
|
|
{
|
2012-09-22 11:19:37 +00:00
|
|
|
end.x = std::max(m_length, nameTextLength);
|
2011-05-25 10:42:56 +00:00
|
|
|
end.y = -begin.y;
|
2012-09-22 11:19:37 +00:00
|
|
|
begin.y = std::max( minsizeV, nameTextHeight );
|
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
|
* 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
|
|
|
int 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
|
|
|
{
|
|
|
|
case PIN_UP:
|
|
|
|
// Pin is rotated and texts positions are mirrored
|
|
|
|
RotatePoint( &begin, wxPoint( 0, 0 ), -900 );
|
|
|
|
RotatePoint( &end, wxPoint( 0, 0 ), -900 );
|
|
|
|
break;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
case PIN_DOWN:
|
|
|
|
RotatePoint( &begin, wxPoint( 0, 0 ), 900 );
|
|
|
|
RotatePoint( &end, wxPoint( 0, 0 ), 900 );
|
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;
|
|
|
|
|
|
|
|
case 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;
|
|
|
|
|
|
|
|
case PIN_RIGHT:
|
|
|
|
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();
|
2015-06-18 14:56:08 +00:00
|
|
|
bbox.Inflate( ( GetPenSize() / 2 ) + 1 );
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
wxArrayString LIB_PIN::GetOrientationNames( void )
|
|
|
|
{
|
2009-11-16 21:37:53 +00:00
|
|
|
wxArrayString tmp;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2009-11-16 21:37:53 +00:00
|
|
|
for( unsigned ii = 0; ii < PIN_ORIENTATION_CNT; ii++ )
|
2015-04-02 18:51:47 +00:00
|
|
|
tmp.Add( getPinOrientationName( ii ) );
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2009-11-16 21:37:53 +00:00
|
|
|
return tmp;
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int LIB_PIN::GetOrientationCode( int index )
|
|
|
|
{
|
|
|
|
if( index >= 0 && index < (int) PIN_ORIENTATION_CNT )
|
|
|
|
return pin_orientation_codes[ index ];
|
|
|
|
|
|
|
|
return PIN_RIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-08 12:16:07 +00:00
|
|
|
int LIB_PIN::GetOrientationIndex( int code )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for( i = 0; i < PIN_ORIENTATION_CNT; i++ )
|
|
|
|
{
|
|
|
|
if( pin_orientation_codes[i] == code )
|
|
|
|
return (int) i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return wxNOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-29 03:04:59 +00:00
|
|
|
const BITMAP_DEF* LIB_PIN::GetOrientationSymbols()
|
2010-03-04 09:32:51 +00:00
|
|
|
{
|
2015-04-03 09:13:06 +00:00
|
|
|
return iconsPinsOrientations;
|
2010-03-04 09:32:51 +00:00
|
|
|
}
|
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2011-08-29 03:04:59 +00:00
|
|
|
BITMAP_DEF LIB_PIN::GetMenuImage() const
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
2016-02-28 17:33:29 +00:00
|
|
|
return GetBitmap( m_type );
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString LIB_PIN::GetSelectMenuText( EDA_UNITS aUnits ) const
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
2018-04-10 10:52:12 +00:00
|
|
|
return wxString::Format( _( "Pin %s, %s, %s" ),
|
|
|
|
m_number,
|
|
|
|
GetElectricalTypeName(),
|
|
|
|
GetText( m_shape ));
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
bool LIB_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxDat )
|
2011-12-01 16:49:28 +00:00
|
|
|
{
|
2019-12-20 14:11:39 +00:00
|
|
|
wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2011-12-13 15:37:33 +00:00
|
|
|
// Note: this will have to be modified if we add find and replace capability to the
|
|
|
|
// compoment library editor. Otherwise, you wont be able to replace pin text.
|
2011-12-01 16:49:28 +00:00
|
|
|
if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_PINS )
|
2011-12-13 15:37:33 +00:00
|
|
|
|| ( aSearchData.GetFlags() & FR_SEARCH_REPLACE ) )
|
2011-12-01 16:49:28 +00:00
|
|
|
return false;
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxLogTrace(
|
|
|
|
traceFindItem, wxT( " child item " ) + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
return EDA_ITEM::Matches( GetName(), aSearchData )
|
|
|
|
|| EDA_ITEM::Matches( m_number, aSearchData );
|
2011-12-01 16:49:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
void LIB_PIN::CalcEdit( const wxPoint& aPosition )
|
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
if( IsMoving() )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-10-11 05:31:17 +00:00
|
|
|
DBG(printf("MOVEPIN\n");)
|
2019-05-09 07:57:07 +00:00
|
|
|
MoveTo( aPosition );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
}
|