From f15a59f0ad0232611e57969bab42ef77b02ca6ba Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 4 Nov 2016 12:13:22 +0100 Subject: [PATCH] Component Editor and Component viewer: add option to show the electrical pin type. --- eeschema/class_libentry.cpp | 6 +- eeschema/class_libentry.h | 5 +- eeschema/dialogs/dialog_libedit_options.h | 6 ++ .../dialogs/dialog_libedit_options_base.cpp | 7 +- .../dialogs/dialog_libedit_options_base.fbp | 92 ++++++++++++++++++- .../dialogs/dialog_libedit_options_base.h | 5 +- eeschema/eeschema_config.cpp | 5 + eeschema/eeschema_id.h | 1 + eeschema/lib_pin.cpp | 64 ++++++++++++- eeschema/lib_pin.h | 18 +++- eeschema/libedit.cpp | 6 +- eeschema/libeditframe.cpp | 1 + eeschema/libeditframe.h | 9 ++ eeschema/pinedit.cpp | 26 ++++-- eeschema/tool_viewlib.cpp | 6 +- eeschema/viewlib_frame.cpp | 23 ++++- eeschema/viewlib_frame.h | 12 ++- eeschema/viewlibs.cpp | 6 +- 18 files changed, 272 insertions(+), 26 deletions(-) diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 83a049ca51..7c231ad453 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -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* aPinsDangling ) + bool aOnlySelected, const std::vector* 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; diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 1e622511d9..4780b157f9 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -417,6 +417,8 @@ public: * vector 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* aPinsDangling = NULL ); + const std::vector* aPinsDangling = NULL, + bool aShowElectricalType = false ); /** * Plot lib part to plotter. diff --git a/eeschema/dialogs/dialog_libedit_options.h b/eeschema/dialogs/dialog_libedit_options.h index 0bc9eecd2d..792f44ccf4 100644 --- a/eeschema/dialogs/dialog_libedit_options.h +++ b/eeschema/dialogs/dialog_libedit_options.h @@ -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__ diff --git a/eeschema/dialogs/dialog_libedit_options_base.cpp b/eeschema/dialogs/dialog_libedit_options_base.cpp index e4855e88d6..52baf71e75 100644 --- a/eeschema/dialogs/dialog_libedit_options_base.cpp +++ b/eeschema/dialogs/dialog_libedit_options_base.cpp @@ -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 ); diff --git a/eeschema/dialogs/dialog_libedit_options_base.fbp b/eeschema/dialogs/dialog_libedit_options_base.fbp index edd5061a6e..ac7b59ce46 100644 --- a/eeschema/dialogs/dialog_libedit_options_base.fbp +++ b/eeschema/dialogs/dialog_libedit_options_base.fbp @@ -44,7 +44,7 @@ DIALOG_LIBEDIT_OPTIONS_BASE - 499,368 + 499,393 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Library Editor Options @@ -2443,7 +2443,7 @@ 3 - wxTOP|wxRIGHT|wxLEFT|wxEXPAND + wxEXPAND|wxALL 0 1 @@ -2529,6 +2529,94 @@ + + 3 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show pin &electrical type + + 0 + + + 0 + + 1 + m_checkShowPinElectricalType + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/dialogs/dialog_libedit_options_base.h b/eeschema/dialogs/dialog_libedit_options_base.h index 5d8691c1fe..2bc78f8755 100644 --- a/eeschema/dialogs/dialog_libedit_options_base.h +++ b/eeschema/dialogs/dialog_libedit_options_base.h @@ -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(); }; diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 275dd7198f..62824388a0 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -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. diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index fb1c2a4bed..4d84d0a11e 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -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, diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 47c79204e3..10b4aea636 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -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 * 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; diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index 01e9b92986..f7fba3a93e 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -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. diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index aac007c2e9..b76170e555 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -236,7 +236,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, PART_LIB* aLibrar void LIB_EDIT_FRAME::RedrawComponent( wxDC* aDC, wxPoint aOffset ) { - LIB_PART* part = GetCurPart(); + LIB_PART* part = GetCurPart(); if( part ) { @@ -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 } } diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index cd1c8fb21a..bfecba6acd 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -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; diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 36ff2a35f9..01327d6dc6 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -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; } /** diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 482375c0f9..d322650d82 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -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 ); + } } } diff --git a/eeschema/tool_viewlib.cpp b/eeschema/tool_viewlib.cpp index 550ba642e2..c8a2d14708 100644 --- a/eeschema/tool_viewlib.cpp +++ b/eeschema/tool_viewlib.cpp @@ -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 * 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; diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 74e88834d1..5c2cc3a0ce 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -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 * 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 ); } diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index 610f857b49..301650ff87 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -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 * 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() }; diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index fe458d46ce..88a578b8c1 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -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 );