AC analysis plots using linear frequency scale
This commit is contained in:
parent
324d27711a
commit
5fdc32b79a
|
@ -266,8 +266,9 @@ void SIM_PLOT_FRAME::addPlot( const wxString& aName, SIM_PLOT_TYPE aType, const
|
|||
TRACE_DESC descriptor( *m_exporter, aName, aType, aParam );
|
||||
|
||||
bool updated = false;
|
||||
SIM_PLOT_TYPE xAxisType = GetXAxisType( simType );
|
||||
|
||||
if( GetXAxisType( simType ) == SPT_FREQUENCY )
|
||||
if( xAxisType == SPT_LIN_FREQUENCY || xAxisType == SPT_LOG_FREQUENCY )
|
||||
{
|
||||
// Add two plots: magnitude & phase
|
||||
TRACE_DESC mag_desc( *m_exporter, descriptor, descriptor.GetType() | SPT_AC_MAG );
|
||||
|
@ -412,7 +413,8 @@ SIM_PLOT_TYPE SIM_PLOT_FRAME::GetXAxisType( SIM_TYPE aType ) const
|
|||
switch( aType )
|
||||
{
|
||||
case ST_AC:
|
||||
return SPT_FREQUENCY;
|
||||
return SPT_LIN_FREQUENCY;
|
||||
/// @todo SPT_LOG_FREQUENCY
|
||||
|
||||
case ST_DC:
|
||||
return SPT_SWEEP;
|
||||
|
|
|
@ -97,11 +97,25 @@ static wxString formatSI ( double x, const wxString& unit, int decimalDigits, do
|
|||
}
|
||||
|
||||
|
||||
class FREQUENCY_SCALE : public mpScaleXLog
|
||||
class FREQUENCY_LIN_SCALE : public mpScaleX
|
||||
{
|
||||
public:
|
||||
FREQUENCY_SCALE(wxString name, int flags, bool ticks = false, unsigned int type = 0) :
|
||||
mpScaleXLog ( name, flags, ticks ,type ) {};
|
||||
FREQUENCY_LIN_SCALE(wxString name, int flags, bool ticks = false, unsigned int type = 0) :
|
||||
mpScaleX( name, flags, ticks ,type ) {};
|
||||
|
||||
const wxString getLabel( int n )
|
||||
{
|
||||
printf("%.10f\n", m_labeledTicks[n] );
|
||||
return formatSI ( m_labeledTicks[n], wxT("Hz"), 2 );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class FREQUENCY_LOG_SCALE : public mpScaleXLog
|
||||
{
|
||||
public:
|
||||
FREQUENCY_LOG_SCALE(wxString name, int flags, bool ticks = false, unsigned int type = 0) :
|
||||
mpScaleXLog( name, flags, ticks ,type ) {};
|
||||
|
||||
const wxString getLabel( int n )
|
||||
{
|
||||
|
@ -253,7 +267,7 @@ SIM_PLOT_PANEL::SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, wxWindowID id,
|
|||
switch( m_type )
|
||||
{
|
||||
case ST_AC:
|
||||
m_axis_x = new FREQUENCY_SCALE( wxT( "Frequency" ), mpALIGN_BOTTOM );
|
||||
m_axis_x = new FREQUENCY_LIN_SCALE( wxT( "Frequency" ), mpALIGN_BOTTOM );
|
||||
m_axis_y1 = new GAIN_SCALE( wxT( "Gain" ), mpALIGN_LEFT );
|
||||
m_axis_y2 = new PHASE_SCALE( wxT( "Phase" ), mpALIGN_RIGHT );
|
||||
m_axis_y2->SetMasterScale(m_axis_y1);
|
||||
|
@ -385,12 +399,12 @@ bool SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints,
|
|||
if( aFlags & SPT_AC_PHASE )
|
||||
{
|
||||
for(int i = 0; i < aPoints; i++ )
|
||||
tmp[i] = tmp[i] * 180.0 / M_PI;
|
||||
tmp[i] = tmp[i] * 180.0 / M_PI; // convert to degrees
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < aPoints; i++ )
|
||||
tmp[i] = 20 * log( tmp[i] ) / log( 10.0 );
|
||||
tmp[i] = 20 * log( tmp[i] ) / log( 10.0 ); // convert to dB
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ enum SIM_PLOT_TYPE {
|
|||
SPT_AC_MAG = 0x08,
|
||||
|
||||
SPT_TIME = 0x10,
|
||||
SPT_FREQUENCY = 0x20,
|
||||
SPT_LIN_FREQUENCY = 0x20,
|
||||
SPT_LOG_FREQUENCY = 0x20,
|
||||
SPT_SWEEP = 0x40
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue