ADDED exclude-from-simulation property to text items and textboxes.

This commit is contained in:
Jeff Young 2023-04-09 12:14:21 +01:00
parent a226f7fc14
commit ea59d583d5
16 changed files with 193 additions and 12 deletions

View File

@ -209,6 +209,8 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
m_textCtrl->SetValue( schematic.ConvertKIIDsToRefs( m_currentText->GetText() ) );
m_textCtrl->EmptyUndoBuffer();
m_excludeFromSim->SetValue( m_currentItem->GetExcludeFromSim() );
m_fontCtrl->SetFontSelection( m_currentText->GetFont() );
m_textSize.SetValue( m_currentText->GetTextWidth() );
m_textColorSwatch->SetSwatchColor( m_currentText->GetTextColor(), false );
@ -490,6 +492,8 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
return false;
}
m_currentItem->SetExcludeFromSim( m_excludeFromSim->GetValue() );
if( !m_currentText->ValidateHyperlink( m_hyperlinkCombo->GetValue() ) )
{
DisplayError( this, _( "Invalid hyperlink destination. Please enter either a valid URL "

View File

@ -83,6 +83,9 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
m_textEntrySizer->Add( bSizer41, wxGBPosition( 1, 5 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALIGN_RIGHT|wxLEFT, 5 );
m_excludeFromSim = new wxCheckBox( this, wxID_ANY, _("Exclude from simulation"), wxDefaultPosition, wxDefaultSize, 0 );
m_textEntrySizer->Add( m_excludeFromSim, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxTOP|wxBOTTOM, 10 );
m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 );
m_fontLabel->Wrap( -1 );
m_textEntrySizer->Add( m_fontLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxTOP, 5 );

View File

@ -349,6 +349,73 @@
</object>
</object>
</object>
<object class="gbsizeritem" expanded="1">
<property name="border">10</property>
<property name="colspan">2</property>
<property name="column">0</property>
<property name="flag">wxTOP|wxBOTTOM</property>
<property name="row">1</property>
<property name="rowspan">1</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">Exclude from simulation</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_excludeFromSim</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="gbsizeritem" expanded="1">
<property name="border">5</property>
<property name="colspan">1</property>

View File

@ -27,6 +27,7 @@ class WX_INFOBAR;
#include <wx/stc/stc.h>
#include <wx/hyperlink.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/choice.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
@ -35,7 +36,6 @@ class WX_INFOBAR;
#include <wx/button.h>
#include <wx/textctrl.h>
#include <wx/panel.h>
#include <wx/checkbox.h>
#include <wx/bmpcbox.h>
#include <wx/gbsizer.h>
#include <wx/dialog.h>
@ -55,6 +55,7 @@ class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM
wxStaticText* m_textLabel;
wxStyledTextCtrl* m_textCtrl;
wxHyperlinkCtrl* m_syntaxHelp;
wxCheckBox* m_excludeFromSim;
wxStaticText* m_fontLabel;
FONT_CHOICE* m_fontCtrl;
BITMAP_BUTTON* m_separator1;

View File

@ -29,7 +29,6 @@
#include <sim/sim_library_spice.h>
#include <sim/sim_model_raw_spice.h>
#include <sim/sim_model_ideal.h>
#include <sim/spice_grammar.h>
#include <common.h>
#include <confirm.h>
#include <pgm_base.h>
@ -37,7 +36,6 @@
#include <sim/sim_library.h>
#include <sim/sim_library_kibis.h>
#include <sim/sim_model_kibis.h>
#include <sim/sim_model.h>
#include <sch_screen.h>
#include <sch_text.h>
#include <sch_textbox.h>
@ -212,7 +210,7 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
{
SCH_SYMBOL* symbol = findNextSymbol( item, &sheet );
if( !symbol || symbol->GetFieldText( SIM_ENABLE_FIELD ) == wxT( "0" ) )
if( !symbol || symbol->GetExcludeFromSim() )
continue;
std::vector<PIN_INFO> pins = CreatePinList( symbol, &sheet, true );
@ -340,6 +338,9 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions )
{
for( SCH_ITEM* item : sheet.LastScreen()->Items() )
{
if( item->GetExcludeFromSim() )
continue;
if( item->Type() == SCH_TEXT_T )
text = static_cast<SCH_TEXT*>( item )->GetShownText();
else if( item->Type() == SCH_TEXTBOX_T )

View File

@ -95,4 +95,5 @@
//#define SEXPR_SCHEMATIC_FILE_VERSION 20221126 // Remove value and footprint from instance data.
//#define SEXPR_SCHEMATIC_FILE_VERSION 20221206 // Simulation model fields V6 -> V7
//#define SEXPR_SCHEMATIC_FILE_VERSION 20230121 // SCH_MARKER specific sheet path serialisation
#define SEXPR_SCHEMATIC_FILE_VERSION 20230221 // Modern power symbols (editable value = net)
//#define SEXPR_SCHEMATIC_FILE_VERSION 20230221 // Modern power symbols (editable value = net)
#define SEXPR_SCHEMATIC_FILE_VERSION 20230409 // Add exclude_from_sim markup

View File

@ -198,6 +198,9 @@ public:
*/
SCH_ITEM* Duplicate( bool doClone = false ) const;
virtual void SetExcludeFromSim( bool aExclude ) { }
virtual bool GetExcludeFromSim() const { return false; }
/**
* @return true for items which are moved with the anchor point at mouse cursor
* and false for items moved with no reference to anchor

View File

@ -3732,6 +3732,11 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
switch( token )
{
case T_exclude_from_sim:
text->SetExcludeFromSim( parseBool() );
NeedRIGHT();
break;
case T_at:
text->SetPosition( parseXY() );
@ -3906,6 +3911,11 @@ SCH_TEXTBOX* SCH_SEXPR_PARSER::parseSchTextBox()
switch( token )
{
case T_exclude_from_sim:
textBox->SetExcludeFromSim( parseBool() );
NeedRIGHT();
break;
case T_start: // Legacy token during 6.99 development; fails to handle angle
pos = parseXY();
NeedRIGHT();

View File

@ -1259,7 +1259,12 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel )
getTextTypeToken( aText->Type() ),
m_out->Quotew( aText->GetText() ).c_str() );
if( aText->Type() == SCH_DIRECTIVE_LABEL_T )
if( aText->Type() == SCH_TEXT_T )
{
m_out->Print( 0, " (exclude_from_sim %s)\n",
aText->GetExcludeFromSim() ? "yes" : "no" );
}
else if( aText->Type() == SCH_DIRECTIVE_LABEL_T )
{
SCH_DIRECTIVE_LABEL* flag = static_cast<SCH_DIRECTIVE_LABEL*>( aText );
@ -1339,7 +1344,8 @@ void SCH_SEXPR_PLUGIN::saveTextBox( SCH_TEXTBOX* aTextBox, int aNestLevel )
VECTOR2I pos = aTextBox->GetStart();
VECTOR2I size = aTextBox->GetEnd() - pos;
m_out->Print( aNestLevel + 1, "(at %s %s %s) (size %s %s)\n",
m_out->Print( aNestLevel + 1, "(exclude_from_sim %s) (at %s %s %s) (size %s %s)\n",
aTextBox->GetExcludeFromSim() ? "yes" : "no",
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.x ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.y ).c_str(),
EDA_UNIT_UTILS::FormatAngle( aTextBox->GetTextAngle() ).c_str(),

View File

@ -42,6 +42,7 @@
#include <utility>
#include "plotters/plotter.h"
#include "sim/sim_model.h"
std::unordered_map<TRANSFORM, int> SCH_SYMBOL::s_transformToOrientationCache;
@ -516,6 +517,30 @@ void SCH_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffse
}
void SCH_SYMBOL::SetExcludeFromSim( bool aExclude )
{
SCH_FIELD* enable = FindField( SIM_ENABLE_FIELD );
if( aExclude )
{
if( !enable )
enable = AddField( SCH_FIELD( VECTOR2I( 0, 0 ), -1, this, SIM_ENABLE_FIELD ) );
enable->SetText( wxS( "0" ) );
}
else
{
RemoveField( SIM_ENABLE_FIELD );
}
}
bool SCH_SYMBOL::GetExcludeFromSim() const
{
return GetFieldText( SIM_ENABLE_FIELD ) == wxS( "0" );
}
bool SCH_SYMBOL::GetInstance( SCH_SYMBOL_INSTANCE& aInstance,
const KIID_PATH& aSheetPath, bool aTestFromEnd ) const
{
@ -1695,6 +1720,30 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
auto addExcludes =
[&]()
{
wxArrayString msgs;
if( GetExcludeFromSim() )
msgs.Add( _( "Simulation" ) );
if( !GetIncludeInBom() )
msgs.Add( _( "BOM" ) );
if( !GetIncludeOnBoard() )
msgs.Add( _( "Board" ) );
if( GetDNP() )
msgs.Add( _( "DNP" ) );
msg = wxJoin( msgs, '|' );
msg.Replace( '|', wxS( ", " ) );
if( !msg.empty() )
aList.emplace_back( _( "Exclude from" ), msg );
};
// part and alias can differ if alias is not the root
if( m_part )
{
@ -1708,6 +1757,7 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
{
aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
aList.emplace_back( _( "Value" ), GetValueFieldText( true ) );
addExcludes();
aList.emplace_back( _( "Name" ), UnescapeString( GetLibId().GetLibItemName() ) );
}
@ -1751,9 +1801,9 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
else
{
aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
aList.emplace_back( _( "Value" ), GetValueFieldText( true ) );
aList.emplace_back( _( "Name" ), GetLibId().GetLibItemName() );
addExcludes();
aList.emplace_back( _( "Name" ), UnescapeString( GetLibId().GetLibItemName() ) );
wxString libNickname = GetLibId().GetLibNickname();

View File

@ -152,6 +152,9 @@ public:
void SortInstances( bool ( *aSortFunction )( const SCH_SYMBOL_INSTANCE& aLhs,
const SCH_SYMBOL_INSTANCE& aRhs ) );
void SetExcludeFromSim( bool aExclude ) override;
bool GetExcludeFromSim() const override;
void ViewGetLayers( int aLayers[], int& aCount ) const override;
/**

View File

@ -121,6 +121,8 @@ SCH_TEXT::SCH_TEXT( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) :
SetTextPos( pos );
SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT );
SetMultilineAllowed( true );
m_excludeFromSim = false;
}
@ -128,7 +130,9 @@ SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) :
SCH_ITEM( aText ),
EDA_TEXT( aText ),
m_spin_style( aText.m_spin_style )
{ }
{
m_excludeFromSim = aText.m_excludeFromSim;
}
VECTOR2I SCH_TEXT::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const
@ -243,7 +247,7 @@ bool SCH_TEXT::operator<( const SCH_ITEM& aItem ) const
auto other = static_cast<const SCH_TEXT*>( &aItem );
if( GetLayer() != other->GetLayer() )
return GetLayer() < other->GetLayer();
return GetLayer() < other->GetLayer();
if( GetPosition().x != other->GetPosition().x )
return GetPosition().x < other->GetPosition().x;
@ -251,6 +255,9 @@ bool SCH_TEXT::operator<( const SCH_ITEM& aItem ) const
if( GetPosition().y != other->GetPosition().y )
return GetPosition().y < other->GetPosition().y;
if( GetExcludeFromSim() != other->GetExcludeFromSim() )
return GetExcludeFromSim() - other->GetExcludeFromSim();
return GetText() < other->GetText();
}
@ -492,6 +499,9 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
// Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Graphic Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
if( m_excludeFromSim )
aList.emplace_back( _( "Exclude from" ), _( "Simulation" ) );
aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };

View File

@ -142,6 +142,9 @@ public:
void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override;
void SetExcludeFromSim( bool aExclude ) override { m_excludeFromSim = aExclude; }
bool GetExcludeFromSim() const override { return m_excludeFromSim; }
/**
* Set a spin or rotation angle, along with specific horizontal and vertical justification
* styles with each angle.
@ -241,6 +244,8 @@ protected:
* easier to handle than 3 parameters when editing and reading and saving files.
*/
TEXT_SPIN_STYLE m_spin_style;
bool m_excludeFromSim;
};

View File

@ -52,13 +52,17 @@ SCH_TEXTBOX::SCH_TEXTBOX( int aLineWidth, FILL_T aFillType, const wxString& text
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
SetVertJustify( GR_TEXT_V_ALIGN_TOP );
SetMultilineAllowed( true );
m_excludeFromSim = false;
}
SCH_TEXTBOX::SCH_TEXTBOX( const SCH_TEXTBOX& aText ) :
SCH_SHAPE( aText ),
EDA_TEXT( aText )
{ }
{
m_excludeFromSim = aText.m_excludeFromSim;
}
int SCH_TEXTBOX::GetTextMargin() const
@ -209,6 +213,9 @@ bool SCH_TEXTBOX::operator<( const SCH_ITEM& aItem ) const
if( GetPosition().y != other->GetPosition().y )
return GetPosition().y < other->GetPosition().y;
if( GetExcludeFromSim() != other->GetExcludeFromSim() )
return GetExcludeFromSim() - other->GetExcludeFromSim();
return GetText() < other->GetText();
}
@ -429,6 +436,9 @@ void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL
// Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
if( m_excludeFromSim )
aList.emplace_back( _( "Exclude from" ), _( "Simulation" ) );
aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };

View File

@ -64,6 +64,9 @@ public:
void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override;
void SetExcludeFromSim( bool aExclude ) override { m_excludeFromSim = aExclude; }
bool GetExcludeFromSim() const override { return m_excludeFromSim; }
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
void SwapData( SCH_ITEM* aItem ) override;
@ -113,6 +116,9 @@ public:
protected:
KIFONT::FONT* getDrawFont() const override;
protected:
bool m_excludeFromSim;
};

View File

@ -35,6 +35,7 @@ edge_clock_high
effects
end
extends
exclude_from_sim
face
fields_autoplaced
fill