pnlanabase.cpp
来自「gspiceui电子CAD仿真程序.用于电路参数模拟仿真」· C++ 代码 · 共 423 行
CPP
423 行
//*****************************************************************************// PnlAnaBase.cpp *// ---------------- *// Started : 26/04/2004 *// Last Update : 05/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 "PnlAnaBase.hpp"//*****************************************************************************// Constructor.//// Argument List:// poWin - A pointer to the parent windowPnlAnaBase::PnlAnaBase( wxWindow * poWin ) : wxPanel( poWin ){ m_eType = Simulation::eANA_NONE; CreateBase( ); bClear( );}//*****************************************************************************// Destructor.PnlAnaBase::~PnlAnaBase( ){}//*****************************************************************************// Create the basic display objects.void PnlAnaBase::CreateBase( void ){ if( bIsCreatedBase( ) ) return; // Create and add sweep parameter labels m_oSbxSwpPars.Create( this, ID_UNUSED, wxT("Sweep Parameters"), wxPoint( 6, 5 ), wxSize( 300, 120 ) ); m_oPnlStart.bCreate( this, ID_PNL_START, 110, wxPoint( 18, 28 ) ); m_oPnlStop .bCreate( this, ID_PNL_STOP, 110, wxPoint( 18, 58 ) ); m_oPnlStep .bCreate( this, ID_PNL_STEP, 110, wxPoint( 18, 88 ) ); m_oPnlStart.bSetName( wxT("Start Value") ); m_oPnlStop .bSetName( wxT("Stop Value") ); m_oPnlStep .bSetName( wxT("Step Increment") ); // Create and add simulation parameter check boxes m_oSbxCalcPars.Create( this, ID_UNUSED, wxT("Parameters"), wxPoint( 313, 5 ), wxSize( 100, 122 ) ); m_oCbxVoltage .Create( this, ID_CBX_VOLT, wxT("Voltage"), wxPoint( 319, 25 ) ); m_oCbxCurrent .Create( this, ID_CBX_CURR, wxT("Current"), wxPoint( 319, 50 ) ); m_oCbxPower .Create( this, ID_CBX_PWR, wxT("Power"), wxPoint( 319, 75 ) ); m_oCbxResist .Create( this, ID_CBX_RES, wxT("Resistance"), wxPoint( 319,100 ) );}//*****************************************************************************// Create the source component display objects.void PnlAnaBase::CreateSrc( void ){ if( bIsCreatedSrc( ) ) return; // Create and add input source m_oSbxSrc .Create ( this, ID_UNUSED, wxT("Source"), wxPoint( 6, 175 ), wxSize( 300, 55 ) ); m_oChoSrcCpnt.Create ( this, ID_CHO_SRCCPNT, wxPoint( 18, 195 ), wxSize( 110, 27 ) ); m_oPnlSrcLvl .bCreate( this, ID_PNL_SRCLVL, -1, wxPoint( 133, 193 ) );}//*****************************************************************************// Create the simulation parameter complex part display objects.void PnlAnaBase::CreateCpxPrt( void ){ if( bIsCreatedCpxPrt( ) ) return; // Create and add simulation parameter complex part check boxes m_oSbxCpxPrt.Create( this, ID_UNUSED, wxT("Complex Parts"), wxPoint( 420, 5 ), wxSize( 105, 146 ) ); m_oCbxMag .Create( this, ID_CBX_MAG, wxT("Magnitude"), wxPoint( 426, 24 ) ); m_oCbxPhase .Create( this, ID_CBX_PHASE, wxT("Phase"), wxPoint( 426, 49 ) ); m_oCbxReal .Create( this, ID_CBX_REAL, wxT("Real Part"), wxPoint( 426, 74 ) ); m_oCbxImag .Create( this, ID_CBX_IMAG, wxT("Imag. Part"), wxPoint( 426, 99 ) ); m_oCbxMagDb .Create( this, ID_CBX_MAGDB, wxT("Mag. in dBV"), wxPoint( 426,124 ) );}//*****************************************************************************// Create the analysis temperature display objects.void PnlAnaBase::CreateTemp( void ){ if( bIsCreatedTemp( ) ) return; // Create and add analysis temperature m_oSbxTemp. Create( this, ID_UNUSED, wxT("Temperature"), wxPoint( 313, 175 ), wxSize( 185, 55 ) ); m_oPnlTemp.bCreate( this, ID_PNL_TEMP, -1, wxPoint( 325, 193 ) ); m_oPnlTemp.bSetUType( ChoUnits::eUNTS_TEMP );}//*****************************************************************************// Set the source component values.//// Argument List:// roSim - The Simulation objectvoid PnlAnaBase::SetSrcCpnt( Simulation & roSim ){ wxString os1; if( ! bIsCreatedSrc( ) ) return; // Set the source component values if( ! roSim.rosGetSrcCpnt( ).IsEmpty( ) ) { // Extract and set the source component label os1 = roSim.rosGetSrcCpnt( ).BeforeFirst( wxT(' ') ); m_oChoSrcCpnt.SetStringSelection( os1 ); if( m_oPnlSrcLvl.GetParent( ) != NULL ) { // Extract and set the source level SetSrcUType( ); os1 = roSim.rosGetSrcCpnt( ).AfterLast( wxT(' ') ); m_oPnlSrcLvl.bSetValue( os1 ); } } else { // Set the default source component label m_oChoSrcCpnt.SetStringSelection( wxT("None") ); if( m_oPnlSrcLvl.GetParent( ) != NULL ) { // Set the default source level m_oPnlSrcLvl.bSetValue( (float) 0.0 ); m_oPnlSrcLvl.bSetUType( ChoUnits::eUNTS_NONE ); } }}//*****************************************************************************// Set the source units type based on the type of the source component.void PnlAnaBase::SetSrcUType( void ){ if( m_oPnlSrcLvl.GetParent( ) == NULL ) return; switch( wxToupper( m_oChoSrcCpnt.GetStringSelection( ).GetChar( 0 ) ) ) { case wxT('C'): // Units of capacitance m_oPnlSrcLvl.bSetUType( ChoUnits::eUNTS_CAP ); break; case wxT('L'): // Units of inductance m_oPnlSrcLvl.bSetUType( ChoUnits::eUNTS_IND ); break; case wxT('R'): // Units of resistance m_oPnlSrcLvl.bSetUType( ChoUnits::eUNTS_RES ); break; case wxT('I'): // Units of current m_oPnlSrcLvl.bSetUType( ChoUnits::eUNTS_CURR ); break; case wxT('V'): // Units of voltage m_oPnlSrcLvl.bSetUType( ChoUnits::eUNTS_VOLT ); break; default: // No units m_oPnlSrcLvl.bSetUType( ChoUnits::eUNTS_NONE ); break; }}//*****************************************************************************// Select the analysis to be performed.//// Arguments:// eAna - The analysis type//// Return Values:// TRUE - Success// FALSE - Failurebool PnlAnaBase::bSetType( Simulation::eAnaType eType ){ if( eType<Simulation::eANA_FST || eType>Simulation::eANA_LST ) return( FALSE ); m_eType = eType; return( TRUE );}//*****************************************************************************// Clear the object attributes.//// Return Values:// TRUE - Success// FALSE - Failurebool PnlAnaBase::bClear( void ){ bool bRtn=TRUE; // Set sweep default values if( ! m_oPnlStart.bClear( ) ) bRtn = FALSE; if( ! m_oPnlStop .bClear( ) ) bRtn = FALSE; if( ! m_oPnlStep .bClear( ) ) bRtn = FALSE; // Set input source default values if( bIsCreatedSrc( ) && m_oSbxSrc.IsShown( ) ) { m_oChoSrcCpnt.Clear( ); m_oChoSrcCpnt.Append( wxT("None") ); m_oChoSrcCpnt.SetSelection( 0 ); if( m_oPnlSrcLvl.GetParent( ) != NULL ) { m_oPnlSrcLvl.bSetValue( (float) 0.0 ); m_oPnlSrcLvl.bSetUType( ChoUnits::eUNTS_NONE ); } } // Set parameters check box default values m_oCbxVoltage.SetValue( TRUE ); m_oCbxCurrent.SetValue( FALSE ); m_oCbxPower .SetValue( FALSE ); m_oCbxResist .SetValue( FALSE ); // Set the complex part defaults values if( bIsCreatedCpxPrt( ) && m_oSbxCpxPrt.IsShown( ) ) { m_oCbxMag .SetValue( TRUE ); m_oCbxPhase.SetValue( FALSE ); m_oCbxReal .SetValue( FALSE ); m_oCbxImag .SetValue( FALSE ); m_oCbxMagDb.SetValue( TRUE ); } // Set the analysis temperature default value if( bIsCreatedTemp( ) && m_oSbxTemp.IsShown( ) ) if( ! m_oPnlTemp.bClear( ) ) bRtn = FALSE; m_osError.Empty( ); // Clear the error string return( bRtn );}//*****************************************************************************// Load information from a Simulation object.//// Argument List:// roSim - The Simulation object//// Return Values:// TRUE - Success// FALSE - Failurebool PnlAnaBase::bLoad( Simulation & roSim ){ bool bRtn=TRUE; // Set the sweep values if( ! m_oPnlStart.bSetValue( roSim.fGetSwpStart( ) ) ) bRtn = FALSE; if( ! m_oPnlStop .bSetValue( roSim.fGetSwpStop( ) ) ) bRtn = FALSE; if( ! m_oPnlStep .bSetValue( roSim.fGetSwpStep( ) ) ) bRtn = FALSE; if( m_oPnlStart.dfGetValue( ) == 0.0 ) m_oPnlStart.bSetUnits( m_oPnlStop.rosGetUnits( ) ); // Set the source component SetSrcCpnt( roSim ); // Set the parameters to derive m_oCbxVoltage.SetValue( roSim.bGetOutPar( Simulation::ePAR_VLT ) ); m_oCbxCurrent.SetValue( roSim.bGetOutPar( Simulation::ePAR_CUR ) ); m_oCbxPower .SetValue( roSim.bGetOutPar( Simulation::ePAR_PWR ) ); m_oCbxResist .SetValue( roSim.bGetOutPar( Simulation::ePAR_RES ) ); // Set the complex parts to derive if( bIsCreatedCpxPrt( ) ) { m_oCbxMag .SetValue( roSim.bGetOutCpx( Simulation::eCPX_MAG ) ); m_oCbxPhase.SetValue( roSim.bGetOutCpx( Simulation::eCPX_PHASE ) ); m_oCbxReal .SetValue( roSim.bGetOutCpx( Simulation::eCPX_REAL ) ); m_oCbxImag .SetValue( roSim.bGetOutCpx( Simulation::eCPX_IMAG ) ); m_oCbxMagDb.SetValue( roSim.bGetOutCpx( Simulation::eCPX_MAGDB ) ); } // Set the analysis temperature if( bIsCreatedTemp( ) ) if( ! m_oPnlTemp.bSetValue( roSim.fGetTempC( ) ) ) bRtn = FALSE; return( bRtn );}//*****************************************************************************// Save information to a Simulation object.//// Argument List:// roSim - The simulation object//// Return Values:// TRUE - Success// FALSE - Failurebool PnlAnaBase::bSave( Simulation & roSim ){ wxStringTokenizer ostk1; wxString os1; float f1; size_t szt1; bool bRtn; m_osError.Empty( ); roSim.ClrSimCmds( ); // Clear simulation commands attribute roSim.ClrSrcCpnt( ); // Clear source component attribute // Set the simulation type if( ! roSim.bSetAnaType( (Simulation::eAnaType) m_eType ) ) SetError( wxT("Invalid simulation type specifier.") ); // Set the sweep parameters f1 = (float) m_oPnlStart.dfGetValue( ); if( ! roSim.bSetSwpStart( f1 ) ) SetError( wxT("Invalid sweep start value.") ); f1 = (float) m_oPnlStop.dfGetValue( ); if( ! roSim.bSetSwpStop( f1 ) ) SetError( wxT("Invalid sweep stop value.") ); f1 = (float) m_oPnlStep.dfGetValue( ); if( ! roSim.bSetSwpStep( f1 ) ) SetError( wxT("Invalid sweep step value.") ); // Set the component to be used as the sweep source if( bIsCreatedSrc( ) && m_oSbxSrc.IsShown( ) ) { if( m_oChoSrcCpnt.GetSelection( ) > 0 ) { // Find the component in the net list for( szt1=0; szt1<roSim.roasGetCpnts( ).GetCount( ); szt1++ ) { os1 = roSim.roasGetCpnts( ).Item( szt1 ); if( os1.BeforeFirst( wxT(' ') ) == m_oChoSrcCpnt.GetStringSelection( ) ) break; } // Create the new component definition line ostk1.SetString( os1 ); os1.Empty( ); for( szt1=0; szt1<3; szt1++ ) os1 << ostk1.GetNextToken( ) << wxT(' '); os1 << m_oPnlSrcLvl.rosGetValue( ); } else { if( eGetType( ) != Simulation::eANA_OP ) { os1.Empty( ); SetError( wxT("Source component hasn't been selected.") ); } } roSim.bSetSrcCpnt( os1 ); } // Set the parameters to be calculated for( szt1=Simulation::ePAR_FST; szt1<=Simulation::ePAR_LST; szt1++ ) roSim.bSetOutPar( (Simulation::eParType) szt1, FALSE ); bRtn = FALSE; if( m_oCbxVoltage.GetValue( ) ) { roSim.bSetOutPar( Simulation::ePAR_VLT, TRUE ); bRtn = TRUE; } if( m_oCbxCurrent.GetValue( ) ) { roSim.bSetOutPar( Simulation::ePAR_CUR, TRUE ); bRtn = TRUE; } if( m_oCbxPower .GetValue( ) ) { roSim.bSetOutPar( Simulation::ePAR_PWR, TRUE ); bRtn = TRUE; } if( m_oCbxResist .GetValue( ) ) { roSim.bSetOutPar( Simulation::ePAR_RES, TRUE ); bRtn = TRUE; } if( ! bRtn ) SetError( wxT("No parameters have been selected.") ); // Set the complex parts of the parameters to derive if( bIsCreatedCpxPrt( ) && m_oSbxCpxPrt.IsShown( ) ) { for( szt1=Simulation::eCPX_FST; szt1<=Simulation::eCPX_LST; szt1++ ) roSim.bSetOutCpx( (Simulation::eCpxType) szt1, FALSE ); bRtn = FALSE; if( m_oCbxMag.GetValue( ) ) { roSim.bSetOutCpx( Simulation::eCPX_MAG, TRUE ); bRtn = TRUE; } if( m_oCbxPhase.GetValue( ) ) { roSim.bSetOutCpx( Simulation::eCPX_PHASE, TRUE ); bRtn = TRUE; } if( m_oCbxReal.GetValue( ) ) { roSim.bSetOutCpx( Simulation::eCPX_REAL, TRUE ); bRtn = TRUE; } if( m_oCbxImag.GetValue( ) ) { roSim.bSetOutCpx( Simulation::eCPX_IMAG, TRUE ); bRtn = TRUE; } if( ! bRtn ) SetError( wxT("No complex parts have been selected.") ); if( m_oCbxMagDb.GetValue( ) ) roSim.bSetOutCpx( Simulation::eCPX_MAGDB, TRUE ); } // Set the analysis temperature if( bIsCreatedTemp( ) && m_oSbxTemp.IsShown( ) ) { f1 = (float) m_oPnlTemp.dfGetValue( ); if( ! roSim.bSetTempC( f1 ) ) SetError( wxT("Invalid analysis temperature value.") ); } return( bIsOk( ) );}//*****************************************************************************
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?