pnlgnucapdc.cpp

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

CPP
351
字号
//*****************************************************************************//                               PnlGnuCapDC.cpp                              *//                              -----------------                             *//  Started     : 18/08/2003                                                  *//  Last Update : 07/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 "PnlGnuCapDC.hpp"//*****************************************************************************// Implement an event table.BEGIN_EVENT_TABLE( PnlGnuCapDC, PnlAnaBase )  EVT_CHOICE  ( ID_CHO_SRCCPNT, PnlGnuCapDC::OnSrcCpnt )  EVT_RADIOBOX( ID_RBX_SCALE,   PnlGnuCapDC::OnScale   )END_EVENT_TABLE( )//*****************************************************************************// Constructor.PnlGnuCapDC::PnlGnuCapDC( wxWindow * poWin ) : PnlAnaBase( poWin ){  bSetType( Simulation::eANA_DC );  Create( );  InitSwpUnts( );  bClear( );}//*****************************************************************************// Destructor.PnlGnuCapDC::~PnlGnuCapDC( ){}//*****************************************************************************// Create the display objects.void  PnlGnuCapDC::Create( void ){  int  ix, iy;  // Set the frequency sweep parameters  m_oSbxSwpPars.GetSize( &ix, &iy );  m_oSbxSwpPars.SetSize(  ix, 201 );  m_oSbxSwpPars.SetLabel( wxT("DC Sweep") );  m_oPnlStart  .bSetName( wxT("Start Value") );  m_oPnlStop   .bSetName( wxT("Stop Value") );  // Create and add the scale radio butwons  wxString  osScale[3] = { wxT("Lin  "), wxT("Log"), wxT("Dec ") };  m_oRbxScale.Create( this, ID_RBX_SCALE, wxT("Step Scale"),                      wxPoint( 13, 123 ), wxDefaultSize, 3, osScale, 3 );  bSetScale( eSCALE_LIN );  // Create and add input source  new wxStaticText( this, ID_UNUSED, wxT("Sweep Source"), wxPoint(  18, 176 ) );  m_oChoSrcCpnt.Create( this, ID_CHO_SRCCPNT,             wxPoint( 113, 171 ),                        wxSize( 110, 27 ) );  CreateTemp( ); // Create and add the analysis temperature controls}//*****************************************************************************// Initialize the sweep parameter units.void  PnlGnuCapDC::InitSwpUnts( void ){  wxString  os1;  ChoUnits::eUnitsType  eUnits;  // Determine the sweep parameters  switch( wxToupper( m_oChoSrcCpnt.GetStringSelection( ).GetChar( 0 ) ) )  {    case wxT('C'): // Units of capacitance      os1 = wxT("Capacitance");      eUnits = ChoUnits::eUNTS_CAP;      break;    case wxT('L'): // Units of inductance      os1 = wxT("Inductance");      eUnits = ChoUnits::eUNTS_IND;      break;    case wxT('R'): // Units of resistance      os1 = wxT("Resistance");      eUnits = ChoUnits::eUNTS_RES;      break;    case wxT('I'): // Units of current      os1 = wxT("Current");      eUnits = ChoUnits::eUNTS_CURR;      break;    case wxT('V'): // Units of voltage      os1 = wxT("Voltage");      eUnits = ChoUnits::eUNTS_VOLT;      break;    default: // No units      os1 = wxT("Value");      eUnits = ChoUnits::eUNTS_NONE;  }  // Set the sweep parameters  m_oPnlStart.bSetName( wxString( wxT("Start ") ) + os1 );  m_oPnlStop .bSetName( wxString( wxT("Stop ")  ) + os1 );  m_oPnlStart.bSetUType( eUnits );  m_oPnlStop .bSetUType( eUnits );  m_oPnlStep .bSetUType( eUnits );}//*****************************************************************************// Set the state of the step scale radio box.//// Argument List://   eScale - The enumerated scale specifier//// Return Values://   Success - TRUE//   Failure - FALSEbool  PnlGnuCapDC::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  PnlGnuCapDC::bClear( void ){  bool  bRtn=TRUE;  // Clear the base class  if( ! PnlAnaBase::bClear( ) )   bRtn = FALSE;  m_oPnlStart.bSetValue( (float)  0.0 );  m_oPnlStep .bSetValue( (float) 10.0 );  // Set default scale value  if( ! bSetScale( eSCALE_LIN ) ) bRtn = FALSE;  // Set input source default values  m_oChoSrcCpnt.Clear( );  m_oChoSrcCpnt.Append( wxT("None") );  m_oChoSrcCpnt.SetSelection( 0 );  return( bRtn );}//*****************************************************************************// Load information from a Simulation object.//// Argument List://   roSim - The Simulation object//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlGnuCapDC::bLoad( Simulation & roSim ){  wxCommandEvent  oEvtCmd;  wxString  os1;  bool  bRtn=TRUE;  uint  ui1;  m_oChoSrcCpnt.Clear( );  m_oChoSrcCpnt.Append( wxT("None") );  // Load the components into the source 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'):      case wxT('R'):      case wxT('C'):      case wxT('L'): 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( bRtn );  // Set the sweep source (before setting the sweep start, stop and step)  os1 = roSim.rosGetSrcCpnt( ).BeforeFirst( wxT(' ') );  if( m_oChoSrcCpnt.FindString( os1 ) != wxNOT_FOUND )    m_oChoSrcCpnt.SetStringSelection( os1 );  else bRtn = FALSE;  OnSrcCpnt( oEvtCmd );  // Perform any base class load tasks  if( ! PnlAnaBase::bLoad( roSim ) ) bRtn = FALSE;  // Set the sweep scale  m_oRbxScale.SetSelection( roSim.iGetSwpScale( ) );  OnScale( oEvtCmd );  return( bRtn );}//*****************************************************************************// Reload information from a Simulation object.//// Argument List://   roSim - The Simulation object//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlGnuCapDC::bReload( Simulation & roSim ){  wxString  os1;  os1 = m_oChoSrcCpnt.GetStringSelection( );    if( ! bLoad( roSim ) ) return( FALSE );  if( !os1.IsEmpty( ) && os1!=wxT("None") )    m_oChoSrcCpnt.SetStringSelection( os1 );  return( TRUE );}//*****************************************************************************// Save information to a Simulation object.//// Argument List://   roSim - The Simulation object//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlGnuCapDC::bSave( Simulation & roSim ){  wxString  os1;  float     f1;  int       i1;  // 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  i1 = m_oRbxScale.GetSelection( );  if( i1 == (int) eSCALE_LOG )    if( m_oPnlStep.dfGetValue( ) == 1.0 )      SetError( wxT("Step multiplier invalid, must be non-unity.") );  if( ! roSim.bSetSwpScale( i1 ) )    SetError( wxT("Sweep scale couldn't be set.") );  // Set the component to be used as the sweep source  if( m_oChoSrcCpnt.GetSelection( ) > 0 )  {    os1 = m_oChoSrcCpnt.GetStringSelection( );    if( ! roSim.bSetSrcCpnt( os1 ) )      SetError( wxT("Source component couldn't be set.") );  }  else SetError( wxT("No source component has been selected.") );  return( bIsOk( ) );}//*****************************************************************************//                                                                            *//                             Event Handlers                                 *//                                                                            *//*****************************************************************************// Step scale radio box event handler.//// Argument List://   roEvtCmd - An object holding information about the eventvoid  PnlGnuCapDC::OnScale( wxCommandEvent & roEvtCmd ){  switch( m_oRbxScale.GetSelection( ) )  {    case eSCALE_LIN:      m_oPnlStep.bSetName( wxT("Step Increment") );      m_oPnlStep.bSetVType( SpinCtrl::eVAR_FLT );      m_oPnlStep.bSetParms( 10.0, 1.0, 1000.0, 1.0, 100.0 );      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;    default:      break;  }}//*****************************************************************************// Source component choice box event handler.//// Argument List://   roEvtCmd - An object holding information about the eventvoid  PnlGnuCapDC::OnSrcCpnt( wxCommandEvent & roEvtCmd ){  InitSwpUnts( );}//*****************************************************************************

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?