Minor improvements to tuner panel look & feel.

This commit is contained in:
Jeff Young 2022-12-23 15:26:47 +00:00
parent 9cd9d7a36a
commit e2f2f3518b
4 changed files with 681 additions and 503 deletions

View File

@ -28,7 +28,7 @@
#include <sim/sim_plot_frame.h>
#include <sch_symbol.h>
#include <template_fieldnames.h>
#include <sim/ngspice_circuit_model.h>
#include <widgets/std_bitmap_button.h>
#include <cmath> // log log1p expm1
#include <complex> // norm
@ -49,21 +49,24 @@ TUNER_SLIDER::TUNER_SLIDER( SIM_PLOT_FRAME* aFrame, wxWindow* aParent, SCH_SYMBO
m_item = aFrame->GetExporter()->FindItem( std::string( ref.ToUTF8() ) );
if( !m_item )
{
throw KI_PARAM_ERROR( wxString::Format( _( "Could not find Spice item with reference '%s'" ),
ref ) );
}
m_name->SetLabel( ref );
m_closeBtn->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
const SIM_MODEL::PARAM* tunerParam = m_item->model->GetTunerParam();
if( !tunerParam )
throw KI_PARAM_ERROR( wxString::Format(
_( "Symbol '%s' has simulation model of type '%s %s', which cannot be tuned" ),
ref,
m_item->model->GetDeviceInfo().fieldValue,
m_item->model->GetTypeInfo().fieldValue ) );
{
throw KI_PARAM_ERROR( wxString::Format( _( "Symbol '%s' has simulation model of type '%s %s', "
"which cannot be tuned" ),
ref,
m_item->model->GetDeviceInfo().fieldValue,
m_item->model->GetTypeInfo().fieldValue ) );
}
// Special case for potentiometers because we don't have value ranges implemented yet.
if( m_item->model->GetType() == SIM_MODEL::TYPE::R_POT )
@ -93,6 +96,8 @@ TUNER_SLIDER::TUNER_SLIDER( SIM_PLOT_FRAME* aFrame, wxWindow* aParent, SCH_SYMBO
m_simTimer.SetOwner( this );
Connect( wxEVT_TIMER, wxTimerEventHandler( TUNER_SLIDER::onSimTimer ), nullptr, this );
Layout();
}

View File

@ -1,10 +1,12 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/std_bitmap_button.h"
#include "tuner_slider_base.h"
///////////////////////////////////////////////////////////////////////////
@ -14,18 +16,22 @@ TUNER_SLIDER_BASE::TUNER_SLIDER_BASE( wxWindow* parent, wxWindowID id, const wxP
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_panel1 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN|wxTAB_TRAVERSAL );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerUpper;
bSizerUpper = new wxBoxSizer( wxHORIZONTAL );
bSizerUpper = new wxBoxSizer( wxVERTICAL );
m_name = new wxStaticText( this, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, 0 );
m_name = new wxStaticText( m_panel1, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, 0 );
m_name->Wrap( -1 );
bSizerUpper->Add( m_name, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_closeBtn = new wxButton( this, wxID_ANY, _(" X "), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
bSizerUpper->Add( m_closeBtn, 0, wxALL, 5 );
bSizerUpper->Add( m_name, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( bSizerUpper, 0, wxALL|wxEXPAND, 5 );
bSizer6->Add( bSizerUpper, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_staticline4 = new wxStaticLine( m_panel1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizer6->Add( m_staticline4, 0, wxEXPAND|wxTOP|wxBOTTOM, 3 );
wxBoxSizer* bSizerMiddle;
bSizerMiddle = new wxBoxSizer( wxHORIZONTAL );
@ -33,8 +39,8 @@ TUNER_SLIDER_BASE::TUNER_SLIDER_BASE( wxWindow* parent, wxWindowID id, const wxP
wxBoxSizer* bSizerSlider;
bSizerSlider = new wxBoxSizer( wxVERTICAL );
m_slider = new wxSlider( this, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LEFT|wxSL_VERTICAL );
bSizerSlider->Add( m_slider, 1, 0, 5 );
m_slider = new wxSlider( m_panel1, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LEFT|wxSL_VERTICAL );
bSizerSlider->Add( m_slider, 1, wxTOP|wxBOTTOM, 5 );
bSizerMiddle->Add( bSizerSlider, 0, wxEXPAND, 5 );
@ -42,17 +48,17 @@ TUNER_SLIDER_BASE::TUNER_SLIDER_BASE( wxWindow* parent, wxWindowID id, const wxP
wxGridSizer* gSizerTxtCtr;
gSizerTxtCtr = new wxGridSizer( 0, 1, 0, 0 );
m_maxText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_maxText = new wxTextCtrl( m_panel1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_maxText->SetMinSize( wxSize( 70,-1 ) );
gSizerTxtCtr->Add( m_maxText, 0, wxALIGN_TOP|wxALL, 5 );
m_valueText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_valueText = new wxTextCtrl( m_panel1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_valueText->SetMinSize( wxSize( 70,-1 ) );
gSizerTxtCtr->Add( m_valueText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_minText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_minText = new wxTextCtrl( m_panel1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_minText->SetMinSize( wxSize( 70,-1 ) );
gSizerTxtCtr->Add( m_minText, 0, wxALIGN_BOTTOM|wxALL, 5 );
@ -61,17 +67,35 @@ TUNER_SLIDER_BASE::TUNER_SLIDER_BASE( wxWindow* parent, wxWindowID id, const wxP
bSizerMiddle->Add( gSizerTxtCtr, 1, wxEXPAND, 5 );
bSizerMain->Add( bSizerMiddle, 1, wxEXPAND, 5 );
bSizer6->Add( bSizerMiddle, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 );
m_saveBtn = new wxButton( this, wxID_ANY, _("Save"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerMain->Add( m_saveBtn, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
wxBoxSizer* bSizerBottom;
bSizerBottom = new wxBoxSizer( wxHORIZONTAL );
m_saveBtn = new wxButton( m_panel1, wxID_ANY, _("Save"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerBottom->Add( m_saveBtn, 0, wxEXPAND|wxRIGHT|wxLEFT, 3 );
bSizerBottom->Add( 5, 0, 1, wxEXPAND, 5 );
m_closeBtn = new STD_BITMAP_BUTTON( m_panel1, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bSizerBottom->Add( m_closeBtn, 0, wxALIGN_CENTER_VERTICAL, 5 );
bSizer6->Add( bSizerBottom, 0, wxEXPAND|wxALL, 3 );
m_panel1->SetSizer( bSizer6 );
m_panel1->Layout();
bSizer6->Fit( m_panel1 );
bSizerMain->Add( m_panel1, 1, wxEXPAND|wxRIGHT, 5 );
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
// Connect Events
m_closeBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TUNER_SLIDER_BASE::onClose ), NULL, this );
m_slider->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( TUNER_SLIDER_BASE::onSliderChanged ), NULL, this );
m_slider->Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( TUNER_SLIDER_BASE::onSliderChanged ), NULL, this );
m_slider->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( TUNER_SLIDER_BASE::onSliderChanged ), NULL, this );
@ -88,12 +112,12 @@ TUNER_SLIDER_BASE::TUNER_SLIDER_BASE( wxWindow* parent, wxWindowID id, const wxP
m_minText->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( TUNER_SLIDER_BASE::onMinKillFocus ), NULL, this );
m_minText->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( TUNER_SLIDER_BASE::onMinTextEnter ), NULL, this );
m_saveBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TUNER_SLIDER_BASE::onSave ), NULL, this );
m_closeBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TUNER_SLIDER_BASE::onClose ), NULL, this );
}
TUNER_SLIDER_BASE::~TUNER_SLIDER_BASE()
{
// Disconnect Events
m_closeBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TUNER_SLIDER_BASE::onClose ), NULL, this );
m_slider->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( TUNER_SLIDER_BASE::onSliderChanged ), NULL, this );
m_slider->Disconnect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( TUNER_SLIDER_BASE::onSliderChanged ), NULL, this );
m_slider->Disconnect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( TUNER_SLIDER_BASE::onSliderChanged ), NULL, this );
@ -110,5 +134,6 @@ TUNER_SLIDER_BASE::~TUNER_SLIDER_BASE()
m_minText->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( TUNER_SLIDER_BASE::onMinKillFocus ), NULL, this );
m_minText->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( TUNER_SLIDER_BASE::onMinTextEnter ), NULL, this );
m_saveBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TUNER_SLIDER_BASE::onSave ), NULL, this );
m_closeBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TUNER_SLIDER_BASE::onClose ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -10,19 +10,23 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class STD_BITMAP_BUTTON;
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/statline.h>
#include <wx/slider.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/sizer.h>
#include <wx/slider.h>
#include <wx/textctrl.h>
#include <wx/bmpbuttn.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
@ -36,16 +40,17 @@ class TUNER_SLIDER_BASE : public wxPanel
private:
protected:
wxPanel* m_panel1;
wxStaticText* m_name;
wxButton* m_closeBtn;
wxStaticLine* m_staticline4;
wxSlider* m_slider;
wxTextCtrl* m_maxText;
wxTextCtrl* m_valueText;
wxTextCtrl* m_minText;
wxButton* m_saveBtn;
STD_BITMAP_BUTTON* m_closeBtn;
// Virtual event handlers, override them in your derived class
virtual void onClose( wxCommandEvent& event ) { event.Skip(); }
virtual void onSliderChanged( wxScrollEvent& event ) { event.Skip(); }
virtual void onMaxKillFocus( wxFocusEvent& event ) { event.Skip(); }
virtual void onMaxTextEnter( wxCommandEvent& event ) { event.Skip(); }
@ -54,11 +59,12 @@ class TUNER_SLIDER_BASE : public wxPanel
virtual void onMinKillFocus( wxFocusEvent& event ) { event.Skip(); }
virtual void onMinTextEnter( wxCommandEvent& event ) { event.Skip(); }
virtual void onSave( wxCommandEvent& event ) { event.Skip(); }
virtual void onClose( wxCommandEvent& event ) { event.Skip(); }
public:
TUNER_SLIDER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 126,283 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
TUNER_SLIDER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxBORDER_NONE|wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~TUNER_SLIDER_BASE();