mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-11 09:40:09 +00:00
Eeschema: Add indicator icons for pins with alt modes
This makes it easier to see which pins have alt modes available. There is an option to turn them off. The icon positions are chosen so they they shouldn't interfere as far as possible: * If the text is inside, the icon goes more inside the body * If the text is above/below the pin, it goes away from the body This means it won't collide with a symbol wall in most cases, but some symbols with alt pins on opposing sides may need to be widened if the icons are show. Includes a rather fiddly refactor of the SCH_PIN painter function, which needs quite a lot of massaging to allow it to figure out where an icon would go. Quite a bit of logic is broken out into smaller encapsulations with less visible state to each chunk. Icon modes for base-name-selected and alt-selected are included, but only the former works due to information being thrown away during the SCH_PAINTER tempPin process. Fixes: https://gitlab.com/kicad/code/kicad/-/issues/11069
This commit is contained in:
parent
7214a108e4
commit
91dca89116
@ -60,7 +60,7 @@ void PANEL_EESCHEMA_DISPLAY_OPTIONS::loadEEschemaSettings( EESCHEMA_SETTINGS* cf
|
||||
m_checkShowERCExclusions->SetValue( cfg->m_Appearance.show_erc_exclusions );
|
||||
m_cbMarkSimExclusions->SetValue( cfg->m_Appearance.mark_sim_exclusions );
|
||||
m_checkShowOPVoltages->SetValue( cfg->m_Appearance.show_op_voltages );
|
||||
m_checkShowOPCurrents->SetValue( cfg->m_Appearance.show_op_currents );
|
||||
m_checkShowPinAltModeIcons->SetValue( cfg->m_Appearance.show_op_currents );
|
||||
m_checkPageLimits->SetValue( cfg->m_Appearance.show_page_limits );
|
||||
|
||||
m_checkSelDrawChildItems->SetValue( cfg->m_Selection.draw_selected_children );
|
||||
@ -107,6 +107,7 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow()
|
||||
cfg->m_Appearance.mark_sim_exclusions = m_cbMarkSimExclusions->GetValue();
|
||||
cfg->m_Appearance.show_op_voltages = m_checkShowOPVoltages->GetValue();
|
||||
cfg->m_Appearance.show_op_currents = m_checkShowOPCurrents->GetValue();
|
||||
cfg->m_Appearance.show_pin_alt_icons = m_checkShowPinAltModeIcons->GetValue();
|
||||
cfg->m_Appearance.show_page_limits = m_checkPageLimits->GetValue();
|
||||
|
||||
cfg->m_Selection.draw_selected_children = m_checkSelDrawChildItems->GetValue();
|
||||
|
@ -75,6 +75,9 @@ PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE::PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE( wxWind
|
||||
m_checkShowOPCurrents = new wxCheckBox( this, wxID_ANY, _("Show OP currents"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bAppearanceSizer->Add( m_checkShowOPCurrents, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_checkShowPinAltModeIcons = new wxCheckBox( this, wxID_ANY, _("Show pin alternate mode indicator icons"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bAppearanceSizer->Add( m_checkShowPinAltModeIcons, 0, wxALL, 5 );
|
||||
|
||||
m_checkPageLimits = new wxCheckBox( this, wxID_ANY, _("Show page limi&ts"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_checkPageLimits->SetValue(true);
|
||||
bAppearanceSizer->Add( m_checkPageLimits, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
@ -868,6 +868,71 @@
|
||||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxCheckBox" expanded="true">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</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="drag_accept_files">0</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 alternate mode indicator icons</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_checkShowPinAltModeIcons</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">; ; forward_declare</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>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="false">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
|
||||
|
@ -50,6 +50,7 @@ class PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE : public RESETTABLE_PANEL
|
||||
wxCheckBox* m_cbMarkSimExclusions;
|
||||
wxCheckBox* m_checkShowOPVoltages;
|
||||
wxCheckBox* m_checkShowOPCurrents;
|
||||
wxCheckBox* m_checkShowPinAltModeIcons;
|
||||
wxCheckBox* m_checkPageLimits;
|
||||
wxStaticText* m_selectionLabel;
|
||||
wxStaticLine* m_staticline2;
|
||||
|
@ -234,6 +234,9 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
|
||||
m_params.emplace_back( new PARAM<bool>( "appearance.show_op_currents",
|
||||
&m_Appearance.show_op_currents, true ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "appearance.show_pin_alt_icons",
|
||||
&m_Appearance.show_pin_alt_icons, true ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "appearance.show_illegal_symbol_lib_dialog",
|
||||
&m_Appearance.show_illegal_symbol_lib_dialog, true ) );
|
||||
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
bool show_erc_exclusions;
|
||||
bool show_op_voltages;
|
||||
bool show_op_currents;
|
||||
bool show_pin_alt_icons;
|
||||
bool show_illegal_symbol_lib_dialog;
|
||||
bool show_page_limits;
|
||||
bool show_sexpr_file_convert_warning;
|
||||
|
@ -239,6 +239,7 @@ void SCH_EDIT_FRAME::doReCreateMenuBar()
|
||||
viewMenu->Add( EE_ACTIONS::markSimExclusions, ACTION_MENU::CHECK );
|
||||
viewMenu->Add( EE_ACTIONS::toggleOPVoltages, ACTION_MENU::CHECK );
|
||||
viewMenu->Add( EE_ACTIONS::toggleOPCurrents, ACTION_MENU::CHECK );
|
||||
viewMenu->Add( EE_ACTIONS::togglePinAltIcons, ACTION_MENU::CHECK );
|
||||
|
||||
#ifdef __APPLE__
|
||||
viewMenu->AppendSeparator();
|
||||
|
@ -730,6 +730,13 @@ void SCH_EDIT_FRAME::setupUIConditions()
|
||||
return cfg && cfg->m_Appearance.show_op_currents;
|
||||
};
|
||||
|
||||
auto showPinAltModeIconsCond =
|
||||
[this]( const SELECTION& )
|
||||
{
|
||||
EESCHEMA_SETTINGS* cfg = eeconfig();
|
||||
return cfg && cfg->m_Appearance.show_pin_alt_icons;
|
||||
};
|
||||
|
||||
auto showAnnotateAutomaticallyCond =
|
||||
[this]( const SELECTION& )
|
||||
{
|
||||
@ -773,6 +780,7 @@ void SCH_EDIT_FRAME::setupUIConditions()
|
||||
mgr->SetConditions( EE_ACTIONS::markSimExclusions, CHECK( markSimExclusionsCond ) );
|
||||
mgr->SetConditions( EE_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
|
||||
mgr->SetConditions( EE_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
|
||||
mgr->SetConditions( EE_ACTIONS::togglePinAltIcons, CHECK( showPinAltModeIconsCond ) );
|
||||
mgr->SetConditions( EE_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
|
||||
mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) );
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -125,15 +125,7 @@ private:
|
||||
|
||||
int getOperatingPointTextSize() const;
|
||||
|
||||
void triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );
|
||||
void strokeText( const wxString& aText, const VECTOR2D& aPosition,
|
||||
const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics );
|
||||
void bitmapText( const wxString& aText, const VECTOR2D& aPosition,
|
||||
const TEXT_ATTRIBUTES& aAttrs );
|
||||
void knockoutText( const wxString& aText, const VECTOR2D& aPosition,
|
||||
const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics );
|
||||
void boxText( const wxString& aText, const VECTOR2D& aPosition,
|
||||
const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics );
|
||||
void triLine( const VECTOR2D& a, const VECTOR2D& b, const VECTOR2D& c );
|
||||
|
||||
wxString expandLibItemTextVars( const wxString& aSourceText, const SCH_SYMBOL* aSymbolContext );
|
||||
|
||||
|
@ -355,8 +355,15 @@ const wxString& SCH_PIN::GetName() const
|
||||
{
|
||||
if( !m_alt.IsEmpty() )
|
||||
return m_alt;
|
||||
else if( m_libPin )
|
||||
return m_libPin->GetName();
|
||||
|
||||
return GetBaseName();
|
||||
}
|
||||
|
||||
|
||||
const wxString& SCH_PIN::GetBaseName() const
|
||||
{
|
||||
if( m_libPin )
|
||||
return m_libPin->GetBaseName();
|
||||
|
||||
return m_name;
|
||||
}
|
||||
|
@ -107,6 +107,10 @@ public:
|
||||
const wxString& GetName() const;
|
||||
wxString GetShownName() const;
|
||||
void SetName( const wxString& aName );
|
||||
/**
|
||||
* Get the name without any alternates
|
||||
*/
|
||||
const wxString& GetBaseName() const;
|
||||
|
||||
const wxString& GetNumber() const { return m_number; }
|
||||
wxString GetShownNumber() const;
|
||||
@ -118,7 +122,7 @@ public:
|
||||
int GetNumberTextSize() const;
|
||||
void SetNumberTextSize( int aSize );
|
||||
|
||||
std::map<wxString, ALT>& GetAlternates()
|
||||
const std::map<wxString, ALT>& GetAlternates() const
|
||||
{
|
||||
if( m_libPin )
|
||||
return m_libPin->GetAlternates();
|
||||
@ -126,6 +130,12 @@ public:
|
||||
return m_alternates;
|
||||
}
|
||||
|
||||
std::map<wxString, ALT>& GetAlternates()
|
||||
{
|
||||
return const_cast<std::map<wxString, ALT>&>(
|
||||
static_cast<const SCH_PIN*>( this )->GetAlternates() );
|
||||
}
|
||||
|
||||
ALT GetAlt( const wxString& aAlt )
|
||||
{
|
||||
return GetAlternates()[ aAlt ];
|
||||
|
@ -1233,6 +1233,12 @@ TOOL_ACTION EE_ACTIONS::toggleOPCurrents( TOOL_ACTION_ARGS()
|
||||
.FriendlyName( _( "Show OP Currents" ) )
|
||||
.Tooltip( _( "Show operating point current data from simulation" ) ) );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::togglePinAltIcons( TOOL_ACTION_ARGS()
|
||||
.Name( "eeschema.EditorControl.togglePinAltIcons" )
|
||||
.Scope( AS_GLOBAL )
|
||||
.FriendlyName( _( "Show Pin Alternate Icons" ) )
|
||||
.Tooltip( _( "Show indicator icons for pins with alternate modes" ) ) );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::lineModeFree( TOOL_ACTION_ARGS()
|
||||
.Name( "eeschema.EditorControl.lineModeFree" )
|
||||
.Scope( AS_GLOBAL )
|
||||
|
@ -253,6 +253,7 @@ public:
|
||||
static TOOL_ACTION markSimExclusions;
|
||||
static TOOL_ACTION toggleOPVoltages;
|
||||
static TOOL_ACTION toggleOPCurrents;
|
||||
static TOOL_ACTION togglePinAltIcons;
|
||||
static TOOL_ACTION toggleSyncedPinsMode;
|
||||
static TOOL_ACTION restartMove;
|
||||
static TOOL_ACTION selectOnPCB;
|
||||
|
@ -2591,6 +2591,18 @@ int SCH_EDITOR_CONTROL::ToggleOPCurrents( const TOOL_EVENT& aEvent )
|
||||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::TogglePinAltIcons( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
EESCHEMA_SETTINGS* cfg = m_frame->eeconfig();
|
||||
cfg->m_Appearance.show_pin_alt_icons = !cfg->m_Appearance.show_pin_alt_icons;
|
||||
|
||||
getView()->UpdateAllItems( KIGFX::REPAINT );
|
||||
m_frame->GetCanvas()->Refresh();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::ChangeLineMode( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->eeconfig()->m_Drawing.line_mode = aEvent.Parameter<LINE_MODE>();
|
||||
@ -2834,6 +2846,7 @@ void SCH_EDITOR_CONTROL::setTransitions()
|
||||
Go( &SCH_EDITOR_CONTROL::MarkSimExclusions, EE_ACTIONS::markSimExclusions.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::ToggleOPVoltages, EE_ACTIONS::toggleOPVoltages.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::ToggleOPCurrents, EE_ACTIONS::toggleOPCurrents.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::TogglePinAltIcons, EE_ACTIONS::togglePinAltIcons.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::ChangeLineMode, EE_ACTIONS::lineModeFree.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::ChangeLineMode, EE_ACTIONS::lineMode90.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::ChangeLineMode, EE_ACTIONS::lineMode45.MakeEvent() );
|
||||
|
@ -141,6 +141,7 @@ public:
|
||||
int MarkSimExclusions( const TOOL_EVENT& aEvent );
|
||||
int ToggleOPVoltages( const TOOL_EVENT& aEvent );
|
||||
int ToggleOPCurrents( const TOOL_EVENT& aEvent );
|
||||
int TogglePinAltIcons( const TOOL_EVENT& aEvent );
|
||||
int ChangeLineMode( const TOOL_EVENT& aEvent );
|
||||
int NextLineMode( const TOOL_EVENT& aEvent );
|
||||
int ToggleAnnotateAuto( const TOOL_EVENT& aEvent );
|
||||
|
@ -126,8 +126,12 @@ SHAPE_ARC MakeArcCw180( const VECTOR2I& aCenter, int aRadius, DIRECTION_45::Dire
|
||||
*
|
||||
* For directions N, E, S, W, the point is the center of the side.
|
||||
* For directions NW, NE, SW, SE, the point is the corner.
|
||||
*
|
||||
* @param aOutset is a distance to move the point outwards from the rectangle,
|
||||
* in the direction of the corner (i.e. perpendicular to the side,
|
||||
* or 45 degrees from the corner).
|
||||
*/
|
||||
VECTOR2I GetPoint( const SHAPE_RECT& aRect, DIRECTION_45::Directions aDir );
|
||||
VECTOR2I GetPoint( const SHAPE_RECT& aRect, DIRECTION_45::Directions aDir, int aOutset = 0 );
|
||||
|
||||
|
||||
/**
|
||||
|
@ -281,21 +281,30 @@ SHAPE_ARC KIGEOM::MakeArcCw180( const VECTOR2I& aCenter, int aRadius,
|
||||
}
|
||||
|
||||
|
||||
VECTOR2I KIGEOM::GetPoint( const SHAPE_RECT& aRect, DIRECTION_45::Directions aDir )
|
||||
VECTOR2I KIGEOM::GetPoint( const SHAPE_RECT& aRect, DIRECTION_45::Directions aDir, int aOutset )
|
||||
{
|
||||
const VECTOR2I nw = aRect.GetPosition();
|
||||
switch( aDir )
|
||||
{
|
||||
// clang-format off
|
||||
case DIRECTION_45::N: return nw + VECTOR2I( aRect.GetWidth() / 2, 0 );
|
||||
case DIRECTION_45::E: return nw + VECTOR2I( aRect.GetWidth(), aRect.GetHeight() / 2 );
|
||||
case DIRECTION_45::S: return nw + VECTOR2I( aRect.GetWidth() / 2, aRect.GetHeight() );
|
||||
case DIRECTION_45::W: return nw + VECTOR2I( 0, aRect.GetHeight() / 2 );
|
||||
case DIRECTION_45::NW: return nw;
|
||||
case DIRECTION_45::NE: return nw + VECTOR2I( aRect.GetWidth(), 0 );
|
||||
case DIRECTION_45::SW: return nw + VECTOR2I( 0, aRect.GetHeight() );
|
||||
case DIRECTION_45::SE: return nw + VECTOR2I( aRect.GetWidth(), aRect.GetHeight() );
|
||||
default: wxFAIL_MSG( "Invalid direction" );
|
||||
case DIRECTION_45::N:
|
||||
return nw + VECTOR2I( aRect.GetWidth() / 2, -aOutset );
|
||||
case DIRECTION_45::E:
|
||||
return nw + VECTOR2I( aRect.GetWidth() + aOutset, aRect.GetHeight() / 2 );
|
||||
case DIRECTION_45::S:
|
||||
return nw + VECTOR2I( aRect.GetWidth() / 2, aRect.GetHeight() + aOutset );
|
||||
case DIRECTION_45::W:
|
||||
return nw + VECTOR2I( -aOutset, aRect.GetHeight() / 2 );
|
||||
case DIRECTION_45::NW:
|
||||
return nw + VECTOR2I( -aOutset, -aOutset );
|
||||
case DIRECTION_45::NE:
|
||||
return nw + VECTOR2I( aRect.GetWidth() + aOutset, -aOutset );
|
||||
case DIRECTION_45::SW:
|
||||
return nw + VECTOR2I( -aOutset, aRect.GetHeight() + aOutset );
|
||||
case DIRECTION_45::SE:
|
||||
return nw + VECTOR2I( aRect.GetWidth() + aOutset, aRect.GetHeight() + aOutset );
|
||||
default:
|
||||
wxFAIL_MSG( "Invalid direction" );
|
||||
// clang-format on
|
||||
}
|
||||
return VECTOR2I();
|
||||
|
Loading…
Reference in New Issue
Block a user