pnlgnucapac.cpp

来自「gspiceui电子CAD仿真程序.用于电路参数模拟仿真」· C++ 代码 · 共 319 行

CPP
319
字号
//*****************************************************************************//                               PnlGnuCapAC.cpp                              *//                              -----------------                             *//  Started     : 18/08/2003                                                  *//  Last Update : 20/07/2005                                                  *//  Copyright   : (C) 2003 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 "PnlGnuCapAC.hpp"//*****************************************************************************// Implement an event table.BEGIN_EVENT_TABLE( PnlGnuCapAC, PnlAnaBase )  EVT_RADIOBOX( ID_RBX_SCALE,   PnlGnuCapAC::OnScale   )  EVT_CHOICE  ( ID_CHO_SRCCPNT, PnlGnuCapAC::OnSrcCpnt )END_EVENT_TABLE( )//*****************************************************************************// Constructor.PnlGnuCapAC::PnlGnuCapAC( wxWindow * poWin ) : PnlAnaBase( poWin ){  bSetType( Simulation::eANA_AC );  Create( );  bClear( );}//*****************************************************************************// Destructor.PnlGnuCapAC::~PnlGnuCapAC( ){}//*****************************************************************************// Create the display objects.void  PnlGnuCapAC::Create( void ){  int  ix, iy;  // 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 units  m_oPnlStart.bSetUType( ChoUnits::eUNTS_FREQ );  m_oPnlStop .bSetUType( ChoUnits::eUNTS_FREQ );  m_oPnlStep .bSetUType( ChoUnits::eUNTS_FREQ );  // 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 );  bSetScale( eSCALE_LIN );  CreateCpxPrt( ); // Create the simulation parameter complex part check boxes  CreateTemp( );   // Create the analysis temperature controls  CreateSrc( );    // Create the 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  PnlGnuCapAC::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  PnlGnuCapAC::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") );  m_oPnlStep .bShowChoUnts( TRUE );  m_oPnlStep .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  PnlGnuCapAC::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 'V':      case '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  PnlGnuCapAC::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  PnlGnuCapAC::bSave( Simulation & roSim ){  wxString  os1;  float     f1;  size_t    szt1;  // Execute base class save tasks  PnlAnaBase::bSave( roSim );  // Check that the step size is valid  if( m_oRbxScale.GetSelection( ) == 0 )  {    f1 = fabs( roSim.fGetSwpStop( ) - roSim.fGetSwpStart( ) );    if( roSim.fGetSwpStep( ) > f1 )      SetError( wxT("Step size is greater than sweep range.") );  }  // Set the sweep scale  szt1 = m_oRbxScale.GetSelection( );  if( ! roSim.bSetSwpScale( szt1 ) )    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(" GENERATOR(1) 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  PnlGnuCapAC::OnScale( wxCommandEvent & roEvtCmd ){  switch( m_oRbxScale.GetSelection( ) )  {    case eSCALE_LIN:      m_oPnlStep.bSetName( wxT("Step Increment") );      m_oPnlStep.bSetVType( SpinCtrl::eVAR_FLT );      m_oPnlStep.bSetUType( ChoUnits::eUNTS_FREQ );      m_oPnlStep.bShowChoUnts( TRUE );      break;    case eSCALE_LOG:      m_oPnlStep.bSetName( wxT("Step Multiplier") );      m_oPnlStep.bSetVType( SpinCtrl::eVAR_FLT );      m_oPnlStep.bSetParms( 1.1, 0.1, 100.0, 1.0, 10.0 );      m_oPnlStep.bShowChoUnts( FALSE );      break;    case eSCALE_DEC:      m_oPnlStep.bSetName( wxT("Steps / Decade") );      m_oPnlStep.bSetVType( SpinCtrl::eVAR_INT );      m_oPnlStep.bSetParms( 10, 1, 1000, 1, 100 );      m_oPnlStep.bShowChoUnts( FALSE );      break;    case eSCALE_OCT:      m_oPnlStep.bSetName( wxT("Steps / Octave") );      m_oPnlStep.bSetVType( SpinCtrl::eVAR_INT );      m_oPnlStep.bSetParms( 10, 1, 1000, 1, 100 );      m_oPnlStep.bShowChoUnts( FALSE );      break;    default:      break;  }}//*****************************************************************************// Source component choice box event handler.//// Argument List://   roEvtCmd - An object holding information about the eventvoid  PnlGnuCapAC::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 + -
显示快捷键?