9.2. Adding a new fit type

The preceding section should make the steps that must be taken to add a new fit type clear:

  1. You must write a new fitting class. This class must be derived from CFit and must implement all of the pure virtual methods of that class.

    This fitting class actually performs fits.

  2. You must write a fit creator. This is a class derived from CFitCreator. Its operator() must be able to return a pointer to an object of the fitting class you created in the previous step. Each invocation must produce a new, unique object (usually done with new).

  3. You must register an instance of your fit creator (written in the previous step) with the CFitFactory.

    This registration is done by adding code to create and register an instance in MySpecTclApp::AddCommands. Use this method because by the time this method is invoked you know the entire fit framework within SpecTcl has been created.

  4. You must make necessary changes to your Makefile to compile the classes you wrote above and link them into SpecTcl. This is normally a matter of adding files to the OBJECTS definition but may also require adding options to USERLDFLAGS to incorporate fitting libraries into SpecTcl. Note that the SpecTcl built in fitters use the GNU Scientific Library (GSL) which includes a set of minimization functions. SpecTcl uses the Levenberg-Marquardt minimizer to implement its fits.