void
SCXferFnDirector::EvaluateTransferFunction()
{
	if (!itsXferFn->EndEditing())
		{
		return;
		}
	else if (itsXferFn->ContainsUIF())
		{
		(JGetUserNotification())->ReportError("Please finish entering the function.");
		itsXferFn->Focus();
		return;
		}

	(GetCircuitDocument())->DataModified();

	itsResult->ClearFunction();

	const SCCircuit* circuit = GetCircuit();
	if (!circuit->IsLinear())
		{
		(JGetUserNotification())->ReportError("The circuit is not linear.");
		return;
		}

	const SCCircuitVarList* varList = GetVarList();

	const JFunction* fn  = itsXferFn->GetFunction();
	const JString textFn = (SCGetSymbolicMath())->Print(*fn);
	JString result;
	JFunction* f;
	if (circuit->Evaluate(textFn, &result) &&
		JParseFunction(result, varList, &f))
		{
		itsResult->SetFunction(varList, f);
		}
}
void
SCFeedbackDirector::EvaluateFeedbackParameters()
{
    if (!itsOutputFn->EndEditing())
    {
        return;
    }
    else if (itsOutputFn->ContainsUIF())
    {
        (JGetUserNotification())->ReportError("Please finish entering the output function.");
        itsOutputFn->Focus();
        return;
    }

    (GetCircuitDocument())->DataModified();

    itsH0->ClearFunction();
    itsHinf->ClearFunction();
    itsT->ClearFunction();
    itsTn->ClearFunction();
    itsScratchFn->ClearFunction();

    const SCCircuit* circuit = GetCircuit();
    if (!circuit->IsLinear())
    {
        (JGetUserNotification())->ReportError("The circuit is not linear.");
        return;
    }

    JIndex indepSourceIndex;
    if (!itsInputSource->GetCompIndex(&indepSourceIndex))
    {
        (JGetUserNotification())->ReportError(
            "There are no independent sources in this circuit.");
        return;
    }

    JIndex depSourceIndex;
    if (!itsDepSource->GetCompIndex(&depSourceIndex))
    {
        (JGetUserNotification())->ReportError(
            "There are no dependent sources in this circuit.");
        return;
    }

    const SCCircuitVarList* varList = GetVarList();

    const JFunction* fn  = itsOutputFn->GetFunction();
    const JString textFn = (SCGetSymbolicMath())->Print(*fn);
    JString H0, Hinf, T, Tn;
    if (!circuit->GetFeedbackParameters(indepSourceIndex, textFn, depSourceIndex,
                                        &H0, &Hinf, &T, &Tn))
    {
        return;
    }

    JFunction* f;
    if (JParseFunction(H0, varList, &f))
    {
        itsH0->SetFunction(varList, f);
    }
    if (JParseFunction(Hinf, varList, &f))
    {
        itsHinf->SetFunction(varList, f);
    }
    if (JParseFunction(T, varList, &f))
    {
        itsT->SetFunction(varList, f);
    }
    if (JParseFunction(Tn, varList, &f))
    {
        itsTn->SetFunction(varList, f);
    }
}