/--------------------------------------------------------------------------
// Filename:  SmithChart.ogs
// Purpose:   Handle events for the "Smith Chart tools" dialog.
// JCG 02/07/03 QA70-3872 7.0509 FIX_NORMALIZATION_BUG
//--------------------------------------------------------------------------


[OnInit]
	// This section called when dialog is shown for the first time.		
	%A = $(1/layer.y.label.divideby);
	SmithChart!NormFactor$ = %A;
	SmithChart!Rtip$ = %A;
	SmithChart!Redit.v1 = 1/layer.y.label.divideby * 1.2;
	SmithChart!PointDensity.Choice = 2; //Medium by default
	SmithChart!Xedit.v1 = 0;
	SmithChart!CircleColor.Choice = 1;	//Red by default
	%A = XOF(%C);
	if ( layer.coortype == 3 )
	{
		SmithChart!CurDataset$ = R: %A;
		SmithChart!CurDataset2$ = X: %C;
	}
	else
	{
		SmithChart!CurDataset$ = "";
		SmithChart!CurDataset2$ = "";
	}
	
[Update.OnClick]
	run.section(,OnWinActivate);

[OnWinActivate]
	if ( layer.coortype == 3 && run.LoadOC( originlab\SmithChart ) == 0 )
	{
		bSmith = 1;
		SmithChartSetParameters();
	}
	else
		bSmith = 0;
	
	NormFactor.Enable = bSmith;
	ReverseRaxes.Enable = bSmith;
	NormBtn.Enable = bSmith;
	ConvToMagAng.Enable = bSmith;
	DataAsMagAng.Enable = bSmith;
	CircleAddBtn.Enable = bSmith;
	Redit.Enable = bSmith;
	Xedit.Enable = bSmith;
	PointDensity.Enable = bSmith;
	CircleColor.Enable = bSmith;
	CurDataset.Enable = bSmith;
	Update.Enable = bSmith;
	
	del -v bSmith;
	
	%A = XOF(%C);
	if ( layer.coortype == 3 )
	{
		SmithChart!CurDataset$ = R: %A;
		SmithChart!CurDataset2$ = X: %C;
	}
	else
	{
		SmithChart!CurDataset$ = "";
		SmithChart!CurDataset2$ = "";
	}
[NormBtn.OnClick]
	run.LoadOC( originlab\SmithChart );
	SmithChartNomalize( SmithChart!NormFactor$ );

[ReverseRaxes.OnClick]
	run.LoadOC( originlab\SmithChart );
	SmithChartReverse();

[ConvToMagAng.OnClick]
	run.LoadOC( originlab\SmithChart );
	SmithChartConvert( %C, 0 );

[DataAsMagAng.OnClick]
	run.LoadOC( originlab\SmithChart );
	SmithChartConvert( %C, 1 );
	
[CircleAddBtn.OnClick]
	run.LoadOC( originlab\SmithChart );
	SmithChartSWR( %C, SmithChart!Redit.v1, SmithChart!Xedit.v1 );
