20#include <boost/test/unit_test.hpp>
31 view.
center = wxPoint( 400, 300 );
34 view.
pan = wxRealPoint( 0.0, 0.0 );
37 double tol = 1.0 / view.
radius;
39 for(
double re : { -1.0, -0.5, 0.0, 0.3, 1.0 } )
41 for(
double im : { -1.0, -0.25, 0.0, 0.6, 1.0 } )
45 BOOST_CHECK_SMALL( back.x - re, tol );
46 BOOST_CHECK_SMALL( back.y - im, tol );
57 view.
pan = wxRealPoint( 0.4, -0.2 );
63 BOOST_CHECK_SMALL( back.x - 0.45, tol );
64 BOOST_CHECK_SMALL( back.y - -0.15, tol );
75 double baseRadius = 250.0;
78 wxPoint
center( 400, 300 );
79 wxPoint pos( 520, 180 );
84 view.
radius = baseRadius * oldZoom;
85 view.
pan = wxRealPoint( 0.1, 0.3 );
87 wxRealPoint gamma = view.
ToGamma( pos );
91 zoomed.
zoom = newZoom;
92 zoomed.
radius = baseRadius * newZoom;
95 wxRealPoint after = zoomed.
ToGamma( pos );
97 BOOST_CHECK_CLOSE( after.x, gamma.x, 1e-9 );
98 BOOST_CHECK_CLOSE( after.y, gamma.y, 1e-9 );
103 restored.
zoom = oldZoom;
104 restored.
radius = baseRadius * oldZoom;
107 BOOST_CHECK_CLOSE( restored.
pan.x, view.
pan.x, 1e-9 );
108 BOOST_CHECK_CLOSE( restored.
pan.y, view.
pan.y, 1e-9 );
115 view.
center = wxPoint( 400, 300 );
118 view.
pan = wxRealPoint( 0.0, 0.0 );
121 wxPoint farPoint = view.
ToScreen( 1e12, -1e12 );
123 BOOST_CHECK( farPoint.x > view.
center.x );
124 BOOST_CHECK( farPoint.y > view.
center.y );
127 double nan = std::nan(
"" );
128 double inf = std::numeric_limits<double>::infinity();
147 BOOST_CHECK_CLOSE( r, 50.0, 1e-9 );
148 BOOST_CHECK_SMALL( x, 1e-9 );
152 BOOST_CHECK_CLOSE( r, 100.0, 1e-9 );
153 BOOST_CHECK_SMALL( x, 1e-9 );
157 BOOST_CHECK_CLOSE( r, 25.0, 1e-9 );
161 BOOST_CHECK_CLOSE( r, 30.0, 1e-9 );
162 BOOST_CHECK_CLOSE( x, 40.0, 1e-9 );
165 BOOST_CHECK_CLOSE( x, -40.0, 1e-9 );
169 BOOST_CHECK_CLOSE( r, 150.0, 1e-9 );
197 for(
double gm : { 0.05, 0.2, 0.45, 0.7, 0.95 } )
200 double lin = std::pow( 10.0, rl / 20.0 );
202 BOOST_CHECK_CLOSE(
SMITH_MATH::VSWR( gm ), ( lin + 1.0 ) / ( lin - 1.0 ), 1e-6 );
209 long response, drive;
234 std::vector<double> freqs, re, im;
236 for(
int ii = 0; ii <= 100; ii++ )
238 freqs.push_back( 1e9 + ii * 10e6 );
239 re.push_back( 0.5 * std::cos( ii * 0.05 ) );
240 im.push_back( 0.5 * std::sin( ii * 0.05 ) );
250 cursor.SetCoordX( freqs[80] );
251 BOOST_REQUIRE_EQUAL(
cursor.GetCoords().x, freqs[80] );
253 trace.
SetFrequencies( std::vector<double>( freqs.begin(), freqs.begin() + 5 ) );
254 trace.
SetData( std::vector<double>( re.begin(), re.begin() + 5 ),
255 std::vector<double>( im.begin(), im.begin() + 5 ) );
256 cursor.UpdateForNewData();
260 cursor.UpdateForNewData();
270 std::vector<double> freqs, re, im;
272 for(
int ii = 0; ii <= 100; ii++ )
274 freqs.push_back( 1e9 + ii * 10e6 );
275 re.push_back( 0.5 * std::cos( ii * 0.05 ) );
276 im.push_back( 0.5 * std::sin( ii * 0.05 ) );
283 cursor.SetCoordX( freqs[80] );
287 cursor.UpdateForNewData();
Trace hidden while the tab is in Smith mode, kept so leaving the mode restores it.
Cursor that snaps along a Smith chart locus, keyed by frequency.
void SetFrequencies(const std::vector< double > &aFreqs)
void SetData(const std::vector< double > &aX, const std::vector< double > &aY) override
Assigns new data set for the trace.
void SetCursor(int aCursorId, CURSOR *aCursor)
double SeriesCapacitance(double aReactance, double aFreq)
Pan that keeps the gamma point under aPos fixed when the view zooms to aNewZoom.
double SeriesInductance(double aReactance, double aFreq)
double VSWR(double aGammaMag)
wxRealPoint ZoomAboutPoint(const SMITH_VIEW &aView, const wxPoint &aPos, double aNewZoom)
S-parameter vectors are named S_<responsePort>_<drivePort>.
bool ParseSParamPorts(const wxString &aVectorName, long *aResponsePort, long *aDrivePort)
bool GammaToImpedance(double aRe, double aIm, double aZ0, double &aResistance, double &aReactance)
< Impedance of a reflection coefficient, z = z0 ( 1 + gamma ) / ( 1 - gamma ), false at the gamma = 1...
double ReturnLoss(double aGammaMag)
Series equivalent element of a reactance at one frequency, henries for aReactance > 0,...
< Smith chart placement plus pan/zoom, maps a gamma point to a screen pixel and back.
wxRealPoint ToGamma(const wxPoint &aPt) const
wxPoint ToScreen(double aRe, double aIm) const
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(GammaScreenRoundTrip)
BOOST_CHECK_EQUAL(result, "25.4")