pnlngspiceac.cpp
来自「gspiceui电子CAD仿真程序.用于电路参数模拟仿真」· C++ 代码 · 共 310 行
CPP
310 行
//*****************************************************************************// PnlNgSpiceAC.cpp *// ------------------ *// Started : 04/08/2004 *// Last Update : 20/07/2005 *// Copyright : (C) 2004 by MSWaters *// Email : M.Waters@bom.gov.au *//*****************************************************************************//*****************************************************************************// *// This program is free software; you can redistribute it and/or modify *// it under the terms of the GNU General Public License as published by *// the Free Software Foundation; either version 2 of the License, or *// (at your option) any later version. *// *//*****************************************************************************#include "PnlNgSpiceAC.hpp"//*****************************************************************************// Implement an event table.BEGIN_EVENT_TABLE( PnlNgSpiceAC, PnlAnaBase ) EVT_RADIOBOX( ID_RBX_SCALE, PnlNgSpiceAC::OnScale ) EVT_CHOICE ( ID_CHO_SRCCPNT, PnlNgSpiceAC::OnSrcCpnt )END_EVENT_TABLE( )//*****************************************************************************// Constructor.PnlNgSpiceAC::PnlNgSpiceAC( wxWindow * poWin ) : PnlAnaBase( poWin ){ bSetType( Simulation::eANA_AC ); Create( ); bClear( );}//*****************************************************************************// Destructor.PnlNgSpiceAC::~PnlNgSpiceAC( ){}//*****************************************************************************// Create the display objects.void PnlNgSpiceAC::Create( void ){ int ix, iy; // Disable the checkboxes for the parameters NG-Spice cannot calculate m_oCbxCurrent.Disable( ); m_oCbxPower .Disable( ); m_oCbxResist .Disable( ); // Set the frequency sweep parameter labels m_oSbxSwpPars.GetSize( &ix, &iy ); m_oSbxSwpPars.SetSize( ix, 167 ); m_oSbxSwpPars.SetLabel( wxT("AC Sweep") ); m_oPnlStart .bSetName( wxT("Start Frequency") ); m_oPnlStop .bSetName( wxT("Stop Frequency") ); // Set sweep parameter spin control parameters and units m_oPnlStart.bSetUType( ChoUnits::eUNTS_FREQ ); m_oPnlStop .bSetUType( ChoUnits::eUNTS_FREQ ); m_oPnlStep .bSetVType( SpinCtrl::eVAR_INT ); m_oPnlStep .bShowChoUnts( FALSE ); // Create and add the scale radio buttons wxString osScale[4] = { wxT("Lin "), wxT("Log"), wxT("Dec"), wxT("Oct ") }; m_oRbxScale.Create( this, ID_RBX_SCALE, wxT("Step Scale"), wxPoint( 13, 123 ), wxDefaultSize, 4, osScale, 4 ); m_oRbxScale.Enable( 1, FALSE ); // Disable scale option NG-Spice doesn't support bSetScale( eSCALE_LIN ); CreateCpxPrt( ); // Create the simulation parameter complex part check boxes CreateTemp( ); // Create the analysis temperature controls CreateSrc( ); // Create input source controls}//*****************************************************************************// Set the state of the step scale radio box.//// Argument List:// eScale - The enumerated scale specifier//// Return Values:// Success - TRUE// Failure - FALSEbool PnlNgSpiceAC::bSetScale( eScaleType eScale ){ wxCommandEvent oEvtCmd; if( eScale<eSCALE_FST || eScale>eSCALE_LST ) return( FALSE ); if( m_oRbxScale.GetCount( ) < (eScale + 1) ) return( FALSE ); m_oRbxScale.SetSelection( (int) eScale ); OnScale( oEvtCmd ); return( TRUE );}//*****************************************************************************// Clear the object attributes.//// Return Values:// TRUE - Success// FALSE - Failurebool PnlNgSpiceAC::bClear( void ){ bool bRtn=TRUE; // Clear the base class if( ! PnlAnaBase::bClear( ) ) bRtn = FALSE; m_oPnlStart.bSetValue( (float) 1.0 ); m_oPnlStep .bSetValue( (float) 10.0 ); // Set the default sweep units m_oPnlStart.bSetUnits( wxT("kHz") ); m_oPnlStop .bSetUnits( wxT("kHz") ); // Set default scale value if( ! bSetScale( eSCALE_DEC ) ) bRtn = FALSE; return( bRtn );}//*****************************************************************************// Load information from a Simulation object.//// Argument List:// roSim - The Simulation object//// Return Values:// TRUE - Success// FALSE - Failurebool PnlNgSpiceAC::bLoad( Simulation & roSim ){ wxString os1; bool bRtn=TRUE; uint ui1; m_oChoSrcCpnt.Clear( ); m_oChoSrcCpnt.Append( wxT("None") ); // Load the components into the choice box const wxArrayString & roasCpnts = roSim.roasGetCpntLbls( ); for( ui1=0; ui1<roasCpnts.GetCount( ); ui1++ ) { os1 = roasCpnts.Item( ui1 ); if( os1.Length( ) <= 0 ) continue; switch( wxToupper( os1.GetChar( 0 ) ) ) { case wxT('V'): case wxT('I'): break; default : continue; } m_oChoSrcCpnt.Append( os1 ); } m_oChoSrcCpnt.SetStringSelection( wxT("None") ); // Don't go any further if the analysis type doesn't match if( roSim.eGetAnaType( ) != eGetType( ) ) return( TRUE ); // Perform any base class load tasks if( ! PnlAnaBase::bLoad( roSim ) ) bRtn = FALSE; // Set the sweep scale m_oRbxScale.SetSelection( roSim.iGetSwpScale( ) ); wxCommandEvent oEvtCmd; OnScale( oEvtCmd ); return( bRtn );}//*****************************************************************************// Reload information from a Simulation object.//// Argument List:// roSim - The Simulation object//// Return Values:// TRUE - Success// FALSE - Failurebool PnlNgSpiceAC::bReload( Simulation & roSim ){ ChoUnits::eUnitsType eUType; wxString os1, os2; os1 = m_oChoSrcCpnt.GetStringSelection( ); eUType = m_oPnlSrcLvl.eGetUType( ); os2 = m_oPnlSrcLvl.rosGetValue( ); if( ! bLoad( roSim ) ) return( FALSE ); if( !os1.IsEmpty( ) && os1!=wxT("None") ) { m_oChoSrcCpnt.SetStringSelection( os1 ); m_oPnlSrcLvl.bSetUType( eUType ); m_oPnlSrcLvl.bSetValue( os2 ); } return( TRUE );}//*****************************************************************************// Save information to a Simulation object.//// Argument List:// roSim - The Simulation object//// Return Values:// TRUE - Success// FALSE - Failurebool PnlNgSpiceAC::bSave( Simulation & roSim ){ wxStringTokenizer ostk1; wxString os1; int i1; size_t szt1; // Execute base class save tasks PnlAnaBase::bSave( roSim ); // Check the start frequency (can't set a frequency of zero so set one as // small as possible, 1.4e-45 is as small as I can go as a float but it will // be converted to a string in engineering unit so use 1.0e-15 = 1.0f) if( roSim.fGetSwpStart( ) == 0.0 ) roSim.bSetSwpStart( 1.0e-15 ); // Set the sweep parameters i1 = m_oRbxScale.GetSelection( ); if( ! roSim.bSetSwpScale( i1 ) ) SetError( wxT("Sweep scale couldn't be set.") ); // Set the component to be used as the sweep source if( m_oPnlSrcLvl.dfGetValue( ) != 0.0 ) { os1 = roSim.rosGetSrcCpnt( ); szt1 = os1.Find( wxT(' '), TRUE ); os1.insert( szt1, wxT(" AC") ); if( ! roSim.bSetSrcCpnt( os1 ) ) SetError( wxT("Source component couldn't be set.") ); } else SetError( wxT("Source component value of zero is not permitted.") ); return( bIsOk( ) );}//*****************************************************************************// *// Event Handlers *// *//*****************************************************************************// Step scale radio box event handler.//// Argument List:// roEvtCmd - An object holding information about the eventvoid PnlNgSpiceAC::OnScale( wxCommandEvent & roEvtCmd ){ switch( m_oRbxScale.GetSelection( ) ) { case eSCALE_LIN: m_oPnlStep.bSetName( wxT("Steps in Total") ); m_oPnlStep.bSetParms( 10, 1, 1000, 1, 100 ); break; case eSCALE_DEC: m_oPnlStep.bSetName( wxT("Steps / Decade") ); m_oPnlStep.bSetParms( 10, 1, 1000, 1, 100 ); break; case eSCALE_OCT: m_oPnlStep.bSetName( wxT("Steps / Octave") ); m_oPnlStep.bSetParms( 10, 1, 1000, 1, 100 ); break; default: break; }}//*****************************************************************************// Source component choice box event handler.//// Argument List:// roEvtCmd - An object holding information about the eventvoid PnlNgSpiceAC::OnSrcCpnt( wxCommandEvent & roEvtCmd ){ if( m_oChoSrcCpnt.GetSelection( ) == 0 ) m_oPnlSrcLvl.bSetValue( (double) 0.0 ); else if( m_oPnlSrcLvl.dfGetValue( ) == 0.0 ) m_oPnlSrcLvl.bSetValue( (double) 1.0 ); SetSrcUType( ); if( m_oPnlSrcLvl.eGetUType( ) == ChoUnits::eUNTS_VOLT ) m_oPnlSrcLvl.bSetUnits( wxT("V") );}//*****************************************************************************
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?