/*****************************************************************************
 ******************************************************************************
 **
 ** FILE:
 **     dervish_template.c
 **
 ** ABSTRACT:
 **     This file contains a template for users writing TCL main programs which
 **     utilize the FSAOimage interface features of Dervish.
 **
 **     The routines invoked by this main program were written to encapsulate
 **     the lower layers of the Dervish, in order to minimize chances of the
 **     template needing changes in the future.
 **
 ** ENVIRONMENT:
 **     ANSI C.
 ******************************************************************************
 ******************************************************************************
 */

#include <stdlib.h>
#include <stdio.h>
#include <dervish.h>

/* Prototypes for SDB interface */
void   sdbInit(Tcl_Interp *interp);

/* Prototypes for class library declarations.
   Here is where you declare the functions which load the schema library.
   Listed below are some sample SDSS libraries, which you may uncomment
   to get access to.  The first library listed (not commented) is the library
   for the example.  If building an executable, you should comment this out. */
void   basicSchDeclareGenericClasses(Tcl_Interp *interp);
void   photoSchDeclareGenericClasses(Tcl_Interp *interp);
void   photoSchTclDeclare(Tcl_Interp *interp);
void   tsTclDeclare(Tcl_Interp *interp);

/* Other prototypes */
extern "C" {
  void atVerbsDeclare(Tcl_Interp *interp);	/* astrotools */
  //void atTclSurveyGeometryDeclare(Tcl_Interp *interp);
  int Blt_Init(Tcl_Interp *interp);
}

#define L_SHPROMPT    "ts> "   /* Command line prompt for dervish */

int main(int argc, char *argv[])
{
   CMD_HANDLE sh_handle;
   Tcl_Interp    *interp;
  
   if (shMainTcl_Init(&sh_handle, &argc, argv, L_SHPROMPT) != SH_SUCCESS)
       return 1;

   interp = sh_handle.interp;

   /*
    * Declare required TCL commands
    */
   ftclCreateCommands(interp);          /* Fermi enhancements to TCL   */
   ftclCreateHelp (interp);             /* Define help command         */
   ftclMsgDefine (interp);              /* Define help for tcl verbs   */
 
   /* --- PLACE YOUR FAVORITE TCL DECLARATIONS HERE --- */
 
   shTclPgplotDeclare(interp);         /* Pgplot Tcl commands */
 
   /* --- PLACE YOUR FAVORITE INITIALIZATIONS HERE --- */
   ftclParseInit(interp);               /* Ftcl command parsing */
   /* Prototypes for class library declarations.
      Here is where you call the functions which load the schema libraries.
      Listed below are some sample SDSS libraries, which you may uncomment
      to get access to.  The first library listed (not commented) is the
      library for the example.  If building an executable, you should comment
      this out. */
   /*
   SchemaLoadFromMtSch();
   extern GenericClass* arMTCalibDeclare();
   ::genericClasses.add(arMTCalibDeclare());
   extern GenericClass* ooHandle_arMTCalib_Declare();
   ::genericClasses.add(ooHandle_arMTCalib_Declare());
   extern GenericClass* arMTCalibPatchDeclare();
   ::genericClasses.add(arMTCalibPatchDeclare());
   extern GenericClass* ooHandle_arMTCalibPatch_Declare();
   ::genericClasses.add(ooHandle_arMTCalibPatch_Declare());
   */ 
   /*
    * NOTE: shMainTcl_Declare is a comprehensive declaration routine for
    * Dervish.  Included are TCL command declarations for region, peek, and
    * FSAOimage.  If all commands are not desired, one can customize by
    * replacing the call to this routine with individual calls to only the
    * desired TCL command declaration routines. It runs the initialization
    * scripts, so it must go after all of the initialization routines have
    * been called.
    */
   shMainTcl_Declare(&sh_handle);       /* Required Dervish TCL commands */
   Blt_Init(interp);
   //atTclSurveyGeometryDeclare(interp);
   atVerbsDeclare (interp);	/* astrotools */
   sdbInit(interp);
   basicSchDeclareGenericClasses(interp);
   photoSchDeclareGenericClasses(interp);
   photoSchTclDeclare(interp);
   tsTclDeclare(interp);

   /*
    *             DO NOT PUT ANYTHING BELOW THIS LINE.
    *
    * We will now enter the main loop of Tk. There is no successfull return
    * from this loop. Anything added below this line will never be reached,
    * NEVER!!
    */
   shTk_MainLoop(&sh_handle);

   return 0;
}
