Component Editor and Component viewer: add option to show the electrical pin type.

This commit is contained in:
jean-pierre charras 2016-11-04 12:13:22 +01:00
parent 9a09b0cb3c
commit f15a59f0ad
18 changed files with 272 additions and 26 deletions

View File

@ -316,7 +316,8 @@ void LIB_PART::SetName( const wxString& aName )
void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, int aMulti,
int aConvert, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor,
const TRANSFORM& aTransform, bool aShowPinText, bool aDrawFields,
bool aOnlySelected, const std::vector<bool>* aPinsDangling )
bool aOnlySelected, const std::vector<bool>* aPinsDangling,
bool aShowElectricalType )
{
BASE_SCREEN* screen = aPanel ? aPanel->GetScreen() : NULL;
@ -394,6 +395,9 @@ void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
if( aShowPinText )
flags |= PIN_DRAW_TEXTS;
if( aShowElectricalType )
flags |= PIN_DRAW_ELECTRICAL_TYPE_NAME;
if( !aPinsDangling || (aPinsDangling->size() > pin_index && (*aPinsDangling)[pin_index] ) )
flags |= PIN_DRAW_DANGLING;

View File

@ -417,6 +417,8 @@ public:
* vector<bool> exactly the same length as the number of pins,
* indicating whether each pin is dangling. If NULL, all pins
* will be drawn as if they were dangling.
* @param aShowElectricalType - show the electrical type name of the pin
* used only in component editor and component viewer
*/
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
int aMulti, int aConvert, GR_DRAWMODE aDrawMode,
@ -424,7 +426,8 @@ public:
const TRANSFORM& aTransform = DefaultTransform,
bool aShowPinText = true, bool aDrawFields = true,
bool aOnlySelected = false,
const std::vector<bool>* aPinsDangling = NULL );
const std::vector<bool>* aPinsDangling = NULL,
bool aShowElectricalType = false );
/**
* Plot lib part to plotter.

View File

@ -86,6 +86,12 @@ public:
return m_spinRepeatLabel->GetValue();
}
void SetShowElectricalType( bool show ) { m_checkShowPinElectricalType->SetValue( show ); }
bool GetShowElectricalType( void )
{
return m_checkShowPinElectricalType->GetValue();
}
};
#endif // __DIALOG_LIBEDIT_OPTIONS__

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version May 6 2016)
// C++ code generated with wxFormBuilder (version Sep 8 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -146,7 +146,10 @@ DIALOG_LIBEDIT_OPTIONS_BASE::DIALOG_LIBEDIT_OPTIONS_BASE( wxWindow* parent, wxWi
bSizer2->Add( m_staticline3, 0, wxEXPAND | wxALL, 5 );
m_checkShowGrid = new wxCheckBox( this, wxID_ANY, _("&Show grid"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_checkShowGrid, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 3 );
bSizer2->Add( m_checkShowGrid, 0, wxEXPAND|wxALL, 3 );
m_checkShowPinElectricalType = new wxCheckBox( this, wxID_ANY, _("Show pin &electrical type"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_checkShowPinElectricalType, 0, wxALL, 3 );
bSizer3->Add( bSizer2, 0, wxEXPAND, 0 );

View File

@ -44,7 +44,7 @@
<property name="minimum_size"></property>
<property name="name">DIALOG_LIBEDIT_OPTIONS_BASE</property>
<property name="pos"></property>
<property name="size">499,368</property>
<property name="size">499,393</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Library Editor Options</property>
@ -2443,7 +2443,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">3</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT|wxEXPAND</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property>
@ -2529,6 +2529,94 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Show pin &amp;electrical type</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_checkShowPinElectricalType</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version May 6 2016)
// C++ code generated with wxFormBuilder (version Sep 8 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -67,6 +67,7 @@ class DIALOG_LIBEDIT_OPTIONS_BASE : public DIALOG_SHIM
wxSpinCtrl* m_spinRepeatLabel;
wxStaticLine* m_staticline3;
wxCheckBox* m_checkShowGrid;
wxCheckBox* m_checkShowPinElectricalType;
wxStaticLine* m_staticline2;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
@ -74,7 +75,7 @@ class DIALOG_LIBEDIT_OPTIONS_BASE : public DIALOG_SHIM
public:
DIALOG_LIBEDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Library Editor Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 499,368 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_LIBEDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Library Editor Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 499,393 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_LIBEDIT_OPTIONS_BASE();
};

View File

@ -536,6 +536,7 @@ static const wxChar repeatLibLabelIncEntry[] = wxT( "LibeditRepeatLabelInc"
static const wxChar pinRepeatStepEntry[] = wxT( "LibeditPinRepeatStep" );
static const wxChar repeatLibStepXEntry[] = wxT( "LibeditRepeatStepX" );
static const wxChar repeatLibStepYEntry[] = wxT( "LibeditRepeatStepY" );
static const wxChar showPinElectricalType[] = wxT( "LibeditShowPinElectricalType" );
///@}
@ -756,6 +757,7 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
step.x = aCfg->Read( repeatLibStepXEntry, (long)DEFAULT_REPEAT_OFFSET_X );
step.y = aCfg->Read( repeatLibStepYEntry, (long)DEFAULT_REPEAT_OFFSET_Y );
SetRepeatStep( step );
m_showPinElectricalTypeName = aCfg->Read( showPinElectricalType, true );
}
@ -770,6 +772,7 @@ void LIB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
aCfg->Write( pinRepeatStepEntry, (long) GetRepeatPinStep() );
aCfg->Write( repeatLibStepXEntry, (long) GetRepeatStep().x );
aCfg->Write( repeatLibStepYEntry, (long) GetRepeatStep().y );
aCfg->Write( showPinElectricalType, GetShowElectricalType() );
}
@ -787,6 +790,7 @@ void LIB_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
dlg.SetPinNameSize( m_textPinNameDefaultSize );
dlg.SetShowGrid( IsGridVisible() );
dlg.SetShowElectricalType( GetShowElectricalType() );
dlg.Layout();
dlg.Fit();
@ -804,6 +808,7 @@ void LIB_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
SetRepeatPinStep( dlg.GetPinRepeatStep() );
SetRepeatStep( dlg.GetItemRepeatStep() );
SetRepeatDeltaLabel( dlg.GetRepeatLabelInc() );
SetShowElectricalType( dlg.GetShowElectricalType() );
SaveSettings( config() ); // save values shared by eeschema applications.

View File

@ -249,6 +249,7 @@ enum id_eeschema_frm
ID_LIBVIEW_CMPWINDOW,
ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC,
ID_SET_RELATIVE_OFFSET,
ID_LIBVIEW_SHOW_ELECTRICAL_TYPE,
ID_UPDATE_PCB_FROM_SCH,
ID_UPDATE_SCH_FROM_PCB,

View File

@ -1,7 +1,7 @@
/*
* 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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
@ -915,6 +915,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
bool drawPinText = flags & PIN_DRAW_TEXTS;
bool drawPinDangling = flags & PIN_DRAW_DANGLING;
bool drawDanglingHidden = flags & PIN_DANGLING_HIDDEN;
bool drawElectricalTypeName = flags & PIN_DRAW_ELECTRICAL_TYPE_NAME;
LIB_PART* Entry = GetParent();
@ -960,6 +961,10 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
aColor, aDrawMode );
}
if( drawElectricalTypeName )
DrawPinElectricalTypeName( aPanel, aDC, pos1, orient, aColor, aDrawMode );
/* Set to one (1) to draw bounding box around pin to validate bounding
* box calculation. */
#if 0
@ -1388,6 +1393,63 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
}
void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
wxPoint& aPosition, int aOrientation,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode )
{
wxString etypeName = GetElectricalTypeName();
int etextSize = (m_nameTextSize*3)/4;
#define ETXT_MAX_SIZE Millimeter2iu(0.7 )
if( etextSize > ETXT_MAX_SIZE )
etextSize = ETXT_MAX_SIZE;
// Use a reasonable pen size to draw the text
int pensize = etextSize/6;
/* Get the num and name colors */
if( (aColor < 0) && IsSelected() )
aColor = GetItemSelectedColor();
wxPoint txtpos = aPosition;
int offset = Millimeter2iu( 0.4 );
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_LEFT;
int orient = TEXT_ORIENT_HORIZ;
switch( aOrientation )
{
case PIN_UP:
txtpos.y += offset;
orient = TEXT_ORIENT_VERT;
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
break;
case PIN_DOWN:
txtpos.y -= offset;
orient = TEXT_ORIENT_VERT;
break;
case PIN_LEFT:
txtpos.x += offset;
break;
case PIN_RIGHT:
txtpos.x -= offset;
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
break;
}
GRSetDrawMode( aDC, aDrawMode );
EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
DrawGraphicText( clipbox, aDC, txtpos, aColor, etypeName,
orient, wxSize( etextSize, etextSize ),
hjustify, GR_TEXT_VJUSTIFY_CENTER, pensize,
false, false );
}
void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
{
int MapX1, MapY1, x1, y1;

View File

@ -37,10 +37,11 @@ class SCH_COMPONENT;
#include "pin_shape.h"
#include "pin_type.h"
#define TARGET_PIN_RADIUS 12 // Circle diameter drawn at the active end of pins
// Circle diameter drawn at the active end of pins:
#define TARGET_PIN_RADIUS 12
/* Pin visibility flag bit. */
#define PIN_INVISIBLE 1 /* Set makes pin invisible */
// Pin visibility flag bit:
#define PIN_INVISIBLE 1 // Set makes pin invisible
/**
@ -57,6 +58,8 @@ enum LibPinDrawFlags {
PIN_DRAW_TEXTS = 1,
PIN_DRAW_DANGLING = 2, // Draw this pin with a 'dangling' indicator
PIN_DANGLING_HIDDEN = 4, // Draw (only!) the dangling indicator if the pin is hidden
PIN_DRAW_ELECTRICAL_TYPE_NAME = 8 // Draw the pin electrical type name
// used only in component editor and component viewer
};
@ -88,6 +91,7 @@ class LIB_PIN : public LIB_ITEM
* PIN_DRAW_TEXTS, -- false to draw only pin shape, useful for fast mode
* PIN_DRAW_DANGLING, -- true to draw the pin with its target
* PIN_DANGLING_HIDDEN -- draw the target even if the pin is hidden
* PIN_DRAW_ELECTRICAL_TYPE_NAME -- Draw the pin electrical type name
* @param aTransform Transform Matrix (rotation, mirror ..)
*/
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
@ -399,6 +403,14 @@ public:
int aOrientation, int TextInside, bool DrawPinNum, bool DrawPinName,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode );
/**
* Function DrawPinElectricalTypeName
* draws the electrical type text of the pin (only for the footprint editor)
* aDrawMode = GR_OR, XOR ...
*/
void DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition,
int aOrientation, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode );
/**
* Function PlotPinTexts
* plots the pin number and pin text info, given the pin line coordinates.

View File

@ -248,7 +248,9 @@ void LIB_EDIT_FRAME::RedrawComponent( wxDC* aDC, wxPoint aOffset )
wxString fieldfullText = field->GetFullText( m_unit );
field->EDA_TEXT::SetText( fieldfullText ); // change the field text string only
part->Draw( m_canvas, aDC, aOffset, m_unit, m_convert, GR_DEFAULT_DRAWMODE );
part->Draw( m_canvas, aDC, aOffset, m_unit, m_convert, GR_DEFAULT_DRAWMODE,
UNSPECIFIED_COLOR, DefaultTransform,
true, true,false, NULL, GetShowElectricalType() );
field->EDA_TEXT::SetText( fieldText ); // restore the field text string
}
}

View File

@ -189,6 +189,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_hotkeysDescrList = g_Libedit_Hokeys_Descr;
m_editPinsPerPartOrConvert = false;
m_repeatPinStep = DEFAULT_REPEAT_OFFSET_PIN;
SetShowElectricalType( true );
m_my_part = NULL;
m_tempCopyComponent = NULL;

View File

@ -76,6 +76,11 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME
*/
bool m_editPinsPerPartOrConvert;
/**
* the option to show the pin electrical name in the component editor
*/
bool m_showPinElectricalTypeName;
/** The current draw or edit graphic item fill style. */
static FILL_T m_drawFillStyle;
@ -391,6 +396,10 @@ public:
void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
bool GetShowElectricalType() { return m_showPinElectricalTypeName; }
void SetShowElectricalType( bool aShow ) { m_showPinElectricalTypeName = aShow; }
FILL_T GetFillStyle() { return m_drawFillStyle; }
/**

View File

@ -387,20 +387,25 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
return;
wxPoint pinpos = cur_pin->GetPosition();
bool showPinText = true;
int show_opts = PIN_DRAW_TEXTS | PIN_DRAW_DANGLING | PIN_DANGLING_HIDDEN;
if( parent->GetShowElectricalType() )
show_opts |= PIN_DRAW_ELECTRICAL_TYPE_NAME;
void* showOptions = (void*) show_opts;
// Erase pin in old position
if( aErase )
{
cur_pin->Move( PinPreviousPos );
cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
&showPinText, DefaultTransform );
showOptions, DefaultTransform );
}
// Redraw pin in new position
cur_pin->Move( aPanel->GetParent()->GetCrossHairPosition( true ) );
cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
&showPinText, DefaultTransform );
showOptions, DefaultTransform );
PinPreviousPos = cur_pin->GetPosition();
@ -416,8 +421,6 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
*/
void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
{
bool showPinText = true;
LIB_PART* part = GetCurPart();
if( !part )
@ -465,8 +468,17 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
m_canvas->SetMouseCapture( DrawMovePin, AbortPinMove );
if( DC )
pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_COPY, &showPinText,
DefaultTransform );
{
int show_opts = PIN_DRAW_TEXTS | PIN_DRAW_DANGLING | PIN_DANGLING_HIDDEN;
if( GetShowElectricalType() )
show_opts |= PIN_DRAW_ELECTRICAL_TYPE_NAME;
void* showOptions = (void*) show_opts;
pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_COPY,
showOptions, DefaultTransform );
}
}
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2016 KiCad Developers, see change_log.txt for contributors.
*
@ -205,6 +205,10 @@ void LIB_VIEW_FRAME::ReCreateMenuBar( void )
AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text,
HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) );
viewMenu->AppendSeparator();
AddMenuItem( viewMenu, ID_LIBVIEW_SHOW_ELECTRICAL_TYPE, _( "&Show Pin Electrical Type" ),
wxEmptyString, KiBitmap( pin_xpm ), wxITEM_CHECK );
// Menu Help:
wxMenu* helpMenu = new wxMenu;

View File

@ -1,7 +1,7 @@
/*
* 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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
@ -76,10 +76,13 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
EVT_MENU( wxID_EXIT, LIB_VIEW_FRAME::CloseLibraryViewer )
EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
EVT_MENU( ID_SET_RELATIVE_OFFSET, LIB_VIEW_FRAME::OnSetRelativeOffset )
EVT_MENU( ID_LIBVIEW_SHOW_ELECTRICAL_TYPE, LIB_VIEW_FRAME::OnShowElectricalType )
EVT_UPDATE_UI( ID_LIBVIEW_VIEWDOC, LIB_VIEW_FRAME::onUpdateViewDoc )
EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton )
EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, LIB_VIEW_FRAME::onUpdateAlternateBodyStyleButton )
EVT_UPDATE_UI( ID_LIBVIEW_SHOW_ELECTRICAL_TYPE, LIB_VIEW_FRAME::OnUpdateElectricalType )
END_EVENT_TABLE()
@ -135,6 +138,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
m_cmpList = NULL;
m_libList = NULL;
m_listPowerCmpOnly = false;
SetShowElectricalType( true );
SetScreen( new SCH_SCREEN( aKiway ) );
GetScreen()->m_Center = true; // Axis origin centered on screen.
@ -338,6 +342,18 @@ void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
}
void LIB_VIEW_FRAME::OnShowElectricalType( wxCommandEvent& event )
{
SetShowElectricalType( not GetShowElectricalType() );
m_canvas->Refresh();
}
void LIB_VIEW_FRAME::OnUpdateElectricalType( wxUpdateUIEvent& aEvent )
{
aEvent.Check( GetShowElectricalType() );
}
double LIB_VIEW_FRAME::BestZoom()
{
/* Please, note: wxMSW before version 2.9 seems have
@ -600,6 +616,7 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
#define LIBLIST_WIDTH_KEY "ViewLiblistWidth"
#define CMPLIST_WIDTH_KEY "ViewCmplistWidth"
#define CMPVIEW_SHOW_PINELECTRICALTYPE_KEY "ViewCmpShowPinElectricalType"
// Currently, the library viewer has no dialog to change the background color
// of the draw canvas. Therefore the background color is here just
@ -616,6 +633,8 @@ void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
aCfg->Read( LIBLIST_WIDTH_KEY, &m_libListWidth, 150 );
aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 150 );
aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 150 );
m_showPinElectricalTypeName = aCfg->Read( CMPVIEW_SHOW_PINELECTRICALTYPE_KEY, true );
// Set parameters to a reasonable value.
if( m_libListWidth > m_FrameSize.x/2 )
@ -638,6 +657,8 @@ void LIB_VIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
m_cmpListWidth = m_cmpList->GetSize().x;
aCfg->Write( CMPLIST_WIDTH_KEY, m_cmpListWidth );
aCfg->Write( CMPVIEW_SHOW_PINELECTRICALTYPE_KEY, m_showPinElectricalTypeName );
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2016 KiCad Developers, see change_log.txt for contributors.
*
@ -88,6 +88,7 @@ public:
void ClickOnCmpList( wxCommandEvent& event );
void OnSetRelativeOffset( wxCommandEvent& event );
void OnSelectSymbol( wxCommandEvent& aEvent );
void OnShowElectricalType( wxCommandEvent& event );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
@ -140,6 +141,9 @@ public:
void SetConvert( int aConvert ) { m_convert = aConvert; }
int GetConvert( void ) { return m_convert; }
bool GetShowElectricalType() { return m_showPinElectricalTypeName; }
void SetShowElectricalType( bool aShow ) { m_showPinElectricalTypeName = aShow; }
private:
/**
* Function OnActivate
@ -159,6 +163,7 @@ private:
void onUpdateAlternateBodyStyleButton( wxUpdateUIEvent& aEvent );
void onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent );
void onUpdateViewDoc( wxUpdateUIEvent& aEvent );
void OnUpdateElectricalType( wxUpdateUIEvent& aEvent );
void onSelectNextSymbol( wxCommandEvent& aEvent );
void onSelectPreviousSymbol( wxCommandEvent& aEvent );
void onViewSymbolDocument( wxCommandEvent& aEvent );
@ -193,6 +198,11 @@ private:
static int m_unit;
static int m_convert;
/**
* the option to show the pin electrical name in the component editor
*/
bool m_showPinElectricalTypeName;
DECLARE_EVENT_TABLE()
};

View File

@ -176,7 +176,7 @@ void LIB_VIEW_FRAME::DisplayLibInfos()
{
PART_LIB* lib = libs->FindLibrary( m_libraryName );
wxString title = wxString::Format( "Library Browser \u2014 %s",
wxString title = wxString::Format( L"Library Browser \u2014 %s",
lib ? lib->GetFullFileName() : "no library selected" );
SetTitle( title );
}
@ -217,7 +217,9 @@ void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
else
msg = _( "None" );
part->Draw( m_canvas, DC, wxPoint( 0, 0 ), m_unit, m_convert, GR_DEFAULT_DRAWMODE );
part->Draw( m_canvas, DC, wxPoint( 0, 0 ), m_unit, m_convert, GR_DEFAULT_DRAWMODE,
UNSPECIFIED_COLOR, DefaultTransform,
true, true,false, NULL, GetShowElectricalType() );
// Redraw the cursor
m_canvas->DrawCrossHair( DC );