From c1552185826ba35e01df78c23646390976f541d9 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 31 Jan 2021 10:36:26 +0100 Subject: [PATCH] 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 --- common/widgets/mathplot.cpp | 4 ++- eeschema/dialogs/dialog_sim_settings_base.cpp | 8 +----- eeschema/dialogs/dialog_sim_settings_base.fbp | 26 +------------------ eeschema/dialogs/dialog_sim_settings_base.h | 2 +- eeschema/sim/sim_plot_frame.cpp | 8 +++--- 5 files changed, 10 insertions(+), 38 deletions(-) diff --git a/common/widgets/mathplot.cpp b/common/widgets/mathplot.cpp index 0ecfdf1564..e5ba6872ae 100644 --- a/common/widgets/mathplot.cpp +++ b/common/widgets/mathplot.cpp @@ -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 ) { diff --git a/eeschema/dialogs/dialog_sim_settings_base.cpp b/eeschema/dialogs/dialog_sim_settings_base.cpp index 12b7719540..237f7d46e9 100644 --- a/eeschema/dialogs/dialog_sim_settings_base.cpp +++ b/eeschema/dialogs/dialog_sim_settings_base.cpp @@ -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 ); diff --git a/eeschema/dialogs/dialog_sim_settings_base.fbp b/eeschema/dialogs/dialog_sim_settings_base.fbp index 15dbb5431f..3905ebd67a 100644 --- a/eeschema/dialogs/dialog_sim_settings_base.fbp +++ b/eeschema/dialogs/dialog_sim_settings_base.fbp @@ -14,7 +14,6 @@ dialog_sim_settings_base 1000 none - 1 DIALOG_SIM_SETTINGS_BASE @@ -26,7 +25,6 @@ 1 1 UI - 0 0 0 @@ -876,21 +874,11 @@ 5 wxALIGN_CENTER_HORIZONTAL 0 - + bSizer151 wxHORIZONTAL none - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - 5 wxEXPAND @@ -2306,7 +2294,6 @@ - 0 @@ -2369,16 +2356,6 @@ - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - @@ -4743,7 +4720,6 @@ - 0 diff --git a/eeschema/dialogs/dialog_sim_settings_base.h b/eeschema/dialogs/dialog_sim_settings_base.h index f8f1ebffbc..b9fe3ddde3 100644 --- a/eeschema/dialogs/dialog_sim_settings_base.h +++ b/eeschema/dialogs/dialog_sim_settings_base.h @@ -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! diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 27f612224b..c1485cff82 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -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 ) ) )