Sim plot: fix a rounding issue that can create a missing point in a plot.

Due to a truncation when converting a value to integer, the first point was
sometimes missing because it looked like out of plot range.
Fix also a cosmetic issue in dialog.
Fixes #7345
https://gitlab.com/kicad/code/kicad/issues/7345
This commit is contained in:
jean-pierre charras 2021-01-31 10:36:26 +01:00
parent 8eca23aabe
commit c155218582
5 changed files with 10 additions and 38 deletions

View File

@ -708,7 +708,9 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
wxCoord y1 = w.y2p( py );
// Store only points on the drawing area, to speed up the drawing time
if( x1 >= startPx && x1 <= endPx )
// Note: x1 is a value truncated from px by w.x2p(). So to be sure the
// first point is drawn, the x1 low limit is startPx-1 in plot coordinates
if( x1 >= startPx-1 && x1 <= endPx )
{
if( !count || line_start.x != x1 )
{

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.9.0 Sep 3 2020)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -95,9 +95,6 @@ DIALOG_SIM_SETTINGS_BASE::DIALOG_SIM_SETTINGS_BASE( wxWindow* parent, wxWindowID
wxBoxSizer* bSizer151;
bSizer151 = new wxBoxSizer( wxHORIZONTAL );
bSizer151->Add( 0, 0, 1, wxEXPAND, 5 );
wxGridBagSizer* gbSizer1;
gbSizer1 = new wxGridBagSizer( 0, 0 );
gbSizer1->SetFlexibleDirection( wxBOTH );
@ -193,9 +190,6 @@ DIALOG_SIM_SETTINGS_BASE::DIALOG_SIM_SETTINGS_BASE( wxWindow* parent, wxWindowID
bSizer151->Add( gbSizer1, 1, wxEXPAND, 5 );
bSizer151->Add( 0, 0, 1, wxEXPAND, 5 );
bSizer82->Add( bSizer151, 0, wxALIGN_CENTER_HORIZONTAL, 5 );

View File

@ -14,7 +14,6 @@
<property name="file">dialog_sim_settings_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">DIALOG_SIM_SETTINGS_BASE</property>
@ -26,7 +25,6 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -876,21 +874,11 @@
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_HORIZONTAL</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer151</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="0">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
@ -2306,7 +2294,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -2369,16 +2356,6 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="0">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
@ -4743,7 +4720,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.9.0 Sep 3 2020)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!

View File

@ -189,8 +189,8 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent )
KiBitmap( sim_probe_xpm ), _( "Probe signals on the schematic" ), wxITEM_NORMAL );
m_toolTune = m_toolBar->AddTool( ID_SIM_TUNE, _( "Tune" ),
KiBitmap( sim_tune_xpm ), _( "Tune component values" ), wxITEM_NORMAL );
m_toolSettings = m_toolBar->AddTool( wxID_ANY, _( "Settings" ),
KiBitmap( sim_settings_xpm ), _( "Simulation settings" ), wxITEM_NORMAL );
m_toolSettings = m_toolBar->AddTool( wxID_ANY, _( "Sim Parameters" ),
KiBitmap( sim_settings_xpm ), _( "Simulation parameters and settings" ), wxITEM_NORMAL );
Connect( m_toolSimulate->GetId(), wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler( SIM_PLOT_FRAME::onSimulate ), NULL, this );
@ -437,7 +437,7 @@ void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
if( aSimCommand.IsEmpty() )
{
SIM_PANEL_BASE* plotPanel = currentPlotWindow();
if( plotPanel && m_plots.count( plotPanel ) != 0 )
m_exporter->SetSimCommand( m_plots[plotPanel].m_simCommand );
}
@ -1325,7 +1325,7 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
// If it is a new simulation type, open a new plot
// For the DC sim, check if sweep source type has changed (char 4 will contain 'v', 'i', 'r' or 't'
if( !plotPanelWindow
if( !plotPanelWindow
|| ( plotPanelWindow && plotPanelWindow->GetType() != newSimType )
|| ( newSimType == ST_DC
&& oldCommand.Lower().GetChar( 4 ) != newCommand.Lower().GetChar( 4 ) ) )