dlggencfg.cpp

来自「gspiceui电子CAD仿真程序.用于电路参数模拟仿真」· C++ 代码 · 共 448 行 · 第 1/2 页

CPP
448
字号
void  DlgGenCfg::SetPnlValues( void ){  int  i1;  SetEvtHandlerEnabled( FALSE );  for( i1=ID_PNL_FST; i1<=ID_PNL_LST; i1++ )    roGetPanel( i1 ).bSetValue( (float) m_dfPnlValue[ i1 ] );  SetEvtHandlerEnabled( TRUE );}//*****************************************************************************// Get the values from the spin controls and put them in temporary storage.void  DlgGenCfg::GetPnlValues( void ){  int  i1;  SetEvtHandlerEnabled( FALSE );  for( i1=ID_PNL_FST; i1<=ID_PNL_LST; i1++ )    m_dfPnlValue[ i1 ] = roGetPanel( i1 ).dfGetValue( );  SetEvtHandlerEnabled( TRUE );}//*****************************************************************************// Parse a generator command string.//// Argument List://   rosCmd - The generator command to be parsed//// Return Values://   TRUE  - Success//   FALSE - Failurebool  DlgGenCfg::bSetGenCmd( const wxString & rosCmd ){  wxStringTokenizer  ostk1;  wxString  os1, os2;  // Extract the generator command parameter list  ostk1.SetString( rosCmd, wxT(" =\t\r\n") );  if( ostk1.CountTokens( ) < 3 )        return( FALSE );  os1 = ostk1.GetNextToken( ).Upper( );  if( ! os1.StartsWith( wxT(".GEN") ) ) return( FALSE );  // Extract each generator parameter value  while( ostk1.HasMoreTokens( ) )  {    os1 = ostk1.GetNextToken( ).Upper( );    if( ! ostk1.HasMoreTokens( ) ) break;    os2 = ostk1.GetNextToken( );    if(      os1.StartsWith( wxT("AM") ) ) m_oPnlAmp   .bSetValue( os2 );    else if( os1.StartsWith( wxT("OF") ) ) m_oPnlOffset.bSetValue( os2 );    else if( os1.StartsWith( wxT("FR") ) ) m_oPnlFreq  .bSetValue( os2 );    else if( os1.StartsWith( wxT("PH") ) ) m_oPnlPhase .bSetValue( os2 );    else if( os1.StartsWith( wxT("IN") ) ) m_oPnlInitV .bSetValue( os2 );    else if( os1.StartsWith( wxT("MI") ) ) m_oPnlMinV  .bSetValue( os2 );    else if( os1.StartsWith( wxT("MA") ) ) m_oPnlMaxV  .bSetValue( os2 );    else if( os1.StartsWith( wxT("DE") ) ) m_oPnlDelay .bSetValue( os2 );    else if( os1.StartsWith( wxT("RI") ) ) m_oPnlRise  .bSetValue( os2 );    else if( os1.StartsWith( wxT("WI") ) ) m_oPnlWidth .bSetValue( os2 );    else if( os1.StartsWith( wxT("FA") ) ) m_oPnlFall  .bSetValue( os2 );    else if( os1.StartsWith( wxT("PE") ) ) m_oPnlPeriod.bSetValue( os2 );  }  return( TRUE );}//*****************************************************************************// Create the generator command string.//// Return Values://   The generator commandconst wxString & DlgGenCfg::rosGetGenCmd( void ){  m_osGenCmd = wxT(".GENERATOR");  if( roGetPanel( ID_PNL_AMP ).IsEnabled( ) )    m_osGenCmd << wxT(" AMP=")    << roGetPanel( ID_PNL_AMP    ).rosGetValue( );  if( roGetPanel( ID_PNL_OFFSET ).IsEnabled( ) )    m_osGenCmd << wxT(" OFFSET=") << roGetPanel( ID_PNL_OFFSET ).rosGetValue( );  if( roGetPanel( ID_PNL_FREQ ).dfGetValue( ) != 0.0 )  {    if( roGetPanel( ID_PNL_FREQ ).IsEnabled( ) )      m_osGenCmd << wxT(" FREQ=")  << roGetPanel( ID_PNL_FREQ  ).rosGetValue( );    if( roGetPanel( ID_PNL_PHASE ).IsEnabled( ) )      m_osGenCmd << wxT(" PHASE=") << roGetPanel( ID_PNL_PHASE ).rosGetValue( );  }  if( roGetPanel( ID_PNL_MAXV ).dfGetValue( ) != 0.0 )  {    if( roGetPanel( ID_PNL_INITV ).IsEnabled( ) )      m_osGenCmd << wxT(" INIT=")   << roGetPanel( ID_PNL_INITV  ).rosGetValue( );    if( roGetPanel( ID_PNL_MINV ).IsEnabled( ) )      m_osGenCmd << wxT(" MIN=")    << roGetPanel( ID_PNL_MINV   ).rosGetValue( );    if( roGetPanel( ID_PNL_MAXV ).IsEnabled( ) )      m_osGenCmd << wxT(" MAX=")    << roGetPanel( ID_PNL_MAXV   ).rosGetValue( );    if( roGetPanel( ID_PNL_DELAY ).IsEnabled( ) )      m_osGenCmd << wxT(" DELAY=")  << roGetPanel( ID_PNL_DELAY  ).rosGetValue( );    if( roGetPanel( ID_PNL_RISE ).IsEnabled( ) )      m_osGenCmd << wxT(" RISE=")   << roGetPanel( ID_PNL_RISE   ).rosGetValue( );    if( roGetPanel( ID_PNL_WIDTH ).IsEnabled( ) )      m_osGenCmd << wxT(" WIDTH=")  << roGetPanel( ID_PNL_WIDTH  ).rosGetValue( );    if( roGetPanel( ID_PNL_FALL ).IsEnabled( ) )      m_osGenCmd << wxT(" FALL=")   << roGetPanel( ID_PNL_FALL   ).rosGetValue( );    if( roGetPanel( ID_PNL_PERIOD ).IsEnabled( ) )      m_osGenCmd << wxT(" PERIOD=") << roGetPanel( ID_PNL_PERIOD ).rosGetValue( );  }  return( m_osGenCmd );}//*****************************************************************************// Reset all dialog settings to defaults.//// Return Values://   TRUE  - Success//   FALSE - Failurebool  DlgGenCfg::bClear( void ){  bool  bRtn=TRUE;  // Set default spin control values  if( ! m_oPnlAmp   .bClear( ) ) bRtn = FALSE;  if( ! m_oPnlOffset.bClear( ) ) bRtn = FALSE;  if( ! m_oPnlFreq  .bClear( ) ) bRtn = FALSE;  if( ! m_oPnlPhase .bClear( ) ) bRtn = FALSE;  if( ! m_oPnlInitV .bClear( ) ) bRtn = FALSE;  if( ! m_oPnlMinV  .bClear( ) ) bRtn = FALSE;  if( ! m_oPnlMaxV  .bClear( ) ) bRtn = FALSE;  if( ! m_oPnlDelay .bClear( ) ) bRtn = FALSE;  if( ! m_oPnlRise  .bClear( ) ) bRtn = FALSE;  if( ! m_oPnlWidth .bClear( ) ) bRtn = FALSE;  if( ! m_oPnlFall  .bClear( ) ) bRtn = FALSE;  if( ! m_oPnlPeriod.bClear( ) ) bRtn = FALSE;  return( bRtn );}//*****************************************************************************// Enable or disable a value panel.//// Return Values://   TRUE  - Success//   FALSE - Failurebool  DlgGenCfg::bEnablePanel( int iPnlID, bool bState ){  if( iPnlID<ID_PNL_FST || iPnlID>ID_PNL_LST ) return( FALSE );  if( roGetPanel( iPnlID ).Enable( bState ) )  return( FALSE );  return( TRUE );}//*****************************************************************************// Set the value on a panel.//// Argument List://   iPnlID   - Spin control identifier//   fValue   - The value to set the spin control//   rosUnits - The units to display//// Return Values://   TRUE  - Success//   FALSE - Failurebool  DlgGenCfg::bSetPnlValue( int iPnlID, float fValue,                               const wxString & rosUnits ){  // Check for a valid panel identifier  if( iPnlID<ID_PNL_FST || iPnlID>ID_PNL_LST )             return( FALSE );  // Set the panel value  if( ! roGetPanel( iPnlID ).bSetValue( (float) fValue ) ) return( FALSE );  m_dfPnlValue[ iPnlID ] = fValue;  if( ! rosUnits.IsEmpty( ) )  { // Set the units    if( ! roGetPanel( iPnlID ).bSetUnits( rosUnits ) )     return( FALSE );    m_dfPnlValue[ iPnlID ] = roGetPanel( iPnlID ).dfGetValue( );  }  return( TRUE );}//*****************************************************************************////                             Event Handlers////*****************************************************************************// Ok button event handler.//// Argument List://   roEvtCmd - An object holding information about the event (not used)void  DlgGenCfg::OnBtnOk( wxCommandEvent & roEvtCmd ){  GetPnlValues( );  EndModal( wxID_OK );  rosGetGenCmd( );}//*****************************************************************************// Cancel button event handler.//// Argument List://   roEvtCmd - An object holding information about the event (not used)void  DlgGenCfg::OnBtnCancel( wxCommandEvent & roEvtCmd ){  SetPnlValues( );  EndModal( wxID_CANCEL );}//*****************************************************************************

⌨️ 快捷键说明

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