kicad/eeschema/lib_pin.cpp

2305 lines
62 KiB
C++
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_pin.cpp
*/
2008-09-13 18:59:57 +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>
#include <gr_basic.h>
#include <macros.h>
#include <trigo.h>
#include <class_drawpanel.h>
#include <drawtxt.h>
#include <plot_common.h>
#include <schframe.h>
#include <richio.h>
#include <base_units.h>
#include <msgpanel.h>
#include <general.h>
#include <libeditframe.h>
#include <class_libentry.h>
#include <lib_pin.h>
#include <transform.h>
#include <sch_component.h>
2008-09-13 18:59:57 +00:00
static const int pin_orientation_codes[] =
{
PIN_RIGHT,
PIN_LEFT,
PIN_UP,
PIN_DOWN
};
2011-04-18 20:22:17 +00:00
#define PIN_ORIENTATION_CNT DIM( pin_orientation_codes )
// bitmaps to show pins orientations in dialog editor
// must have same order than pin_orientation_names
static const BITMAP_DEF iconsPinsOrientations[] =
{
pinorient_right_xpm,
pinorient_left_xpm,
pinorient_up_xpm,
pinorient_down_xpm,
};
// bitmaps to show pins shapes in dialog editor
// must have same order than pin_style_names
static BITMAP_DEF iconsPinsShapes[] =
{
pinshape_normal_xpm,
pinshape_invert_xpm,
pinshape_clock_normal_xpm,
pinshape_clock_invert_xpm,
pinshape_active_low_input_xpm,
pinshape_clock_active_low_xpm,
pinshape_active_low_output_xpm,
pinshape_clock_fall_xpm,
pinshape_nonlogic_xpm
};
static const int pin_style_codes[] =
{
NONE,
INVERT,
CLOCK,
CLOCK | INVERT,
LOWLEVEL_IN,
LOWLEVEL_IN | CLOCK,
LOWLEVEL_OUT,
CLOCK_FALL,
NONLOGIC
};
#define PIN_STYLE_CNT DIM( pin_style_codes )
// bitmaps to show pins electrical type in dialog editor
// must have same order than enum ElectricPinType (see lib_pin.h)
static const BITMAP_DEF iconsPinsElectricalType[] =
{
pintype_input_xpm,
pintype_output_xpm,
pintype_bidi_xpm,
pintype_3states_xpm,
pintype_passive_xpm,
pintype_notspecif_xpm,
pintype_powerinput_xpm,
pintype_poweroutput_xpm,
pintype_opencoll_xpm,
pintype_openemit_xpm,
pintype_noconnect_xpm
};
#define PIN_ELECTRICAL_TYPE_CNT DIM( iconsPinsElectricalType )
const wxString LIB_PIN::GetCanonicalElectricalTypeName( unsigned aType )
{
// 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
// must have same order than enum ElectricPinType (see lib_pin.h)
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" ),
wxT( "NotConnected" ),
wxT( "???" )
};
if( aType > PIN_NMAX )
aType = PIN_NMAX;
return msgPinElectricType[ aType ];
}
// 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
static const wxString getPinOrientationName( unsigned aPinOrientationCode )
2009-06-13 17:06:07 +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" ),
_( "Down" ),
wxT( "???" )
};
if( aPinOrientationCode > PIN_ORIENTATION_CNT )
aPinOrientationCode = PIN_ORIENTATION_CNT;
return pin_orientation_names[ aPinOrientationCode ];
}
const wxString LIB_PIN::GetElectricalTypeName( unsigned aPinsElectricalType )
{
const wxString pin_electrical_type_names[] =
{ // Keep these translated strings not static
_( "Input" ),
_( "Output" ),
_( "Bidirectional" ),
_( "Tri-state" ),
_( "Passive" ),
_( "Unspecified" ),
_( "Power input" ),
_( "Power output" ),
_( "Open collector" ),
_( "Open emitter" ),
_( "Not connected" ),
wxT( "???" )
};
if( aPinsElectricalType > PIN_ELECTRICAL_TYPE_CNT )
aPinsElectricalType = PIN_ELECTRICAL_TYPE_CNT;
return pin_electrical_type_names[ aPinsElectricalType ];
}
static const wxString getPinStyleName( unsigned aPinsStyle )
{
const wxString pin_style_names[] =
{ // Keep these translated strings not static
_( "Line" ),
_( "Inverted" ),
_( "Clock" ),
_( "Inverted clock" ),
_( "Input low" ),
_( "Clock low" ),
_( "Output low" ),
_( "Falling edge clock" ),
_( "NonLogic" ),
wxT( "???" )
};
if( aPinsStyle > PIN_STYLE_CNT )
aPinsStyle = PIN_STYLE_CNT;
return pin_style_names[ aPinsStyle ];
}
2008-09-13 18:59:57 +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 )
{
return aPin.GetNameTextSize() / 2;
}
/// 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;
}
LIB_PIN::LIB_PIN( LIB_PART* aParent ) :
LIB_ITEM( LIB_PIN_T, aParent )
{
m_length = LIB_EDIT_FRAME::GetDefaultPinLength();
m_orientation = PIN_RIGHT; // Pin orient: Up, Down, Left, Right
m_shape = NONE; // Pin shape, bitwise.
m_type = PIN_UNSPECIFIED; // electrical type of pin
m_attributes = 0; // bit 0 != 0: pin invisible
m_number = 0; // pin number (i.e. 4 ASCII chars)
m_numTextSize = LIB_EDIT_FRAME::GetPinNumDefaultSize();
m_nameTextSize = LIB_EDIT_FRAME::GetPinNameDefaultSize();
m_width = 0;
2011-04-18 20:22:17 +00:00
m_typeName = _( "Pin" );
2009-06-13 17:06:07 +00:00
}
void LIB_PIN::SetName( const wxString& aName )
{
wxString tmp = ( aName.IsEmpty() ) ? wxT( "~" ) : aName;
2011-04-18 20:22:17 +00:00
tmp.Replace( wxT( " " ), wxT( "_" ) );
if( m_name != tmp )
{
m_name = tmp;
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_name == m_name )
continue;
pinList[i]->m_name = m_name;
SetModified();
}
}
void LIB_PIN::SetNameTextSize( int size )
{
if( size != m_nameTextSize )
{
m_nameTextSize = size;
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_nameTextSize == size )
continue;
pinList[i]->m_nameTextSize = size;
SetModified();
}
}
void LIB_PIN::SetNumber( const wxString& number )
{
wxString tmp = ( number.IsEmpty() ) ? wxT( "~" ) : number;
2011-04-18 20:22:17 +00:00
tmp.Replace( wxT( " " ), wxT( "_" ) );
2011-04-18 20:22:17 +00:00
long oldNumber = m_number;
SetPinNumFromString( tmp );
if( m_number != oldNumber )
2013-03-30 19:55:26 +00:00
SetFlags( IS_CHANGED );
/* Others pin numbers marked by EnableEditMode() are not modified
* because each pin has its own number
*/
}
void LIB_PIN::SetNumberTextSize( int size )
{
if( size != m_numTextSize )
{
m_numTextSize = size;
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_numTextSize == size )
continue;
pinList[i]->m_numTextSize = size;
SetModified();
}
}
void LIB_PIN::SetOrientation( int orientation )
{
if( m_orientation != orientation )
{
m_orientation = orientation;
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_orientation == orientation )
continue;
pinList[i]->m_orientation = orientation;
SetModified();
}
}
void LIB_PIN::SetShape( int aShape )
{
if( m_shape != aShape )
{
m_shape = aShape;
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
2011-04-18 20:22:17 +00:00
|| pinList[i]->m_Convert != m_Convert
|| pinList[i]->m_shape == aShape )
continue;
pinList[i]->m_shape = aShape;
SetModified();
}
}
void LIB_PIN::SetType( int aType )
{
if( aType < 0 )
aType = 0;
if( aType >= (int)PIN_ELECTRICAL_TYPE_CNT )
aType = PIN_ELECTRICAL_TYPE_CNT - 1;
if( m_type != aType )
{
m_type = aType;
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_type == aType )
continue;
pinList[i]->m_type = aType;
SetModified();
}
}
void LIB_PIN::SetLength( int length )
{
if( m_length != length )
{
m_length = length;
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
2011-04-18 20:22:17 +00:00
|| pinList[i]->m_Convert != m_Convert
|| pinList[i]->m_length == length )
continue;
pinList[i]->m_length = length;
SetModified();
}
}
void LIB_PIN::SetPartNumber( int part )
{
if( m_Unit == part )
return;
m_Unit = part;
SetModified();
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 ) )
continue;
GetParent()->RemoveDrawItem( (LIB_ITEM*) pin );
}
}
}
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 );
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 ) )
continue;
GetParent()->RemoveDrawItem( (LIB_ITEM*) pin );
}
}
}
void LIB_PIN::SetVisible( bool visible )
{
if( visible == IsVisible() )
return;
if( visible )
2011-05-06 13:56:26 +00:00
m_attributes &= ~PIN_INVISIBLE;
else
2011-05-06 13:56:26 +00:00
m_attributes |= PIN_INVISIBLE;
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]->IsVisible() == visible )
continue;
if( visible )
2011-05-06 13:56:26 +00:00
pinList[i]->m_attributes &= ~PIN_INVISIBLE;
else
2011-05-06 13:56:26 +00:00
pinList[i]->m_attributes |= PIN_INVISIBLE;
SetModified();
}
}
void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin )
{
LIB_PINS pinList;
if( GetParent() == NULL )
return;
GetParent()->GetPins( pinList );
for( size_t i = 0; i < pinList.size(); i++ )
{
if( pinList[i] == this )
continue;
if( ( pinList[i]->m_position == m_position )
2011-04-18 20:22:17 +00:00
&& ( pinList[i]->m_orientation == m_orientation )
&& !IsNew()
&& editPinByPin == false
&& enable )
2013-03-30 19:55:26 +00:00
pinList[i]->SetFlags( IS_LINKED | IN_EDIT );
else
2013-03-30 19:55:26 +00:00
pinList[i]->ClearFlags( IS_LINKED | IN_EDIT );
}
}
bool LIB_PIN::HitTest( const wxPoint& aPosition ) const
2009-06-13 17:06:07 +00:00
{
return HitTest( aPosition, 0, DefaultTransform );
2009-06-13 17:06:07 +00:00
}
bool LIB_PIN::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
2009-06-13 17:06:07 +00:00
{
if( aThreshold < 0 )
aThreshold = 0;
TRANSFORM transform = DefaultTransform;
DefaultTransform = aTransform;
EDA_RECT rect = GetBoundingBox();
rect.Inflate( aThreshold );
2009-06-13 17:06:07 +00:00
//Restore matrix
DefaultTransform = transform;
return rect.Contains( aPosition );
}
bool LIB_PIN::Save( OUTPUTFORMATTER& aFormatter )
{
wxString StringPinNum;
int Etype;
switch( m_type )
{
default:
case PIN_INPUT:
Etype = 'I';
break;
case PIN_OUTPUT:
Etype = 'O';
break;
case PIN_BIDI:
Etype = 'B';
break;
case PIN_TRISTATE:
Etype = 'T';
break;
case PIN_PASSIVE:
Etype = 'P';
break;
case PIN_UNSPECIFIED:
Etype = 'U';
break;
case PIN_POWER_IN:
Etype = 'W';
break;
case PIN_POWER_OUT:
Etype = 'w';
break;
case PIN_OPENCOLLECTOR:
Etype = 'C';
break;
case PIN_OPENEMITTER:
Etype = 'E';
break;
case PIN_NC:
Etype = 'N';
break;
}
* 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
PinStringNum( StringPinNum );
if( StringPinNum.IsEmpty() )
StringPinNum = wxT( "~" );
if( !m_name.IsEmpty() )
{
if( aFormatter.Print( 0, "X %s", TO_UTF8( m_name ) ) < 0 )
return false;
}
else
{
if( aFormatter.Print( 0, "X ~" ) < 0 )
return false;
}
if( aFormatter.Print( 0, " %s %d %d %d %c %d %d %d %d %c",
TO_UTF8( StringPinNum ), m_position.x, m_position.y,
(int) m_length, (int) m_orientation, m_numTextSize, m_nameTextSize,
m_Unit, m_Convert, Etype ) < 0 )
return false;
2011-05-06 13:56:26 +00:00
if( m_shape || !IsVisible() )
{
if( aFormatter.Print( 0, " " ) < 0 )
return false;
}
if( !IsVisible() && aFormatter.Print( 0, "N" ) < 0 )
return false;
if( m_shape & INVERT && aFormatter.Print( 0, "I" ) < 0 )
return false;
if( m_shape & CLOCK && aFormatter.Print( 0, "C" ) < 0 )
return false;
if( m_shape & LOWLEVEL_IN && aFormatter.Print( 0, "L" ) < 0 )
return false;
if( m_shape & LOWLEVEL_OUT && aFormatter.Print( 0, "V" ) < 0 )
return false;
if( m_shape & CLOCK_FALL && aFormatter.Print( 0, "F" ) < 0 )
return false;
if( m_shape & NONLOGIC && aFormatter.Print( 0, "X" ) < 0 )
return false;
if( aFormatter.Print( 0, "\n" ) < 0 )
return false;
2013-03-30 19:55:26 +00:00
ClearFlags( IS_CHANGED );
return true;
}
bool LIB_PIN::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
{
int i, j;
char pinAttrs[64];
char pinName[256];
char pinNum[64];
char pinOrient[64];
char pinType[64];
char* line = (char*) aLineReader;
*pinAttrs = 0;
i = sscanf( line + 2, "%255s %63s %d %d %d %63s %d %d %d %d %63s %63s", pinName,
pinNum, &m_position.x, &m_position.y, &m_length, pinOrient, &m_numTextSize,
&m_nameTextSize, &m_Unit, &m_Convert, pinType, pinAttrs );
if( i < 11 )
{
aErrorMsg.Printf( wxT( "pin only had %d parameters of the required 11 or 12" ), i );
return false;
}
m_orientation = pinOrient[0] & 255;
strncpy( (char*) &m_number, pinNum, 4 );
m_name = FROM_UTF8( pinName );
switch( *pinType & 255 )
{
case 'I':
m_type = PIN_INPUT;
break;
case 'O':
m_type = PIN_OUTPUT;
break;
case 'B':
m_type = PIN_BIDI;
break;
case 'T':
m_type = PIN_TRISTATE;
break;
case 'P':
m_type = PIN_PASSIVE;
break;
case 'U':
m_type = PIN_UNSPECIFIED;
break;
case 'W':
m_type = PIN_POWER_IN;
break;
case 'w':
m_type = PIN_POWER_OUT;
break;
case 'C':
m_type = PIN_OPENCOLLECTOR;
break;
case 'E':
m_type = PIN_OPENEMITTER;
break;
case 'N':
m_type = PIN_NC;
break;
default:
aErrorMsg.Printf( wxT( "unknown pin type [%c]" ), *pinType & 255 );
return false;
}
if( i == 12 ) /* Special Symbol defined */
{
for( j = strlen( pinAttrs ); j > 0; )
{
switch( pinAttrs[--j] )
{
case '~':
break;
case 'N':
2011-05-06 13:56:26 +00:00
m_attributes |= PIN_INVISIBLE;
break;
case 'I':
m_shape |= INVERT;
break;
case 'C':
m_shape |= CLOCK;
break;
case 'L':
m_shape |= LOWLEVEL_IN;
break;
case 'V':
m_shape |= LOWLEVEL_OUT;
break;
case 'F':
m_shape |= CLOCK_FALL;
break;
case 'X':
m_shape |= NONLOGIC;
break;
default:
aErrorMsg.Printf( wxT( "unknown pin attribute [%c]" ), pinAttrs[j] );
return false;
}
}
}
return true;
}
2011-04-18 20:22:17 +00:00
int LIB_PIN::GetPenSize() const
{
return ( m_width == 0 ) ? GetDefaultLineThickness() : m_width;
}
void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
wxDC* aDC,
const wxPoint& aOffset,
EDA_COLOR_T aColor,
GR_DRAWMODE aDrawMode,
void* aData,
const TRANSFORM& aTransform )
2008-09-13 18:59:57 +00:00
{
2011-05-06 13:56:26 +00:00
// Invisible pins are only drawn on request.
// They are drawn in GetInvisibleItemColor().
// in schematic, they are drawn only if m_showAllPins is true.
2011-05-06 13:56:26 +00:00
// In other windows, they are always drawn because we must see them.
if( ! IsVisible() )
2008-09-19 08:19:15 +00:00
{
2011-05-06 13:56:26 +00:00
EDA_DRAW_FRAME* frame = NULL;
2011-05-06 13:56:26 +00:00
if( aPanel && aPanel->GetParent() )
frame = (EDA_DRAW_FRAME*)aPanel->GetParent();
if( frame && frame->IsType( FRAME_SCH ) &&
! ((SCH_EDIT_FRAME*)frame)->GetShowAllPins() )
2008-09-19 08:19:15 +00:00
return;
2011-05-06 13:56:26 +00:00
aColor = GetInvisibleItemColor();
2008-09-19 08:19:15 +00:00
}
LIB_PART* Entry = GetParent();
// aData is used here as a bitfield of flags.
uintptr_t flags = (uintptr_t) aData;
bool drawPinText = flags & PIN_DRAW_TEXTS;
bool drawPinDangling = flags & PIN_DRAW_DANGLING;
2008-09-13 18:59:57 +00:00
/* Calculate pin orient taking in account the component 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( aTransform );
2008-09-13 18:59:57 +00:00
/* Calculate the pin position */
wxPoint pos1 = aTransform.TransformCoordinate( m_position ) + aOffset;
2008-09-13 18:59:57 +00:00
/* Drawing from the pin and the special symbol combination */
DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor, drawPinDangling );
2008-09-13 18:59:57 +00:00
if( drawPinText )
2008-09-13 18:59:57 +00:00
{
DrawPinTexts( aPanel, aDC, pos1, orient, Entry->GetPinNameOffset(),
Entry->ShowPinNumbers(), Entry->ShowPinNames(),
aColor, aDrawMode );
2008-09-13 18:59:57 +00:00
}
/* Set to one (1) to draw bounding box around pin to validate bounding
* box calculation. */
#if 0
2011-04-18 20:22:17 +00:00
EDA_RECT bBox = GetBoundingBox();
bBox.RevertYAxis();
bBox = aTransform.TransformCoordinate( bBox );
2011-04-18 20:22:17 +00:00
bBox.Move( aOffset );
GRRect( aPanel ? aPanel->GetClipBox() : NULL, aDC, bBox, 0, LIGHTMAGENTA );
#endif
2008-09-13 18:59:57 +00:00
}
void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
wxDC* aDC,
const wxPoint& aPinPos,
int aOrient,
GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor,
bool aDrawDangling )
2008-09-13 18:59:57 +00:00
{
2011-04-18 20:22:17 +00:00
int MapX1, MapY1, x1, y1;
int width = GetPenSize();
int posX = aPinPos.x, posY = aPinPos.y, len = m_length;
EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
2008-09-13 18:59:57 +00:00
EDA_COLOR_T color = GetLayerColor( LAYER_PIN );
2008-09-13 18:59:57 +00:00
if( aColor < 0 ) // Used normal color or selected color
{
if( IsSelected() )
color = GetItemSelectedColor();
2008-09-13 18:59:57 +00:00
}
else
color = aColor;
GRSetDrawMode( aDC, aDrawMode );
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 )
{
case PIN_UP:
2011-04-18 20:22:17 +00:00
y1 = posY - len;
MapY1 = 1;
2008-09-13 18:59:57 +00:00
break;
case PIN_DOWN:
2011-04-18 20:22:17 +00:00
y1 = posY + len;
MapY1 = -1;
2008-09-13 18:59:57 +00:00
break;
case PIN_LEFT:
2011-04-18 20:22:17 +00:00
x1 = posX - len;
MapX1 = 1;
2008-09-13 18:59:57 +00:00
break;
case PIN_RIGHT:
2011-04-18 20:22:17 +00:00
x1 = posX + len;
MapX1 = -1;
2008-09-13 18:59:57 +00:00
break;
}
if( m_shape & INVERT )
2008-09-13 18:59:57 +00:00
{
const int radius = ExternalPinDecoSize( *this );
GRCircle( clipbox, aDC, MapX1 * radius + x1,
MapY1 * radius + y1,
radius, width, color );
2008-09-13 18:59:57 +00:00
GRMoveTo( MapX1 * radius * 2 + x1,
MapY1 * radius * 2 + y1 );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox, aDC, posX, posY, width, color );
2008-09-13 18:59:57 +00:00
}
else if( m_shape & CLOCK_FALL ) /* an alternative for Inverted Clock */
{
const int clock_size = InternalPinDecoSize( *this );
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1, y1 + clock_size );
GRLineTo( clipbox,
aDC,
x1 + MapX1 * clock_size * 2,
y1,
width,
color );
GRLineTo( clipbox,
aDC,
x1,
y1 - clock_size,
width,
color );
}
else /* MapX1 = 0 */
{
GRMoveTo( x1 + clock_size, y1 );
GRLineTo( clipbox,
aDC,
x1,
y1 + MapY1 * clock_size * 2,
width,
color );
GRLineTo( clipbox,
aDC,
x1 - clock_size,
y1,
width,
color );
}
GRMoveTo( MapX1 * clock_size * 2 + x1,
MapY1 * clock_size * 2 + y1 );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox, aDC, posX, posY, width, color );
}
2008-09-13 18:59:57 +00:00
else
{
GRMoveTo( x1, y1 );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox, aDC, posX, posY, width, color );
2008-09-13 18:59:57 +00:00
}
if( m_shape & CLOCK )
2008-09-13 18:59:57 +00:00
{
const int clock_size = InternalPinDecoSize( *this );
2008-09-13 18:59:57 +00:00
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1, y1 + clock_size );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox,
aDC,
x1 - MapX1 * clock_size * 2,
y1,
width,
color );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox,
aDC,
x1,
y1 - clock_size,
width,
color );
2008-09-13 18:59:57 +00:00
}
else /* MapX1 = 0 */
{
GRMoveTo( x1 + clock_size, y1 );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox,
aDC,
x1,
y1 - MapY1 * clock_size * 2,
width,
color );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox,
aDC,
x1 - clock_size,
y1,
width,
color );
2008-09-13 18:59:57 +00:00
}
}
2011-04-18 20:22:17 +00:00
if( m_shape & LOWLEVEL_IN ) /* IEEE symbol "Active Low Input" */
2008-09-13 18:59:57 +00:00
{
const int symbol_size = ExternalPinDecoSize( *this );
2008-09-13 18:59:57 +00:00
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1 + MapX1 * symbol_size * 2, y1 );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox,
aDC,
x1 + MapX1 * symbol_size * 2,
y1 - symbol_size * 2,
width,
color );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox, aDC, x1, y1, width, color );
2008-09-13 18:59:57 +00:00
}
else /* MapX1 = 0 */
{
GRMoveTo( x1, y1 + MapY1 * symbol_size * 2 );
GRLineTo( clipbox, aDC, x1 - symbol_size * 2,
y1 + MapY1 * symbol_size * 2, width, color );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox, aDC, x1, y1, width, color );
2008-09-13 18:59:57 +00:00
}
}
2011-04-18 20:22:17 +00:00
if( m_shape & LOWLEVEL_OUT ) /* IEEE symbol "Active Low Output" */
2008-09-13 18:59:57 +00:00
{
const int symbol_size = ExternalPinDecoSize( *this );
2008-09-13 18:59:57 +00:00
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1, y1 - symbol_size * 2 );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox,
aDC,
x1 + MapX1 * symbol_size * 2,
y1,
width,
color );
2008-09-13 18:59:57 +00:00
}
else /* MapX1 = 0 */
{
GRMoveTo( x1 - symbol_size * 2, y1 );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox,
aDC,
x1,
y1 + MapY1 * symbol_size * 2,
width,
color );
2008-09-13 18:59:57 +00:00
}
}
else if( m_shape & NONLOGIC ) /* NonLogic pin symbol */
{
const int symbol_size = ExternalPinDecoSize( *this );
GRMoveTo( x1 - (MapX1 + MapY1) * symbol_size,
y1 - (MapY1 - MapX1) * symbol_size );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox,
aDC,
x1 + (MapX1 + MapY1) * symbol_size,
y1 + (MapY1 - MapX1) * symbol_size,
width,
color );
GRMoveTo( x1 - (MapX1 - MapY1) * symbol_size,
y1 - (MapY1 + MapX1) * symbol_size );
2011-04-18 20:22:17 +00:00
GRLineTo( clipbox,
aDC,
x1 + (MapX1 - MapY1) * symbol_size,
y1 + (MapY1 + MapX1) * symbol_size,
width,
color );
}
// Draw the pin end target (active end of the pin)
2011-04-18 20:22:17 +00:00
BASE_SCREEN* screen = aPanel ? aPanel->GetScreen() : NULL;
#define NCSYMB_PIN_DIM TARGET_PIN_RADIUS
if( m_type == PIN_NC ) // Draw a N.C. symbol
{
2011-04-18 20:22:17 +00:00
GRLine( clipbox, aDC,
posX - NCSYMB_PIN_DIM, posY - NCSYMB_PIN_DIM,
posX + NCSYMB_PIN_DIM, posY + NCSYMB_PIN_DIM,
width, color );
GRLine( clipbox, aDC,
posX + NCSYMB_PIN_DIM, posY - NCSYMB_PIN_DIM,
posX - NCSYMB_PIN_DIM, posY + NCSYMB_PIN_DIM,
width, color );
}
// Draw but do not print the pin end target 1 pixel width
2011-04-18 20:22:17 +00:00
else if( screen == NULL || !screen->m_IsPrinting )
{
if( aDrawDangling )
GRCircle( clipbox, aDC, posX, posY, TARGET_PIN_RADIUS, 0, color );
}
2008-09-13 18:59:57 +00:00
}
void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
wxDC* DC,
wxPoint& pin_pos,
int orient,
int TextInside,
bool DrawPinNum,
bool DrawPinName,
EDA_COLOR_T Color,
GR_DRAWMODE DrawMode )
2008-09-13 18:59:57 +00:00
{
int x, y, x1, y1;
wxString StringPinNum;
EDA_COLOR_T NameColor, NumColor;
2008-09-13 18:59:57 +00:00
wxSize PinNameSize( m_nameTextSize, m_nameTextSize );
wxSize PinNumSize( m_numTextSize, m_numTextSize );
2008-09-13 18:59:57 +00:00
int nameLineWidth = GetPenSize();
2009-06-13 17:06:07 +00:00
nameLineWidth = Clamp_Text_PenSize( nameLineWidth, m_nameTextSize, false );
2011-04-18 20:22:17 +00:00
int numLineWidth = GetPenSize();
numLineWidth = Clamp_Text_PenSize( numLineWidth, m_numTextSize, false );
2008-09-13 18:59:57 +00:00
GRSetDrawMode( DC, DrawMode );
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
2008-09-13 18:59:57 +00:00
/* Get the num and name colors */
if( (Color < 0) && IsSelected() )
Color = GetItemSelectedColor();
NameColor = (EDA_COLOR_T) ( Color == UNSPECIFIED_COLOR ?
GetLayerColor( LAYER_PINNAM ) : Color );
NumColor = (EDA_COLOR_T) ( Color == UNSPECIFIED_COLOR ?
GetLayerColor( LAYER_PINNUM ) : Color );
2008-09-13 18:59:57 +00:00
/* Create the pin num string */
* 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
PinStringNum( StringPinNum );
2008-09-13 18:59:57 +00:00
x1 = pin_pos.x;
y1 = pin_pos.y;
2008-09-13 18:59:57 +00:00
switch( orient )
{
case PIN_UP:
y1 -= m_length;
break;
2008-09-13 18:59:57 +00:00
case PIN_DOWN:
y1 += m_length;
break;
2008-09-13 18:59:57 +00:00
case PIN_LEFT:
x1 -= m_length;
break;
2008-09-13 18:59:57 +00:00
case PIN_RIGHT:
x1 += m_length;
break;
2008-09-13 18:59:57 +00:00
}
if( m_name.IsEmpty() )
DrawPinName = false;
2008-09-13 18:59:57 +00:00
if( TextInside ) /* Draw the text inside, but the pin numbers outside. */
{
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
{
// It is an horizontal line
if( DrawPinName )
2008-09-13 18:59:57 +00:00
{
if( orient == PIN_RIGHT )
{
x = x1 + TextInside;
DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor,
m_name,
TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
2009-05-28 17:39:40 +00:00
false, false );
2008-09-13 18:59:57 +00:00
}
else // Orient == PIN_LEFT
{
x = x1 - TextInside;
DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor,
m_name,
TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
2009-05-28 17:39:40 +00:00
false, false );
2008-09-13 18:59:57 +00:00
}
}
if( DrawPinNum )
{
DrawGraphicText( clipbox, DC,
wxPoint( (x1 + pin_pos.x) / 2,
2011-04-18 20:22:17 +00:00
y1 - TXTMARGE ), NumColor,
StringPinNum,
TEXT_ORIENT_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. */
{
// Text is drawn from bottom to top (i.e. to negative value for Y axis)
if( orient == PIN_DOWN )
2008-09-13 18:59:57 +00:00
{
y = y1 + TextInside;
2008-09-13 18:59:57 +00:00
if( DrawPinName )
DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor,
m_name,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
2009-05-28 17:39:40 +00:00
false, false );
if( DrawPinNum )
DrawGraphicText( clipbox, DC,
wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ), NumColor,
StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
2009-06-13 17:06:07 +00:00
false, false );
}
else /* PIN_UP */
{
y = y1 - TextInside;
2008-09-13 18:59:57 +00:00
if( DrawPinName )
DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor,
m_name,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
2009-05-28 17:39:40 +00:00
false, false );
if( DrawPinNum )
DrawGraphicText( clipbox, DC,
wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ), NumColor,
StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
2009-06-13 17:06:07 +00:00
false, false );
2008-09-13 18:59:57 +00:00
}
}
}
else /**** Draw num & text pin outside ****/
{
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
{
/* Its an horizontal line. */
if( DrawPinName )
2008-09-13 18:59:57 +00:00
{
x = (x1 + pin_pos.x) / 2;
DrawGraphicText( clipbox, DC, wxPoint( x, y1 - TXTMARGE ),
NameColor, m_name,
TEXT_ORIENT_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth,
2009-05-28 17:39:40 +00:00
false, false );
2008-09-13 18:59:57 +00:00
}
if( DrawPinNum )
{
x = (x1 + pin_pos.x) / 2;
DrawGraphicText( clipbox, DC, wxPoint( x, y1 + TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, numLineWidth,
2009-06-13 17:06:07 +00:00
false, false );
2008-09-13 18:59:57 +00:00
}
}
else /* Its a vertical line. */
{
if( DrawPinName )
2008-09-13 18:59:57 +00:00
{
y = (y1 + pin_pos.y) / 2;
DrawGraphicText( clipbox, DC, wxPoint( x1 - TXTMARGE, y ),
NameColor, m_name,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth,
false, false );
2008-09-13 18:59:57 +00:00
}
if( DrawPinNum )
{
DrawGraphicText( clipbox, DC,
wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_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
void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
{
int MapX1, MapY1, x1, y1;
EDA_COLOR_T color = GetLayerColor( LAYER_PIN );
aPlotter->SetColor( color );
MapX1 = MapY1 = 0;
x1 = aPosition.x; y1 = aPosition.y;
switch( aOrientation )
{
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;
}
if( m_shape & INVERT )
{
const int radius = ExternalPinDecoSize( *this );
aPlotter->Circle( wxPoint( MapX1 * radius + x1,
MapY1 * radius + y1 ),
radius * 2, // diameter
NO_FILL, // fill option
GetPenSize() ); // width
aPlotter->MoveTo( wxPoint( MapX1 * radius * 2 + x1,
MapY1 * radius * 2 + y1 ) );
aPlotter->FinishTo( aPosition );
}
else if( m_shape & CLOCK_FALL )
{
const int clock_size = InternalPinDecoSize( *this );
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
aPlotter->MoveTo( wxPoint( x1, y1 + clock_size ) );
aPlotter->LineTo( wxPoint( x1 + MapX1 * clock_size * 2, y1 ) );
aPlotter->FinishTo( wxPoint( x1, y1 - clock_size ) );
}
else /* MapX1 = 0 */
{
aPlotter->MoveTo( wxPoint( x1 + clock_size, y1 ) );
aPlotter->LineTo( wxPoint( x1, y1 + MapY1 * clock_size * 2 ) );
aPlotter->FinishTo( wxPoint( x1 - clock_size, y1 ) );
}
aPlotter->MoveTo( wxPoint( MapX1 * clock_size * 2 + x1,
MapY1 * clock_size * 2 + y1 ) );
aPlotter->FinishTo( aPosition );
}
else
{
aPlotter->MoveTo( wxPoint( x1, y1 ) );
aPlotter->FinishTo( aPosition );
}
if( m_shape & CLOCK )
{
const int clock_size = InternalPinDecoSize( *this );
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
aPlotter->MoveTo( wxPoint( x1, y1 + clock_size ) );
aPlotter->LineTo( wxPoint( x1 - MapX1 * clock_size * 2, y1 ) );
aPlotter->FinishTo( wxPoint( x1, y1 - clock_size ) );
}
else /* MapX1 = 0 */
{
aPlotter->MoveTo( wxPoint( x1 + clock_size, y1 ) );
aPlotter->LineTo( wxPoint( x1, y1 - MapY1 * clock_size * 2 ) );
aPlotter->FinishTo( wxPoint( x1 - clock_size, y1 ) );
}
}
if( m_shape & LOWLEVEL_IN ) /* IEEE symbol "Active Low Input" */
{
const int symbol_size = ExternalPinDecoSize( *this );
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
aPlotter->MoveTo( wxPoint( x1 + MapX1 * symbol_size * 2, y1 ) );
aPlotter->LineTo( wxPoint( x1 + MapX1 * symbol_size * 2,
y1 - symbol_size * 2 ) );
aPlotter->FinishTo( wxPoint( x1, y1 ) );
}
else /* MapX1 = 0 */
{
aPlotter->MoveTo( wxPoint( x1, y1 + MapY1 * symbol_size * 2 ) );
aPlotter->LineTo( wxPoint( x1 - symbol_size * 2,
y1 + MapY1 * symbol_size * 2 ) );
aPlotter->FinishTo( wxPoint( x1, y1 ) );
}
}
if( m_shape & LOWLEVEL_OUT ) /* IEEE symbol "Active Low Output" */
{
const int symbol_size = ExternalPinDecoSize( *this );
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
aPlotter->MoveTo( wxPoint( x1, y1 - symbol_size * 2 ) );
aPlotter->FinishTo( wxPoint( x1 + MapX1 * symbol_size * 2, y1 ) );
}
else /* MapX1 = 0 */
{
aPlotter->MoveTo( wxPoint( x1 - symbol_size * 2, y1 ) );
aPlotter->FinishTo( wxPoint( x1, y1 + MapY1 * symbol_size * 2 ) );
}
}
else if( m_shape & NONLOGIC ) /* NonLogic pin symbol */
{
const int symbol_size = ExternalPinDecoSize( *this );
aPlotter->MoveTo( wxPoint( x1 - (MapX1 + MapY1) * symbol_size,
y1 - (MapY1 - MapX1) * symbol_size ) );
aPlotter->FinishTo( wxPoint( x1 + (MapX1 + MapY1) * symbol_size,
y1 + (MapY1 - MapX1) * symbol_size ) );
aPlotter->MoveTo( wxPoint( x1 - (MapX1 - MapY1) * symbol_size,
y1 - (MapY1 + MapX1) * symbol_size ) );
aPlotter->FinishTo( wxPoint( x1 + (MapX1 - MapY1) * symbol_size,
y1 + (MapY1 + MapX1) * symbol_size ) );
}
if( m_type == PIN_NC ) // Draw a N.C. symbol
{
const int ex1 = aPosition.x;
const int ey1 = aPosition.y;
aPlotter->MoveTo( wxPoint( ex1 - NCSYMB_PIN_DIM, ey1 - NCSYMB_PIN_DIM ) );
aPlotter->FinishTo( wxPoint( ex1 + NCSYMB_PIN_DIM, ey1 + NCSYMB_PIN_DIM ) );
aPlotter->MoveTo( wxPoint( ex1 + NCSYMB_PIN_DIM, ey1 - NCSYMB_PIN_DIM ) );
aPlotter->FinishTo( wxPoint( ex1 - NCSYMB_PIN_DIM, ey1 + NCSYMB_PIN_DIM ) );
}
}
2011-04-18 20:22:17 +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
{
int x, y, x1, y1;
wxString StringPinNum;
EDA_COLOR_T NameColor, NumColor;
wxSize PinNameSize = wxSize( m_nameTextSize, m_nameTextSize );
wxSize PinNumSize = wxSize( m_numTextSize, m_numTextSize );
2008-09-13 19:06:31 +00:00
/* Get the num and name colors */
NameColor = GetLayerColor( LAYER_PINNAM );
NumColor = GetLayerColor( LAYER_PINNUM );
2008-09-13 19:06:31 +00:00
/* Create the pin num string */
* 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
PinStringNum( StringPinNum );
x1 = pin_pos.x;
y1 = pin_pos.y;
2008-09-13 19:06:31 +00:00
switch( orient )
{
case PIN_UP:
y1 -= m_length;
break;
2008-09-13 19:06:31 +00:00
case PIN_DOWN:
y1 += m_length;
break;
2008-09-13 19:06:31 +00:00
case PIN_LEFT:
x1 -= m_length;
break;
2008-09-13 19:06:31 +00:00
case PIN_RIGHT:
x1 += m_length;
break;
2008-09-13 19:06:31 +00:00
}
if( m_name.IsEmpty() )
DrawPinName = false;
2008-09-13 19:06:31 +00:00
/* Draw the text inside, but the pin numbers outside. */
if( TextInside )
2008-09-13 19:06:31 +00:00
{
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) /* Its an horizontal line. */
{
if( DrawPinName )
2008-09-13 19:06:31 +00:00
{
if( orient == PIN_RIGHT )
{
x = x1 + TextInside;
plotter->Text( wxPoint( x, y1 ), NameColor,
m_name,
TEXT_ORIENT_HORIZ,
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;
if( DrawPinName )
plotter->Text( wxPoint( x, y1 ),
NameColor, m_name, TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER,
aWidth, false, false );
}
2009-09-25 13:59:42 +00:00
}
if( DrawPinNum )
{
plotter->Text( wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ),
2009-09-25 13:59:42 +00:00
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, false, false );
2008-09-13 19:06:31 +00:00
}
}
else /* Its a vertical line. */
{
if( orient == PIN_DOWN )
2008-09-13 19:06:31 +00:00
{
y = y1 + TextInside;
2008-09-13 19:06:31 +00:00
if( DrawPinName )
plotter->Text( wxPoint( x1, y ), NameColor,
m_name,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER,
aWidth, false, false );
if( DrawPinNum )
2008-09-13 19:06:31 +00:00
{
plotter->Text( wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, false, false );
}
}
else /* PIN_UP */
{
y = y1 - TextInside;
2008-09-13 19:06:31 +00:00
if( DrawPinName )
plotter->Text( wxPoint( x1, y ), NameColor,
m_name,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER,
aWidth, false, false );
if( DrawPinNum )
{
plotter->Text( wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
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) )
{
/* Its an horizontal line. */
if( DrawPinName )
2008-09-13 19:06:31 +00:00
{
x = (x1 + pin_pos.x) / 2;
plotter->Text( wxPoint( x, y1 - TXTMARGE ),
NameColor, m_name,
TEXT_ORIENT_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, false, false );
2008-09-13 19:06:31 +00:00
}
2008-09-13 19:06:31 +00:00
if( DrawPinNum )
{
x = ( x1 + pin_pos.x ) / 2;
plotter->Text( wxPoint( x, y1 + TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP,
aWidth, false, false );
2008-09-13 19:06:31 +00:00
}
}
else /* Its a vertical line. */
{
if( DrawPinName )
2008-09-13 19:06:31 +00:00
{
y = ( y1 + pin_pos.y ) / 2;
plotter->Text( wxPoint( x1 - TXTMARGE, y ),
NameColor, m_name,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
aWidth, false, false );
2008-09-13 19:06:31 +00:00
}
if( DrawPinNum )
{
plotter->Text( wxPoint( x1 + TXTMARGE, ( y1 + pin_pos.y ) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
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
{
wxPoint pos = m_position;
2008-09-14 04:27:22 +00:00
switch( m_orientation )
2008-09-14 04:27:22 +00:00
{
case PIN_UP:
pos.y += m_length;
break;
2008-09-14 04:27:22 +00:00
case PIN_DOWN:
pos.y -= m_length;
break;
2008-09-14 04:27:22 +00:00
case PIN_LEFT:
pos.x -= m_length;
break;
2008-09-14 04:27:22 +00:00
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
{
int orient;
wxPoint end; // position of pin end starting at 0,0 according to its orientation, length = 1
2008-09-14 04:27:22 +00:00
switch( m_orientation )
2008-09-14 04:27:22 +00:00
{
case PIN_UP:
end.y = 1;
break;
2008-09-14 04:27:22 +00:00
case PIN_DOWN:
end.y = -1;
break;
2008-09-14 04:27:22 +00:00
case PIN_LEFT:
end.x = -1;
break;
2008-09-14 04:27:22 +00:00
case PIN_RIGHT:
end.x = 1;
break;
2008-09-14 04:27:22 +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;
if( end.x == 0 )
2008-09-14 04:27:22 +00:00
{
if( end.y > 0 )
2008-09-14 04:27:22 +00:00
orient = PIN_DOWN;
}
else
{
orient = PIN_RIGHT;
if( end.x < 0 )
2008-09-14 04:27:22 +00:00
orient = PIN_LEFT;
}
return orient;
}
* 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
void LIB_PIN::PinStringNum( wxString& aStringBuffer ) const
{
* 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
aStringBuffer = PinStringNum( m_number );
}
* 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
wxString LIB_PIN::PinStringNum( long aPinNum )
2008-09-14 04:27:22 +00:00
{
char ascii_buf[5];
memcpy( ascii_buf, &aPinNum, 4 );
2008-09-14 04:27:22 +00:00
ascii_buf[4] = 0;
wxString buffer = FROM_UTF8( ascii_buf );
return buffer;
2008-09-14 04:27:22 +00:00
}
void LIB_PIN::SetPinNumFromString( wxString& buffer )
2008-09-14 04:27:22 +00:00
{
char ascii_buf[4];
unsigned ii, len = buffer.Len();
ascii_buf[0] = ascii_buf[1] = ascii_buf[2] = ascii_buf[3] = 0;
2008-09-14 04:27:22 +00:00
if( len > 4 )
len = 4;
2008-09-14 04:27:22 +00:00
for( ii = 0; ii < len; ii++ )
{
ascii_buf[ii] = buffer.GetChar( ii );
ascii_buf[ii] &= 0xFF;
2008-09-14 04:27:22 +00:00
}
strncpy( (char*) &m_number, ascii_buf, 4 );
2008-09-14 04:27:22 +00:00
}
EDA_ITEM* LIB_PIN::Clone() const
2008-09-14 04:27:22 +00:00
{
return new LIB_PIN( *this );
2008-09-14 04:27:22 +00:00
}
int LIB_PIN::compare( const LIB_ITEM& other ) const
{
wxASSERT( other.Type() == LIB_PIN_T );
2011-04-18 20:22:17 +00:00
const LIB_PIN* tmp = (LIB_PIN*) &other;
if( m_number != tmp->m_number )
return m_number - tmp->m_number;
int result = m_name.CmpNoCase( tmp->m_name );
if( result != 0 )
return result;
if( m_position.x != tmp->m_position.x )
return m_position.x - tmp->m_position.x;
if( m_position.y != tmp->m_position.y )
return m_position.y - tmp->m_position.y;
return 0;
}
void LIB_PIN::SetOffset( const wxPoint& aOffset )
{
m_position += aOffset;
}
bool LIB_PIN::Inside( EDA_RECT& rect ) const
{
* 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();
return rect.Contains( m_position.x, -m_position.y ) || rect.Contains( end.x, -end.y );
}
void LIB_PIN::Move( const wxPoint& newPosition )
{
if( m_position != newPosition )
{
m_position = newPosition;
SetModified();
}
}
void LIB_PIN::MirrorHorizontal( const wxPoint& center )
{
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;
}
void LIB_PIN::MirrorVertical( const wxPoint& center )
{
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;
}
void LIB_PIN::Rotate( const wxPoint& center, bool aRotateCCW )
{
int rot_angle = aRotateCCW ? -900 : 900;
RotatePoint( &m_position, center, rot_angle );
if( aRotateCCW )
{
switch( m_orientation )
{
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;
}
}
else
{
switch( m_orientation )
{
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;
}
}
}
void LIB_PIN::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const TRANSFORM& aTransform )
{
2011-05-06 13:56:26 +00:00
if( ! IsVisible() )
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 );
wxPoint pos = aTransform.TransformCoordinate( m_position ) + offset;
plotter->SetCurrentLineWidth( GetPenSize() );
PlotSymbol( plotter, pos, orient );
PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(),
GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(),
GetPenSize() );
}
void LIB_PIN::SetWidth( int aWidth )
{
if( m_width != aWidth )
{
m_width = aWidth;
SetModified();
}
}
void LIB_PIN::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
{
wxString text;
LIB_ITEM::GetMsgPanelInfo( aList );
aList.push_back( MSG_PANEL_ITEM( _( "Name" ), m_name, DARKCYAN ) );
if( m_number == 0 )
text = wxT( "?" );
else
PinStringNum( text );
aList.push_back( MSG_PANEL_ITEM( _( "Number" ), text, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Type" ),
LIB_PIN::GetElectricalTypeName( m_type ),
RED ) );
int styleCodeIndex = GetStyleCodeIndex( m_shape );
if( styleCodeIndex >= 0 )
text = getPinStyleName( styleCodeIndex );
else
text = wxT( "?" );
aList.push_back( MSG_PANEL_ITEM( _( "Style" ), text, BLUE ) );
if( IsVisible() )
text = _( "Yes" );
else
text = _( "No" );
aList.push_back( MSG_PANEL_ITEM( _( "Visible" ), text, DARKGREEN ) );
// Display pin length
text = StringFromValue( g_UserUnit, m_length, true );
aList.push_back( MSG_PANEL_ITEM( _( "Length" ), text, MAGENTA ) );
text = getPinOrientationName( (unsigned) GetOrientationCodeIndex( m_orientation ) );
aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), text, DARKMAGENTA ) );
}
const EDA_RECT LIB_PIN::GetBoundingBox() const
{
LIB_PART* entry = (LIB_PART* ) m_Parent;
2011-04-18 20:22:17 +00:00
EDA_RECT bbox;
wxPoint begin;
wxPoint end;
int nameTextOffset = 0;
bool showName = !m_name.IsEmpty() && (m_name != wxT( "~" ));
bool showNum = m_number != 0;
int minsizeV = TARGET_PIN_RADIUS;
2011-04-18 20:22:17 +00:00
if( entry )
{
if( entry->ShowPinNames() )
nameTextOffset = entry->GetPinNameOffset();
else
showName = false;
showNum = entry->ShowPinNumbers();
}
2011-04-18 20:22:17 +00:00
// First, calculate boundary box corners position
int numberTextLength = showNum ? m_numTextSize * GetNumberString().Len() : 0;
2011-04-18 20:22:17 +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;
if( m_shape & INVERT )
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)
begin.y = std::max( minsizeV, numberTextHeight + TXTMARGE );
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
int nameTextLength = 0;
int nameTextHeight = 0;
if( showName )
{
int length = m_name.Len();
// Don't count the line over text symbol.
if( m_name.Left( 1 ) == wxT( "~" ) )
length -= 1;
nameTextLength = ( m_nameTextSize * length ) + nameTextOffset;
// Actual text height are 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
nameTextHeight = KiROUND( m_nameTextSize * 1.1 ) + TXTMARGE;
}
if( nameTextOffset ) // for values > 0, pin name is inside the body
{
end.x = m_length + nameTextLength;
end.y = std::min( -minsizeV, -nameTextHeight / 2 );
}
else // if value == 0:
// pin name is outside the body, and above the pin line
// pin num is below the pin line
{
end.x = std::max(m_length, nameTextLength);
end.y = -begin.y;
begin.y = std::max( minsizeV, nameTextHeight );
}
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 );
/* 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;
2011-04-18 20:22:17 +00:00
case PIN_DOWN:
RotatePoint( &begin, wxPoint( 0, 0 ), 900 );
RotatePoint( &end, wxPoint( 0, 0 ), 900 );
begin.x = -begin.x;
end.x = -end.x;
2011-04-18 20:22:17 +00:00
break;
case PIN_LEFT:
begin.x = -begin.x;
end.x = -end.x;
2011-04-18 20:22:17 +00:00
break;
case PIN_RIGHT:
break;
}
begin += m_position;
end += m_position;
2011-04-18 20:22:17 +00:00
bbox.SetOrigin( begin );
bbox.SetEnd( end );
2011-04-18 20:22:17 +00:00
bbox.Normalize();
bbox.Inflate( ( GetPenSize() / 2 ) + 1 );
// Draw Y axis is reversed in schematic:
bbox.RevertYAxis();
2011-04-18 20:22:17 +00:00
return bbox;
}
wxArrayString LIB_PIN::GetOrientationNames( void )
{
wxArrayString tmp;
for( unsigned ii = 0; ii < PIN_ORIENTATION_CNT; ii++ )
tmp.Add( getPinOrientationName( ii ) );
return tmp;
}
int LIB_PIN::GetOrientationCode( int index )
{
if( index >= 0 && index < (int) PIN_ORIENTATION_CNT )
return pin_orientation_codes[ index ];
return PIN_RIGHT;
}
int LIB_PIN::GetOrientationCodeIndex( int code )
{
size_t i;
for( i = 0; i < PIN_ORIENTATION_CNT; i++ )
{
if( pin_orientation_codes[i] == code )
return (int) i;
}
return wxNOT_FOUND;
}
void LIB_PIN::Rotate()
{
2011-05-05 18:43:56 +00:00
int orient = PIN_RIGHT;
2011-05-05 18:43:56 +00:00
switch( GetOrientation() )
{
case PIN_UP:
orient = PIN_LEFT;
break;
case PIN_DOWN:
orient = PIN_RIGHT;
break;
case PIN_LEFT:
orient = PIN_DOWN;
break;
case PIN_RIGHT:
orient = PIN_UP;
break;
}
2011-04-18 20:22:17 +00:00
// Set the new orientation
2011-05-05 18:43:56 +00:00
SetOrientation( orient );
}
wxArrayString LIB_PIN::GetStyleNames( void )
{
wxArrayString tmp;
for( unsigned ii = 0; ii < PIN_STYLE_CNT; ii++ )
tmp.Add( getPinStyleName( ii ) );
return tmp;
}
int LIB_PIN::GetStyleCode( int index )
{
if( index >= 0 && index < (int) PIN_STYLE_CNT )
return pin_style_codes[ index ];
return NONE;
}
int LIB_PIN::GetStyleCodeIndex( int code )
{
size_t i;
for( i = 0; i < PIN_STYLE_CNT; i++ )
{
if( pin_style_codes[i] == code )
return (int) i;
}
return wxNOT_FOUND;
}
wxArrayString LIB_PIN::GetElectricalTypeNames( void )
{
wxArrayString tmp;
for( unsigned ii = 0; ii < PIN_ELECTRICAL_TYPE_CNT; ii++ )
tmp.Add( LIB_PIN::GetElectricalTypeName( ii ) );
return tmp;
}
const BITMAP_DEF* LIB_PIN::GetElectricalTypeSymbols()
{
return iconsPinsElectricalType;
}
const BITMAP_DEF* LIB_PIN::GetOrientationSymbols()
{
return iconsPinsOrientations;
}
const BITMAP_DEF* LIB_PIN::GetStyleSymbols()
{
return iconsPinsShapes;
}
2011-04-18 20:22:17 +00:00
BITMAP_DEF LIB_PIN::GetMenuImage() const
{
return iconsPinsElectricalType[m_type];
}
wxString LIB_PIN::GetSelectMenuText() const
{
2011-03-26 10:08:50 +00:00
wxString tmp;
wxString style;
int styleCode = GetStyleCodeIndex( m_shape );
if( styleCode >= 0 )
style = getPinStyleName( styleCode );
else
style = wxT( "?" );
2011-04-18 20:22:17 +00:00
2011-03-26 10:08:50 +00:00
tmp.Printf( _( "Pin %s, %s, %s" ),
GetChars( GetNumberString() ),
GetChars( GetElectricalTypeName() ),
GetChars( style )
2011-04-18 20:22:17 +00:00
);
2011-03-26 10:08:50 +00:00
return tmp;
}
bool LIB_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation )
{
wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() );
// 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.
if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_PINS )
|| ( aSearchData.GetFlags() & FR_SEARCH_REPLACE ) )
return false;
wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText() );
if( EDA_ITEM::Matches( GetName(), aSearchData )
|| EDA_ITEM::Matches( GetNumberString(), aSearchData ) )
{
if( aFindLocation )
*aFindLocation = GetBoundingBox().Centre();
return true;
}
return false;
}
#if defined(DEBUG)
void LIB_PIN::Show( int nestLevel, std::ostream& os ) const
{
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
<< " num=\"" << GetNumberString().mb_str()
<< '"' << "/>\n";
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
}
#endif