On-the-fly language updates for simulator window.
Fixes https://gitlab.com/kicad/code/kicad/issues/13357
This commit is contained in:
parent
b000d68def
commit
a1a1a49729
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 CERN
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2023 CERN
|
||||
* Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Sylwester Kocjan <s.kocjan@o2.pl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -86,8 +86,8 @@ SIM_NOPLOT_PANEL::SIM_NOPLOT_PANEL( const wxString& aCommand, int aOptions, wxWi
|
|||
m_textInfo->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT,
|
||||
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
m_textInfo->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
|
||||
m_textInfo->SetLabel(
|
||||
_( "Simulation provided no plots. Please refer to console window for results." ) );
|
||||
m_textInfo->SetLabel( _( "Simulation provided no plots. Please refer to console window "
|
||||
"for results." ) );
|
||||
|
||||
m_sizer->Add( m_textInfo, 1, wxALL | wxEXPAND, 5 );
|
||||
m_sizer->Add( 0, 1, 1, wxEXPAND, 5 );
|
||||
|
@ -99,3 +99,12 @@ SIM_NOPLOT_PANEL::SIM_NOPLOT_PANEL( const wxString& aCommand, int aOptions, wxWi
|
|||
SIM_NOPLOT_PANEL::~SIM_NOPLOT_PANEL()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SIM_NOPLOT_PANEL::OnLanguageChanged()
|
||||
{
|
||||
m_textInfo->SetLabel( _( "Simulation provided no plots. Please refer to console window "
|
||||
"for results." ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 CERN
|
||||
* Copyright (C) 2016-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2023 CERN
|
||||
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Sylwester Kocjan <s.kocjan@o2.pl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -46,6 +46,8 @@ public:
|
|||
|
||||
static bool IsPlottable( SIM_TYPE aSimType );
|
||||
|
||||
virtual void OnLanguageChanged() = 0;
|
||||
|
||||
SIM_TYPE GetType() const;
|
||||
|
||||
protected:
|
||||
|
@ -81,6 +83,8 @@ public:
|
|||
|
||||
virtual ~SIM_NOPLOT_PANEL();
|
||||
|
||||
void OnLanguageChanged() override;
|
||||
|
||||
private:
|
||||
wxSizer* m_sizer;
|
||||
wxStaticText* m_textInfo;
|
||||
|
|
|
@ -212,6 +212,35 @@ void SIM_PLOT_FRAME::setupTools()
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::ShowChangedLanguage()
|
||||
{
|
||||
EDA_BASE_FRAME::ShowChangedLanguage();
|
||||
|
||||
updateTitle();
|
||||
|
||||
for( int ii = 0; ii < (int) m_workbook->GetPageCount(); ++ii )
|
||||
{
|
||||
SIM_PANEL_BASE* plot = dynamic_cast<SIM_PLOT_PANEL*>( m_workbook->GetPage( ii ) );
|
||||
|
||||
plot->OnLanguageChanged();
|
||||
|
||||
wxString pageTitle( m_simulator->TypeToName( plot->GetType(), true ) );
|
||||
pageTitle.Prepend( wxString::Format( _( "Plot%u - " ), ii+1 /* 1-based */ ) );
|
||||
|
||||
m_workbook->SetPageText( ii, pageTitle );
|
||||
}
|
||||
|
||||
m_staticTextSignals->SetLabel( _( "Signals" ) );
|
||||
updateSignalList();
|
||||
|
||||
m_staticTextCursors->SetLabel( _( "Cursors" ) );
|
||||
wxCommandEvent dummy;
|
||||
onCursorUpdate( dummy );
|
||||
|
||||
m_staticTextTune->SetLabel( _( "Tune" ) );
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||
{
|
||||
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
|
||||
|
|
|
@ -134,6 +134,8 @@ public:
|
|||
*/
|
||||
void ToggleDarkModePlots();
|
||||
|
||||
void ShowChangedLanguage() override;
|
||||
|
||||
void ReCreateHToolbar();
|
||||
|
||||
/**
|
||||
|
|
|
@ -341,16 +341,25 @@ SIM_PLOT_PANEL::~SIM_PLOT_PANEL()
|
|||
|
||||
void SIM_PLOT_PANEL::updateAxes()
|
||||
{
|
||||
bool skipAddToView = false;
|
||||
|
||||
if( m_axis_x )
|
||||
return;
|
||||
skipAddToView = true;
|
||||
|
||||
switch( GetType() )
|
||||
{
|
||||
case ST_AC:
|
||||
m_axis_x = new LOG_SCALE<mpScaleXLog>( _( "Frequency" ), wxT( "Hz" ), mpALIGN_BOTTOM );
|
||||
m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Gain" ), wxT( "dBV" ), mpALIGN_LEFT );
|
||||
m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Phase" ), wxT( "°" ), mpALIGN_RIGHT );
|
||||
m_axis_y2->SetMasterScale( m_axis_y1 );
|
||||
if( !m_axis_x )
|
||||
{
|
||||
m_axis_x = new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM );
|
||||
m_axis_y1 = new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "dBV" ), mpALIGN_LEFT );
|
||||
m_axis_y2 = new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "°" ), mpALIGN_RIGHT );
|
||||
m_axis_y2->SetMasterScale( m_axis_y1 );
|
||||
}
|
||||
|
||||
m_axis_x->SetName( _( "Frequency" ) );
|
||||
m_axis_y1->SetName( _( "Gain" ) );
|
||||
m_axis_y2->SetName( _( "Phase" ) );
|
||||
break;
|
||||
|
||||
case ST_DC:
|
||||
|
@ -358,15 +367,28 @@ void SIM_PLOT_PANEL::updateAxes()
|
|||
break;
|
||||
|
||||
case ST_NOISE:
|
||||
m_axis_x = new LOG_SCALE<mpScaleXLog>( _( "Frequency" ), wxT( "Hz" ), mpALIGN_BOTTOM );
|
||||
m_axis_y1 = new mpScaleY( _( "noise [(V or A)^2/Hz]" ), mpALIGN_LEFT );
|
||||
if( !m_axis_x )
|
||||
{
|
||||
m_axis_x = new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM );
|
||||
m_axis_y1 = new mpScaleY( wxEmptyString, mpALIGN_LEFT );
|
||||
}
|
||||
|
||||
m_axis_x->SetName( _( "Frequency" ) );
|
||||
m_axis_y1->SetName( _( "noise [(V or A)^2/Hz]" ) );
|
||||
break;
|
||||
|
||||
case ST_TRANSIENT:
|
||||
m_axis_x = new LIN_SCALE<mpScaleX>( _( "Time" ), wxT( "s" ), mpALIGN_BOTTOM );
|
||||
m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Voltage" ), wxT( "V" ), mpALIGN_LEFT );
|
||||
m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Current" ), wxT( "A" ), mpALIGN_RIGHT );
|
||||
m_axis_y2->SetMasterScale( m_axis_y1 );
|
||||
if( !m_axis_x )
|
||||
{
|
||||
m_axis_x = new LIN_SCALE<mpScaleX>( wxEmptyString, wxT( "s" ), mpALIGN_BOTTOM );
|
||||
m_axis_y1 = new LIN_SCALE<mpScaleY>(wxEmptyString, wxT( "V" ), mpALIGN_LEFT );
|
||||
m_axis_y2 = new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "A" ), mpALIGN_RIGHT );
|
||||
m_axis_y2->SetMasterScale( m_axis_y1 );
|
||||
}
|
||||
|
||||
m_axis_x->SetName( _( "Time" ) );
|
||||
m_axis_y1->SetName( _( "Voltage" ) );
|
||||
m_axis_y2->SetName( _( "Current" ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -374,6 +396,9 @@ void SIM_PLOT_PANEL::updateAxes()
|
|||
break;
|
||||
}
|
||||
|
||||
if( skipAddToView )
|
||||
return;
|
||||
|
||||
if( m_axis_x )
|
||||
{
|
||||
m_axis_x->SetTicks( false );
|
||||
|
@ -413,32 +438,51 @@ void SIM_PLOT_PANEL::prepareDCAxes()
|
|||
ch = rem.GetChar( 0 );
|
||||
}
|
||||
catch( ... )
|
||||
{;}
|
||||
{
|
||||
// Best efforts
|
||||
}
|
||||
|
||||
switch( ch )
|
||||
{
|
||||
// Make sure that we have a reliable default (even if incorrectly labeled)
|
||||
default:
|
||||
case 'v':
|
||||
m_axis_x = new LIN_SCALE<mpScaleX>( _( "Voltage (swept)" ), wxT( "V" ),
|
||||
mpALIGN_BOTTOM );
|
||||
if( !m_axis_x )
|
||||
m_axis_x = new LIN_SCALE<mpScaleX>( wxEmptyString, wxT( "V" ), mpALIGN_BOTTOM );
|
||||
|
||||
m_axis_x->SetName( _( "Voltage (swept)" ) );
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
m_axis_x = new LIN_SCALE<mpScaleX>( _( "Current (swept)" ), wxT( "A" ),
|
||||
mpALIGN_BOTTOM );
|
||||
if( !m_axis_x )
|
||||
m_axis_x = new LIN_SCALE<mpScaleX>( wxEmptyString, wxT( "A" ), mpALIGN_BOTTOM );
|
||||
|
||||
m_axis_x->SetName( _( "Current (swept)" ) );
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
m_axis_x = new LIN_SCALE<mpScaleX>( _( "Resistance (swept)" ), wxT( "Ω" ),
|
||||
mpALIGN_BOTTOM );
|
||||
if( !m_axis_x )
|
||||
m_axis_x = new LIN_SCALE<mpScaleX>( wxEmptyString, wxT( "Ω" ), mpALIGN_BOTTOM );
|
||||
|
||||
m_axis_x->SetName( _( "Resistance (swept)" ) );
|
||||
break;
|
||||
|
||||
case 't':
|
||||
m_axis_x = new LIN_SCALE<mpScaleX>( _( "Temperature (swept)" ), wxT( "°C" ),
|
||||
mpALIGN_BOTTOM );
|
||||
if( !m_axis_x )
|
||||
m_axis_x = new LIN_SCALE<mpScaleX>( wxEmptyString, wxT( "°C" ), mpALIGN_BOTTOM );
|
||||
|
||||
m_axis_x->SetName( _( "Temperature (swept)" ) );
|
||||
break;
|
||||
}
|
||||
|
||||
m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Voltage (measured)" ), wxT( "V" ), mpALIGN_LEFT );
|
||||
m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Current" ), wxT( "A" ), mpALIGN_RIGHT );
|
||||
if( !m_axis_y1 )
|
||||
m_axis_y1 = new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "V" ), mpALIGN_LEFT );
|
||||
|
||||
if( !m_axis_y2 )
|
||||
m_axis_y2 = new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "A" ), mpALIGN_RIGHT );
|
||||
|
||||
m_axis_y1->SetName( _( "Voltage (measured)" ) );
|
||||
m_axis_y2->SetName( _( "Current" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,6 +505,13 @@ void SIM_PLOT_PANEL::UpdatePlotColors()
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_PANEL::OnLanguageChanged()
|
||||
{
|
||||
updateAxes();
|
||||
m_plotWin->UpdateAll();
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_PANEL::UpdateTraceStyle( TRACE* trace )
|
||||
{
|
||||
int type = trace->GetType();
|
||||
|
@ -509,14 +560,7 @@ bool SIM_PLOT_PANEL::addTrace( const wxString& aTitle, const wxString& aName, in
|
|||
UpdateTraceStyle( trace );
|
||||
m_traces[ aTitle ] = trace;
|
||||
|
||||
// It is a trick to keep legend & coords always on the top
|
||||
for( mpLayer* l : m_topLevel )
|
||||
m_plotWin->DelLayer( l );
|
||||
|
||||
m_plotWin->AddLayer( (mpLayer*) trace );
|
||||
|
||||
for( mpLayer* l : m_topLevel )
|
||||
m_plotWin->AddLayer( l );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -85,10 +85,11 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
const TRACE* m_trace;
|
||||
bool m_updateRequired, m_updateRef;
|
||||
wxRealPoint m_coords;
|
||||
mpWindow* m_window;
|
||||
const TRACE* m_trace;
|
||||
bool m_updateRequired;
|
||||
bool m_updateRef;
|
||||
wxRealPoint m_coords;
|
||||
mpWindow* m_window;
|
||||
|
||||
static constexpr int DRAG_MARGIN = 10;
|
||||
};
|
||||
|
@ -279,6 +280,8 @@ public:
|
|||
///> Update plot colors
|
||||
void UpdatePlotColors();
|
||||
|
||||
void OnLanguageChanged() override;
|
||||
|
||||
///< Getter for math plot window
|
||||
mpWindow* GetPlotWin() const
|
||||
{
|
||||
|
@ -314,8 +317,6 @@ private:
|
|||
mpInfoLegend* m_legend;
|
||||
|
||||
bool m_dotted_cp;
|
||||
|
||||
std::vector<mpLayer*> m_topLevel;
|
||||
};
|
||||
|
||||
wxDECLARE_EVENT( EVT_SIM_CURSOR_UPDATE, wxCommandEvent );
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <tool/tool_manager.h>
|
||||
#include <tools/ee_actions.h>
|
||||
#include <widgets/wx_menubar.h>
|
||||
#include "menus_helpers.h"
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::ReCreateHToolbar()
|
||||
|
@ -79,6 +80,7 @@ void SIM_PLOT_FRAME::doReCreateMenuBar()
|
|||
wxMenuBar* oldMenuBar = dynamic_cast<EDA_BASE_FRAME*>( this )->GetMenuBar();
|
||||
WX_MENUBAR* menuBar = new WX_MENUBAR();
|
||||
|
||||
|
||||
//-- File menu -----------------------------------------------------------
|
||||
//
|
||||
ACTION_MENU* fileMenu = new ACTION_MENU( false, tool );
|
||||
|
@ -97,6 +99,7 @@ void SIM_PLOT_FRAME::doReCreateMenuBar()
|
|||
fileMenu->AppendSeparator();
|
||||
fileMenu->AddClose( _( "Simulator" ) );
|
||||
|
||||
|
||||
//-- View menu -----------------------------------------------------------
|
||||
//
|
||||
ACTION_MENU* viewMenu = new ACTION_MENU( false, tool );
|
||||
|
@ -111,6 +114,7 @@ void SIM_PLOT_FRAME::doReCreateMenuBar()
|
|||
viewMenu->Add( EE_ACTIONS::toggleDottedSecondary, ACTION_MENU::CHECK );
|
||||
viewMenu->Add( EE_ACTIONS::toggleDarkModePlots, ACTION_MENU::CHECK );
|
||||
|
||||
|
||||
//-- Simulation menu -----------------------------------------------------------
|
||||
//
|
||||
ACTION_MENU* simulationMenu = new ACTION_MENU( false, tool );
|
||||
|
@ -126,11 +130,31 @@ void SIM_PLOT_FRAME::doReCreateMenuBar()
|
|||
simulationMenu->AppendSeparator();
|
||||
simulationMenu->Add( EE_ACTIONS::showNetlist );
|
||||
|
||||
|
||||
//-- Preferences menu -----------------------------------------------
|
||||
//
|
||||
ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool );
|
||||
|
||||
//prefsMenu->Add( ACTIONS::configurePaths );
|
||||
//prefsMenu->Add( EE_ACTIONS::showSimLibTable );
|
||||
|
||||
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
|
||||
// Mac, and it needs the wxID_PREFERENCES id to find it.
|
||||
prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
|
||||
_( "Show preferences for all open tools" ),
|
||||
wxID_PREFERENCES,
|
||||
BITMAPS::preference );
|
||||
|
||||
prefsMenu->AppendSeparator();
|
||||
AddMenuLanguageList( prefsMenu, tool );
|
||||
|
||||
|
||||
//-- Menubar -------------------------------------------------------------
|
||||
//
|
||||
menuBar->Append( fileMenu, _( "&File" ) );
|
||||
menuBar->Append( viewMenu, _( "&View" ) );
|
||||
menuBar->Append( simulationMenu, _( "&Simulation" ) );
|
||||
menuBar->Append( prefsMenu, _( "&Preferences" ) );
|
||||
dynamic_cast<EDA_BASE_FRAME*>( this )->AddStandardHelpMenu( menuBar );
|
||||
|
||||
dynamic_cast<EDA_BASE_FRAME*>( this )->SetMenuBar( menuBar );
|
||||
|
|
Loading…
Reference in New Issue