/*
	Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/


/*--------------------------------------------------------------------*\
Pro/TOOLKIT includes
\*--------------------------------------------------------------------*/
#include <ProToolkit.h>
#include "ProObjects.h"
#include "ProMdl.h"
#include "ProMenu.h"
#include "ProMenuBar.h"
#include "ProMessage.h"
#include "ProUtil.h"
#include "ProCore.h"

/*--------------------------------------------------------------------*\
Pro/DEVELOP includes
\*--------------------------------------------------------------------*/

/*--------------------------------------------------------------------*\
C System includes
\*--------------------------------------------------------------------*/

/*--------------------------------------------------------------------*\
Application includes
\*--------------------------------------------------------------------*/
#include "TestError.h"
#include "UtilMessage.h"
#include "TestSelect.h"
#include "TestParams.h"
#include "TestExtobj.h"
#include "TestDbms.h"
#include "TestNotify.h"
#include "TestSimpRep.h"
#include "TestSetup.h"
#include "TestFeat.h"
#include "TestSect.h"
#include "TestMisc.h"
#include "TestGenedata.h"
#include "TestMenu.h"
#include "UtilString.h"
#include "TestAnalysis.h"
#include "PTApplsUnicodeUtils.h"
#include "ProTKRunTime.h"
#include "UtilMenu.h"

/*--------------------------------------------------------------------*\
Application macros
\*--------------------------------------------------------------------*/

/*--------------------------------------------------------------------*\
Application data types
\*--------------------------------------------------------------------*/

/*--------------------------------------------------------------------*\
Application global/external data
\*--------------------------------------------------------------------*/

/*====================================================================*\
    FUNCTION :	TestAccessDefault()
    PURPOSE  :   enable access to the -Main button	
\*====================================================================*/
static uiCmdAccessState TestAccessDefault(uiCmdAccessMode access_mode)
{
  return (ACCESS_AVAILABLE);
}
/*====================================================================*\
    FUNCTION :  TestNoAccess()
    PURPOSE  :   disable access any button
\*====================================================================*/
static uiCmdAccessState TestNoAccess(uiCmdAccessMode access_mode)
{
  return (ACCESS_UNAVAILABLE);
}

/*====================================================================*\
    FUNCTION :	TestDrawingAccess()
    PURPOSE  :   enable access to the Drawing button	
\*====================================================================*/
static uiCmdAccessState TestDrawingAccess(uiCmdAccessMode access_mode)
{
  ProMdl mdl;
  ProError status;
  ProMdlType mdltype;

  status = ProMdlCurrentGet(&mdl);
  if (status == PRO_TK_NO_ERROR)
    {
      ProMdlTypeGet(mdl, &mdltype); 
      if (mdltype == PRO_MDL_DRAWING) 
	return (ACCESS_AVAILABLE);
      else 
	return (ACCESS_UNAVAILABLE);
    }
  return (ACCESS_UNAVAILABLE);
}

/*====================================================================*\
    FUNCTION :	TestDiagramAccess()
    PURPOSE  :   enable access to the Diagram button	
\*====================================================================*/
static uiCmdAccessState TestDiagramAccess(uiCmdAccessMode access_mode)
{
  ProMdl mdl;
  ProError status;
  ProMdlType mdltype;

  status = ProMdlCurrentGet(&mdl);

  if (status == PRO_TK_NO_ERROR)
    {
      status = ProMdlTypeGet(mdl, &mdltype); 
      if (status == PRO_TK_NO_ERROR && mdltype == PRO_MDL_DIAGRAM) 
	return (ACCESS_AVAILABLE);
      else 
	return (ACCESS_UNAVAILABLE);
    }
  return (ACCESS_UNAVAILABLE);
}

/*====================================================================*\
    FUNCTION :	TestReportAccess()
    PURPOSE  :   enable access to the Report button	
\*====================================================================*/
static uiCmdAccessState TestReportAccess(uiCmdAccessMode access_mode)
{
  ProMdl mdl;
  ProError status;
  ProMdlType mdltype;

  status = ProMdlCurrentGet(&mdl);

  if (status == PRO_TK_NO_ERROR)
    {
      status = ProMdlTypeGet(mdl, &mdltype); 
      if (status == PRO_TK_NO_ERROR && mdltype == PRO_MDL_REPORT) 
	return (ACCESS_AVAILABLE);
      else 
	return (ACCESS_UNAVAILABLE);
    }
  return (ACCESS_UNAVAILABLE);
}

/*====================================================================*\
    FUNCTION :	TestLayoutAccess()
    PURPOSE  :   enable access to the Layout button	
\*====================================================================*/
static uiCmdAccessState TestLayoutAccess(uiCmdAccessMode access_mode)
{
  ProMdl mdl;
  ProError status;
  ProMdlType mdltype;

  status = ProMdlCurrentGet(&mdl);
  if (status == PRO_TK_NO_ERROR)
    {
      ProMdlTypeGet(mdl, &mdltype); 
      if (mdltype == PRO_MDL_LAYOUT) 
	return (ACCESS_AVAILABLE);
      else 
	return (ACCESS_UNAVAILABLE);
    }
  return (ACCESS_UNAVAILABLE);
}
/*====================================================================*\
    FUNCTION :  TestPartAccess()
    PURPOSE  :   enable access to the Part button
\*====================================================================*/
static uiCmdAccessState TestPartAccess(uiCmdAccessMode access_mode)
{
  ProMdl mdl;
  ProError status;
  ProMdlType mdltype;

  status = ProMdlCurrentGet(&mdl);
  if (status == PRO_TK_NO_ERROR)
    {
      status = ProMdlTypeGet(mdl, &mdltype);
      if (status == PRO_TK_NO_ERROR && mdltype == PRO_MDL_PART)
        return (ACCESS_AVAILABLE);
    }
  return (ACCESS_UNAVAILABLE);
}
/*====================================================================*\
    FUNCTION :  TestAsmAccess()
    PURPOSE  :   enable access to the Asm button
\*====================================================================*/
static uiCmdAccessState TestAsmAccess(uiCmdAccessMode access_mode)
{
  ProMdl mdl;
  ProError status;
  ProMdlType mdltype;

  status = ProMdlCurrentGet(&mdl);
  if (status == PRO_TK_NO_ERROR)
    {
      status = ProMdlTypeGet(mdl, &mdltype);
      if (status == PRO_TK_NO_ERROR && mdltype == PRO_MDL_ASSEMBLY)
        return (ACCESS_AVAILABLE);
    }
  return (ACCESS_UNAVAILABLE);
}
/*====================================================================*\
    FUNCTION :  TestAsmAccess()
    PURPOSE  :   enable access to the Asm button
\*====================================================================*/
static uiCmdAccessState TestMfgAccess(uiCmdAccessMode access_mode)
{
  ProMdl mdl;
  ProError status;
  ProMdlType mdltype;

  status = ProMdlCurrentGet(&mdl);
  if (status == PRO_TK_NO_ERROR)
    {
      status = ProMdlTypeGet(mdl, &mdltype);
      if (status == PRO_TK_NO_ERROR && mdltype == PRO_MDL_MFG)
        return (ACCESS_AVAILABLE);
    }
  return (ACCESS_UNAVAILABLE);
}
/*====================================================================*\
    FUNCTION :  TestAsmProcessPlanAccess()
    PURPOSE  :   enable access to the Asm Process button
\*====================================================================*/
static uiCmdAccessState TestAsmProcessPlanAccess(uiCmdAccessMode access_mode)
{
  ProMdl mdl;
  ProError status;
  ProMdlType mdltype;
  ProMdlsubtype subtype;

  status = ProMdlCurrentGet(&mdl);
  if (status == PRO_TK_NO_ERROR)
    {
      status = ProMdlTypeGet(mdl, &mdltype);
      if (mdltype == PRO_MDL_ASSEMBLY && status == PRO_TK_NO_ERROR)
      {
        status = ProMdlSubtypeGet(mdl,&subtype);
        if (subtype == PROMDLSTYPE_ASM_PROCPLAN && status == PRO_TK_NO_ERROR)
            return (ACCESS_AVAILABLE);
      }
    }
  return (ACCESS_UNAVAILABLE);
}
/*====================================================================*\
    FUNCTION :  TestAsmMoldLayoutAccess()
    PURPOSE  :   enable access to the Asm Mold Layout  button
\*====================================================================*/
static uiCmdAccessState TestAsmMoldLayoutAccess(uiCmdAccessMode access_mode)
{
  ProMdl mdl;
  ProError status;
  ProMdlType mdltype;
  ProMdlsubtype subtype;

  status = ProMdlCurrentGet(&mdl);
  if (status == PRO_TK_NO_ERROR)
    {
      status = ProMdlTypeGet(mdl, &mdltype);
      if (mdltype == PRO_MDL_ASSEMBLY && status == PRO_TK_NO_ERROR)
      {
        status = ProMdlSubtypeGet(mdl,&subtype);
        if (subtype == PROMDLSTYPE_ASM_CLASS_CAV && status == PRO_TK_NO_ERROR)
            return (ACCESS_AVAILABLE);
      }
    }
  return (ACCESS_UNAVAILABLE);
}
/*====================================================================*\
    FUNCTION :  TestMfgMoldCavityAccess()
    PURPOSE  :   enable access to the Asm Mold Layout  button
\*====================================================================*/
static uiCmdAccessState TestMfgMoldCavityAccess(uiCmdAccessMode access_mode)
{
  ProMdl mdl;
  ProError status;
  ProMdlType mdltype;
  ProMdlsubtype subtype;

  status = ProMdlCurrentGet(&mdl);
  if (status == PRO_TK_NO_ERROR)
    {
      status = ProMdlTypeGet(mdl, &mdltype);
      if (mdltype == PRO_MDL_MFG && status == PRO_TK_NO_ERROR)
      {
        status = ProMdlSubtypeGet(mdl,&subtype);
        if (subtype == PROMDLSTYPE_MFG_MOLD && status == PRO_TK_NO_ERROR)
            return (ACCESS_AVAILABLE);
      }
    }
  return (ACCESS_UNAVAILABLE);
}
/*====================================================================*\
    FUNCTION :	main()
    PURPOSE  :	To test ProToolkitMain
\*====================================================================*/
int main(int argc, char**argv)
{
    ProTKFprintf(stderr, "Welcome to PRO/TOOLKIT -the \"pt_example\" program\n");
    ProToolkitMain(argc, argv);
    return (0);
}
/*====================================================================*\
    FUNCTION :	user_initialize()
    PURPOSE  :	Pro/DEVELOP standard initialize - define menus.
\*====================================================================*/
int user_initialize(
    int argc,			/** Number of arguments			**/
    char *argv[],		/** Pro/E arguments			**/
    char *proe_vsn,		/** Pro/E version			**/
    char *build,		/** Pro/E build				**/
    wchar_t err_buff[])		/** Error buffer			**/
{
    ProError status;
    ProPath w_path;
    int menu_id;
    int size, a;
    char str[PRO_PATH_SIZE], path[PRO_PATH_SIZE];
    ProComment w_com;
    int ProTestMain();
    int ProTestPart();
    int ProTestAsm();
    int ProTestDraw();
    int ProTestDiagram();
    int ProTestLayout();
    int ProTestMfg();
    int ProTestMfgNew();
    int ProTestMoldLayoutMenu();
    int ProTestProcstep();
    int ProTestWeldMenu();
    int ProTestReport();    
    ProError ProTestFemMeshMenu();
    ProError ProTestCavityLayoutMenu();
    int ProTestMoldProd();
    
    ProFileName  message_file;
    uiCmdCmdId   cmd_id, cmd_id_draw, cmd_id_diagram, cmd_id_report, cmd_id_layout;
    
    /*--------------------------------------------------------------------*\
    Check the size of wchar_t
    \*--------------------------------------------------------------------*/
    status = ProWcharSizeVerify( sizeof(wchar_t), &size );
    TEST_CALL_REPORT( "ProWcharSizeVerify()", "user_initialize()", 
			status, status !=PRO_TK_NO_ERROR );
    if( status !=PRO_TK_NO_ERROR )
    {
        ProTKSprintf(str,"ERROR wchar_t has size %d - should be %d",
                sizeof(wchar_t),  size );
        ProUtilMsgPrint("gen", "TEST %0s", str);
        ProTKPrintf("%s\n", str);
        return(-1);
    }

/*--------------------------------------------------------------------*\
    Check that the Pro/E version and build are OK
\*--------------------------------------------------------------------*/
    if(proe_vsn == NULL)
    {
	ProUtilstrcpy(str,"Pro/E version set to NULL");
	ProUtilMsgPrint("gen", "TEST %0s", str);
	ProTKPrintf("%s\n",str);
	ProStringToWstring(err_buff, str);
	return(-1);
    }

    if(build == NULL)
    {
	ProUtilstrcpy(str, "Pro/E build set to NULL");
	ProUtilMsgPrint("gen", "TEST %0s", str);
	ProTKPrintf("%s\n",str);
	ProStringToWstring(err_buff, str);
	return(-1);
    }
    if(sscanf(build, "%d", &a) < 1)
    {
	ProTKSprintf(str, "Pro/E build invalid : %s", build);
	ProUtilMsgPrint("gen", "TEST %0s", str);
	ProTKPrintf("%s\n",str);
	ProStringToWstring(err_buff, str);
	return(-1);
    }

/*--------------------------------------------------------------------*\
    Parse the command line setting application parameters
\*--------------------------------------------------------------------*/
    ProUtilCommandLineParse( argc, argv );

/*--------------------------------------------------------------------*\
    Print the input arguments
\*--------------------------------------------------------------------*/
    ProTKPrintf("\n");
    for(a=0;a<argc;a++)
    ProTKPrintf("\targv[%d]       = %s\n", a, argv[a]);
    ProTKPrintf("\tPro/E version = %s\n", proe_vsn);
    ProTKPrintf("\tPro/E build   = %s\n", build);

/*--------------------------------------------------------------------*\
    Open the error log file.
\*--------------------------------------------------------------------*/
    if(argc > 4)
	ProTestErrlogOpen(argv[4], proe_vsn, build);
    else
	ProTestErrlogOpen((char*)"pt_toolkit", proe_vsn, build);
/*--------------------------------------------------------------------*\
    Test ProToolkit functions
\*--------------------------------------------------------------------*/
    TEST_CALL_REPORT("ProToolkitMain()", "user_initialize()", PRO_TK_NO_ERROR, 0);
    TEST_CALL_REPORT( "ProWcharSizeVerify()", "user_initialize()",  status , 0);

    status = ProToolkitApplExecPathGet( w_path );
    TEST_CALL_REPORT( "ProToolkitApplExecPathGet()", "user_initialize()", 
			status, status != PRO_TK_NO_ERROR );
    
    ProTKSprintf(str, "Exec path is %0s", ProWstringToString( path, w_path ));
    ProUtilMsgPrint( "gen", "TEST %0s", str);
 
    ProMessageClear();
    TEST_CALL_REPORT( "ProMessageClear()", "user_initialize()", PRO_TK_NO_ERROR, 0 );

    status = ProToolkitApplTextPathGet( w_path );
    TEST_CALL_REPORT( "ProToolkitApplTextPathGet()", "user_initialize()", 
			status, status != PRO_TK_NO_ERROR );
    ProTKSprintf(str, "Text path is %0s", ProWstringToString( path, w_path ));
    ProUtilMsgPrint( "gen", "TEST %0s", str);

    ProMessageClear();
    TEST_CALL_REPORT( "ProMessageClear()", "user_initialize()", PRO_TK_NO_ERROR, 0 );
    
/*---------------------------------------------------------------------*\
    Add "PTExamples" after info button to the menu bar
\*---------------------------------------------------------------------*/
   ProStringToWstring(message_file, (char*)"gen_msg.txt");
   status = ProMenubarMenuAdd ((char*)"PTExamples", (char*)"PTExamples",
        (char*)"Info", PRO_B_TRUE, message_file);
    TEST_CALL_REPORT( "ProMenubarMenuAdd()", "user_initialize()", PRO_TK_NO_ERROR, 0 );
/*---------------------------------------------------------------------*\
    Add "-Main" button to the menu bar
\*---------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-Main",
        (uiCmdCmdActFn)ProTestMain,
        uiProe2ndImmediate, TestAccessDefault,
        PRO_B_TRUE, PRO_B_TRUE, &cmd_id);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-Main", (char*)"-Main",
        (char*)"Non-mode-specific Pro/TOOLKIT test commands", NULL,
	 PRO_B_TRUE, cmd_id, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

/*---------------------------------------------------------------------*\
    Add "-Drawing" button to the menu bar
\*---------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-TKDrawingtest",
			     (uiCmdCmdActFn)ProTestDraw,
			     uiProe2ndImmediate, TestDrawingAccess,
			     PRO_B_TRUE, PRO_B_TRUE, &cmd_id_draw);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
		     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TKDrawingtest", (char*)"-TKDrawingtest",
        (char*)"Drawing Test menu", (char*)"-Main",
	 PRO_B_TRUE, cmd_id_draw, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

/*---------------------------------------------------------------------*\
    Add "-Diagram" button to the menu bar
\*---------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-TKDiagramtest",
			     (uiCmdCmdActFn)ProTestDiagram,
			     uiProe2ndImmediate, TestDiagramAccess,
			     PRO_B_TRUE, PRO_B_TRUE, &cmd_id_diagram);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
		     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TKDiagramtest", (char*)"-TKDiagramtest",
        (char*)"Diagram Test menu", (char*)"-TKDrawingtest",
	 PRO_B_TRUE, cmd_id_diagram, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

/*---------------------------------------------------------------------*\
    Add "-Report" button to the menu bar
\*---------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-TKReporttest",
			     (uiCmdCmdActFn)ProTestReport,
			     uiProe2ndImmediate, TestReportAccess,
			     PRO_B_TRUE, PRO_B_TRUE, &cmd_id_report);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
		     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TKReporttest", (char*)"-TKReporttest",
        (char*)"Report Test menu", (char*)"-TKDiagramtest",
	 PRO_B_TRUE, cmd_id_report, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

/*---------------------------------------------------------------------*\
    Add "-Layout" button to the menu bar
\*---------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-TKLayouttest",
			     (uiCmdCmdActFn)ProTestLayout,
			     uiProe2ndImmediate, TestLayoutAccess,
			     PRO_B_TRUE, PRO_B_TRUE, &cmd_id_layout);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
		     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TKLayouttest", (char*)"-TKLayouttest",
       (char*)"Layout Test menu", (char*)"-TKReporttest",
	 PRO_B_TRUE, cmd_id_layout, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

/*--------------------------------------------------------------------*\
    Add to the part menu.
\*--------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-TkPart",
                             (uiCmdCmdActFn)ProTestPart,
                             uiProe2ndImmediate, TestPartAccess,
                             PRO_B_TRUE, PRO_B_TRUE, &cmd_id_layout);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
                     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TkPart", (char*)"-TkPart",
        (char*)"Menu of commands for testing Pro/TOOLKIT in part mode", (char*)"-TKLayouttest",
         PRO_B_TRUE, cmd_id_layout, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

#ifndef PT_PRODUCTS_BUILD
    ProMenuFileRegister((char*)"part",(char*)"part.mnu", &menu_id);
    status = ProMenuAuxfileRegister((char*)"part",(char*)"part.aux", &menu_id);
    TEST_CALL_REPORT("ProMenuAuxfileRegister()", "user_initialize()", 
		status, status !=PRO_TK_NO_ERROR);

    ProMenubuttonActionSet((char*)"part",(char*)"-TkPart", 
	(ProMenubuttonAction)ProTestPart, NULL, 0);
#else
   ProMenuFileRegister("jr_part", "jnew_part.mnu", &menu_id);
   status = ProMenuAuxfileRegister("jr_part", "part.aux", &menu_id);
   TEST_CALL_REPORT("ProMenuAuxfileRegister()", "user_initialize()",
                status, status !=PRO_TK_NO_ERROR);

   ProMenubuttonActionSet("jr_part", "-TkPart", ProTestPart, NULL, 0);
#endif

/*--------------------------------------------------------------------*\
    Add to the assembly menu.
\*--------------------------------------------------------------------*/

    status = ProCmdActionAdd((char*)"-TkAsm",
                             (uiCmdCmdActFn)ProTestAsm,
                             uiProe2ndImmediate, TestAsmAccess,
                             PRO_B_TRUE, PRO_B_TRUE, &cmd_id_layout);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
                     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TkAsm", (char*)"-TkAsm",
        (char*)"Menu of commands for testing Pro/TOOLKIT in assembly mode", (char*)"-TkPart",
         PRO_B_TRUE, cmd_id_layout, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"assembly",(char*)"assembly.mnu", &menu_id);
    status = ProMenuAuxfileRegister((char*)"assembly",(char*)"assembly.aux", &menu_id);
    TEST_CALL_REPORT("ProMenuAuxfileRegister()", "user_initialize()", 
		status, status !=PRO_TK_NO_ERROR);
    ProMenubuttonActionSet((char*)"assembly",(char*)"-TkAsm", 
			(ProMenubuttonAction)ProTestAsm, NULL, 0);

/*--------------------------------------------------------------------*\
    Add to the diagram menu.
\*--------------------------------------------------------------------*/
    ProMenuFileRegister((char*)"diagram",(char*)"diagram.mnu", &menu_id);
    status = ProMenuAuxfileRegister((char*)"diagram",(char*)"diagram.aux", &menu_id);
    TEST_CALL_REPORT("ProMenuAuxfileRegister()", "user_initialize()",
                status, status !=PRO_TK_NO_ERROR);
    ProMenubuttonActionSet((char*)"diagram",(char*)"-TkDiagram",
                        (ProMenubuttonAction)ProTestDiagram, NULL, 0);

/*--------------------------------------------------------------------*\
    Add to the Layout menu.
\*--------------------------------------------------------------------*/
    ProMenuFileRegister((char*)"notebook",(char*)"notebook.mnu", &menu_id);
    status = ProMenuAuxfileRegister((char*)"notebook",(char*)"notebook.aux", &menu_id);
    TEST_CALL_REPORT("ProMenuAuxfileRegister()", "user_initialize()", 
		status, status !=PRO_TK_NO_ERROR);
    ProMenubuttonActionSet((char*)"notebook",(char*)"-TkLayout", 
			(ProMenubuttonAction)ProTestLayout, NULL, 0);

/*--------------------------------------------------------------------*\
    Add to the manufacturing menu
\*--------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-TkMfgNew",
                             (uiCmdCmdActFn)ProTestMfgNew,
                             uiProe2ndImmediate, TestMfgAccess,
                             PRO_B_TRUE, PRO_B_TRUE, &cmd_id_layout);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
                     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TkMfgNew", (char*)"-TkMfgNew",
        (char*)"Command for testing Pro/TOOLKIT in manufacturing mode new", (char*)"-TkAsm",
         PRO_B_TRUE, cmd_id_layout, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

    status = ProCmdActionAdd((char*)"-TkMfg",
                             (uiCmdCmdActFn)ProTestMfg,
                             uiProe2ndImmediate, TestMfgAccess,
                             PRO_B_TRUE, PRO_B_TRUE, &cmd_id_layout);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
                     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TkMfg", (char*)"-TkMfg",
        (char*)"Command for testing Pro/TOOLKIT in manufacturing mode", (char*)"-TkMfgNew",
         PRO_B_TRUE, cmd_id_layout, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"manufacture",(char*)"mfg.mnu", &menu_id);
    status = ProMenuAuxfileRegister((char*)"manufacture",(char*)"mfg.aux", &menu_id);
    TEST_CALL_REPORT("ProMenuAuxfileRegister()", "user_initialize()", 
		status, status !=PRO_TK_NO_ERROR);

    ProMenubuttonActionSet((char*)"manufacture",(char*)"-TkMfg", 
			(ProMenubuttonAction)ProTestMfg, NULL,0);
    ProMenubuttonActionSet((char*)"manufacture",(char*)"-TkMfgNew",
			(ProMenubuttonAction)ProTestMfgNew, NULL, 0);
/*--------------------------------------------------------------------*\
    Add to the mold menu
\*--------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-TkCavityLayout",
                             (uiCmdCmdActFn)ProTestCavityLayoutMenu,
                             uiProe2ndImmediate, TestMfgMoldCavityAccess,
                             PRO_B_TRUE, PRO_B_TRUE, &cmd_id_layout);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
                     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TkCavityLayout", (char*)"-TkCavityLayout",
        (char*)"Testing cavity layout function", (char*)"-TkMfg",
         PRO_B_TRUE, cmd_id_layout, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"mold",(char*)"mold.mnu", &menu_id);
    ProMenuAuxfileRegister((char*)"mold",(char*)"mold.aux", &menu_id);
    ProMenubuttonActionSet((char*)"mold",(char*)"-TkCavityLayout",
        (ProMenubuttonAction)ProTestCavityLayoutMenu,NULL,0);

/*--------------------------------------------------------------------*\
    Add to the mold layout menu
\*--------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-TkMold Layout",
                             (uiCmdCmdActFn)ProTestMoldLayoutMenu,
                             uiProe2ndImmediate, TestMfgMoldCavityAccess,
                             PRO_B_TRUE, PRO_B_TRUE, &cmd_id_layout);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
                     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TkMold Layout", (char*)"-TkMold Layout",
        (char*)"Mold Layout Test menu", (char*)"-TkCavityLayout",
         PRO_B_TRUE, cmd_id_layout, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"Mold_Layout20", (char*)"rmdt.mnu", &menu_id);
    ProMenuAuxfileRegister((char*)"Mold_Layout20", (char*)"rmdt.aux", &menu_id);

    ProMenubuttonActionSet((char*)"Mold_Layout20",(char*)"-TkMold Layout",
        (ProMenubuttonAction)ProTestMoldLayoutMenu, NULL, 0);

/*--------------------------------------------------------------------*\
    Add to the asm#process menu
\*--------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-Step Active Set",
                             (uiCmdCmdActFn)ProTestProcstep,
                             uiProe2ndImmediate, TestAsmProcessPlanAccess,
                             PRO_B_TRUE, PRO_B_TRUE, &cmd_id_layout);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
                     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-Step Active Set", (char*)"-Step Active Set",
        (char*)"Set Active step for process",(char*) "-TkMold Layout",
         PRO_B_TRUE, cmd_id_layout, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"Asm process", (char*)"asmprocess.mnu", &menu_id);
    ProMenuAuxfileRegister((char*)"Asm process", (char*)"asmprocess.aux", &menu_id);
    ProMenubuttonActionSet((char*)"Asm process", (char*)"-Step Active Set",
        (ProMenubuttonAction)ProTestProcstep, NULL, 0);

/*--------------------------------------------------------------------*\
    Add to the drawing menu.
\*--------------------------------------------------------------------*/
    ProMenuFileRegister((char*)"drawing",(char*)"draw.mnu", &menu_id);
    status = ProMenuAuxfileRegister((char*)"drawing",(char*)"draw.aux", &menu_id);
    TEST_CALL_REPORT("ProMenuAuxfileRegister()", "user_initialize()", 
		      status, status !=PRO_TK_NO_ERROR);
    ProMenubuttonActionSet((char*)"drawing",(char*)"-TkDrawing", 
			   (ProMenubuttonAction)ProTestDraw, NULL, 0);

    ProStringToWstring(w_com, (char*)"Application pt_examples started");
    status = ProTrailfileCommentWrite(w_com);
    TEST_CALL_REPORT("ProTrailfileCommentWrite()", "user_initialize()",
		     status, status != PRO_TK_NO_ERROR);

/*--------------------------------------------------------------------*\
    Add to the FEM menu.
\*--------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-TkFEM",
                             (uiCmdCmdActFn)ProTestFemMeshMenu,
                             uiProe2ndImmediate, TestAsmAccess,
                             PRO_B_TRUE, PRO_B_TRUE, &cmd_id_layout);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
                     status, status != PRO_TK_NO_ERROR);

    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TkFEM", (char*)"-TkFEM",
        (char*)"Test Pro/MECHANICA FEM Mesh function", (char*)"-Step Active Set",
         PRO_B_TRUE, cmd_id_layout, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"assembly",(char*)"assembly.mnu", &menu_id);
    status = ProMenuAuxfileRegister((char*)"assembly",(char*)"tk_fem.aux", &menu_id);
    ProMenubuttonActionSet((char*)"assembly",(char*)"TkFEM",
        (ProMenubuttonAction)ProTestFemMeshMenu, NULL, 0);

/*--------------------------------------------------------------------*\
    Add to the welding menu.
\*--------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-TkWelding",
                             (uiCmdCmdActFn)ProTestWeldMenu,
                             uiProe2ndImmediate, TestAsmAccess,
                             PRO_B_TRUE, PRO_B_TRUE, &cmd_id_layout);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
                     status, status != PRO_TK_NO_ERROR);
    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TkWelding", (char*)"-TkWelding",
        (char*)"Welding Test menu", (char*)"-TkFEM",
         PRO_B_TRUE, cmd_id_layout, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"welding",(char*)"welding.mnu", &menu_id);
    ProMenuAuxfileRegister((char*)"welding",(char*)"welding.aux", &menu_id);
    ProMenubuttonActionSet((char*)"welding",(char*)"-TkWelding",
	(ProMenubuttonAction)ProTestWeldMenu, NULL, 0);

/*--------------------------------------------------------------------*\
    Add to the mold product menu.
\*--------------------------------------------------------------------*/
    status = ProCmdActionAdd((char*)"-TkMoldProd",
                             (uiCmdCmdActFn)ProTestMoldProd,
                             uiProe2ndImmediate, TestAsmAccess,
                             PRO_B_TRUE, PRO_B_TRUE, &cmd_id_layout);
    TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
                     status, status != PRO_TK_NO_ERROR);
    status = ProMenubarmenuPushbuttonAdd(
        (char*)"PTExamples", (char*)"-TkMoldProd", (char*)"-TkMoldProd",
        (char*)"Mold Test menu", (char*)"-TkWelding",
         PRO_B_TRUE, cmd_id_layout, message_file);
    TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
                      status, status != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"MOLD LAYOUT",(char*)"moldprod.mnu", &menu_id);
    ProMenuAuxfileRegister((char*)"MOLD LAYOUT",(char*)"moldprod.aux", &menu_id);
    ProMenubuttonActionSet((char*)"MOLD LAYOUT",(char*)"-TkMoldProd",
        (ProMenubuttonAction)ProTestMoldProd,NULL,0);

/*--------------------------------------------------------------------*\
    Add to the report menu.
\*--------------------------------------------------------------------*/
    ProMenuFileRegister((char*)"report",(char*)"report.mnu", &menu_id);
    ProMenuAuxfileRegister((char*)"report",(char*)"report.aux", &menu_id);
    ProMenubuttonActionSet((char*)"report",(char*)"-TkReport",
	(ProMenubuttonAction)ProTestReport, NULL, 0);
        
/*--------------------------------------------------------------------*\
    Register analysis types
\*--------------------------------------------------------------------*/
    ProTestAnalysisRegister ();

/*--------------------------------------------------------------------*\
    Add button to Resolve Feat menu
\*--------------------------------------------------------------------*/
    ProUtilResolveFeatMenu ();

    return(0);
}

/*====================================================================*\
    FUNCTION :	user_terminate()
    PURPOSE  :	Pro/DEVELOP standard termination
\*====================================================================*/
void user_terminate()
{
    ProTestErrlogClose();
}

/*====================================================================*\
    FUNCTION :	ProTestMain()
    PURPOSE  :	Define and activate menu of Toolkit Test commands which
		are not mode-specific and therefore appear below the
		Main Menu.
\*====================================================================*/
int ProTestMain()
{
    int menu_id, action;

    int ProTestViewMenu();
    int ProTestObjWinMenu();
    int ProTestChangeDir();
    int ProTestMessage();
    int ProTestMacro();
    int ProTestConfig();
    int ProTestMenuBar();
    int ProTestUITableEditExample();

    ProMenuFileRegister((char*)"TkMain",(char*)"tkmain.mnu", &menu_id);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-Notify", 
		    (ProMenubuttonAction)ProTestNotify, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-Dbms",
		    (ProMenubuttonAction)ProTestDbms, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-Section", 
		    (ProMenubuttonAction)ProTestSectionMenuAction, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-Simp Rep",
		    (ProMenubuttonAction)ProTestSRepRetrieve, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-Menus", 
		    (ProMenubuttonAction)ProTestMenus, NULL, 0);
    
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-MenuBar", 
		    (ProMenubuttonAction)ProTestMenuBar, NULL, 0);
    
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-Message", 
		    (ProMenubuttonAction)ProTestMessage, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-Macro", 
		    (ProMenubuttonAction)ProTestMacro, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-Obj Windows",
                    (ProMenubuttonAction)ProTestObjWinMenu, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-View",
                    (ProMenubuttonAction) ProTestViewMenu, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-UI Table Edit",
                    (ProMenubuttonAction) ProTestUITableEditExample, 
                    NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"MULTI-CAD",
		    (ProMenubuttonAction)ProTestMultiCADFile, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-Change dir", 
		    (ProMenubuttonAction)ProTestChangeDir, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-Config Opt", 
		    (ProMenubuttonAction)ProTestConfig, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"-Done", 
		    (ProMenubuttonAction)ProMenuDelete, NULL, 0);
    ProMenubuttonActionSet((char*)"TkMain",(char*)"TkMain",
	    	    (ProMenubuttonAction)ProMenuDelete, NULL, 0);

    ProMenuCreate(PROMENUTYPE_MAIN, (char*)"TkMain", &menu_id);
    ProMenuProcess((char*)"", &action);

    return(0);
}

/*====================================================================*\
    FUNCTION :	ProTestPart()
    PURPOSE  :	Define and activate menu of Toolkit Test commands for parts
\*====================================================================*/
int ProTestPart()
{
    ProMdl part;
    ProError status;
    int ProTestFeatures(ProMdl *);
    int ProTestAnalysis ();
    int ProTestGeometry();
    int ProTestGeneData();
    int ProTestMisc();
    int ProTestLayerMenu();
//    int ProTestLayerR19Menu();
    int ProTestAnimation();
    int ProTestGraphics();
    int ProTestPartMaterial();
    int ProTestFamlyTabMenu();
    int ProTestCollection();
    int ProTestRelationsMenu();
    int ProTestInterface();
    int ProTestXsec();
    int ProTestDimensionMenu();
	int ProTestDispObjectSetMenu();
    
    int menu_id, action;

    status = ProMdlCurrentGet(&part);
    TEST_CALL_REPORT("ProMdlCurrentGet()", "ProTestPart()",
				status, status != PRO_TK_NO_ERROR);
    ProMenuPush();
    ProMenuFileRegister((char*)"TkPart",(char*)"tkpart.mnu", &menu_id);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"TkPart", 
    			   (ProMenubuttonAction)ProMenuDelete, NULL,  0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-ExtAnalysis",
    			   (ProMenubuttonAction)ProTestAnalysis,  &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Features",
    			   (ProMenubuttonAction)ProTestFeatures,  &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Geometry", 
			    (ProMenubuttonAction)ProTestGeometry,  &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Selection", 
    			(ProMenubuttonAction)ProTestSelection, &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Parameters",
    			(ProMenubuttonAction)ProTestParams,  &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Family Tab",
    			(ProMenubuttonAction)ProTestFamlyTabMenu, &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Extobj",
    			(ProMenubuttonAction)ProTestExtobj, &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Dbms", 
    			(ProMenubuttonAction)ProTestDbms, &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-SimpRep",
    			(ProMenubuttonAction)ProTestSimpRep,  &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Interface",
                        (ProMenubuttonAction)ProTestInterface, &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Set Up", 
    			(ProMenubuttonAction)ProTestSetupMnu, &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Layer", 
    			(ProMenubuttonAction)ProTestLayerMenu, &part, 0);
//    ProMenubuttonActionSet((char*)"TkPart",(char*)"-LayerR19", 
//    			(ProMenubuttonAction)ProTestLayerR19Menu, &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Appdata", 
    			(ProMenubuttonAction)ProTestGeneData, &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Misc", 
    			(ProMenubuttonAction)ProTestMisc, &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Animation",
                    (ProMenubuttonAction)ProTestAnimation, NULL, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Graphics",
                    (ProMenubuttonAction)ProTestGraphics, NULL, 0);
    ProMenubuttonActionSet((char*) "TkPart",(char*)"-Material", 
    			(ProMenubuttonAction)ProTestPartMaterial, &part, 0);
    ProMenubuttonActionSet( (char*)"TkPart",(char*)"-Collection", 
    			(ProMenubuttonAction)ProTestCollection, &part, 0);
    ProMenubuttonActionSet( (char*)"TkPart",(char*)"-Relations", 
    			(ProMenubuttonAction)ProTestRelationsMenu, &part, 0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Done/Return", 
    			(ProMenubuttonAction)ProMenuDelete, NULL,  0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Xsec",
			(ProMenubuttonAction)ProTestXsec, &part,  0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-Dimension",
			(ProMenubuttonAction)ProTestDimensionMenu, &part,  0);
    ProMenubuttonActionSet((char*)"TkPart",(char*)"-DisplayObj",
	(ProMenubuttonAction)ProTestDispObjectSetMenu, NULL, 0);

    ProMenuCreate(PROMENUTYPE_MAIN, (char*)"TkPart", &menu_id);
    ProMenuProcess((char*)"", &action);

    ProMenuPop();

    return(0);
}

/*====================================================================*\
    FUNCTION :	ProTestAsm()
    PURPOSE  :	Define and activate menu of Toolkit Test commands for 
		assemblies.
\*====================================================================*/
int ProTestAsm()
{
    ProMdl assembly;
    ProError status;
    int ProTestFeatures(ProMdl *);
    int ProTestGeometry();
    int ProTestMisc();
    int ProTestLayerMenu();
//    int ProTestLayerR19Menu();
    int ProTestAnimation();
    int ProTestAsmFunc();
    int ProTestAsmcomppathFunc();
    int ProTestAsmcompFunc();
    int ProTestGraphics();
    int ProTestFamlyTabMenu();
    int ProTestCollection();
    int ProTestInterface();
    int ProTestXsec();
    int ProTestDimensionMenu();
    int ProTestDrag();
	int ProTestDispObjectSetMenu();
    
    int menu_id, action;

    int ProTestExtrnReferences (ProMdl *model);
    /* TestExtref.c */

    status = ProMdlCurrentGet(&assembly);
    TEST_CALL_REPORT("ProMdlCurrentGet()", "ProTestAsm()",
				status, status != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"TkAsm",(char*)"tkasm.mnu", &menu_id);
    ProMenubuttonActionSet((char*)"TkAsm",(char*) "TkAsm",
			(ProMenubuttonAction)ProMenuDelete, NULL,  0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Features",
			(ProMenubuttonAction)ProTestFeatures,  &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Geometry", 
    			(ProMenubuttonAction)ProTestGeometry,  &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Selection",
    			(ProMenubuttonAction)ProTestSelection, &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Parameters",
    			(ProMenubuttonAction)ProTestParams,  &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Family Tab",
    			(ProMenubuttonAction)ProTestFamlyTabMenu, &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Extobj",
    			(ProMenubuttonAction)ProTestExtobj,  &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Dbms", 
    			(ProMenubuttonAction)ProTestDbms,  &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-SimpRep",
    			(ProMenubuttonAction)ProTestSimpRep,  &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Interface",
                        (ProMenubuttonAction)ProTestInterface,  &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Set Up", 
    			(ProMenubuttonAction)ProTestSetupMnu, &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Layer", 
    			(ProMenubuttonAction)ProTestLayerMenu, &assembly, 0);
//    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-LayerR19",
//    			(ProMenubuttonAction)ProTestLayerR19Menu, &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Misc", 
    			(ProMenubuttonAction)ProTestMisc,  &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Expl/Unexpl", 
    			(ProMenubuttonAction)ProTestAsmFunc,  &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Rotate comp", 
    			(ProMenubuttonAction)ProTestAsmcomppathFunc,
			&assembly,0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Components",
                    (ProMenubuttonAction)ProTestAsmcompFunc, &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Animation",
                    (ProMenubuttonAction)ProTestAnimation, NULL, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Graphics",
                    (ProMenubuttonAction)ProTestGraphics, NULL, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Collection",
                    (ProMenubuttonAction)ProTestCollection, &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-ExtRef",
                    (ProMenubuttonAction)ProTestExtrnReferences, &assembly, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Xsec",
		    (ProMenubuttonAction)ProTestXsec, &assembly,  0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Dimension",
		    (ProMenubuttonAction)ProTestDimensionMenu, &assembly,  0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Drag",
		    (ProMenubuttonAction)ProTestDrag, &assembly,  0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-DisplayObj",
	(ProMenubuttonAction)ProTestDispObjectSetMenu, NULL, 0);
    ProMenubuttonActionSet((char*)"TkAsm",(char*)"-Done/Return", 
    			(ProMenubuttonAction)ProMenuDelete, NULL,  0);

    ProMenuCreate(PROMENUTYPE_MAIN, (char*)"TkAsm", &menu_id);
    ProMenuProcess((char*)"", &action);

    return(0);
}

/*====================================================================*\
    FUNCTION :  ProTestDiagram()
    PURPOSE  :  Define and activate menu of Toolkit Test commands for diagram
\*====================================================================*/
int ProTestDiagram()
{
    ProMdl diagram;
    ProError status;
    int ProTestLayerMenu();
//    int ProTestLayerR19Menu();
    int menu_id, action;

    status = ProMdlCurrentGet(&diagram);
    TEST_CALL_REPORT("ProMdlCurrentGet()", "ProTestDiagram()",
                                status, status != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"TkDiagram",(char*)"tkdiagram.mnu", &menu_id);
    ProMenubuttonActionSet((char*)"TkDiagram",(char*)"TkDiagram",
                           (ProMenubuttonAction)ProMenuDelete, NULL,  0);
    ProMenubuttonActionSet((char*)"TkDiagram",(char*)"-Layer",
                        (ProMenubuttonAction)ProTestLayerMenu, &diagram, 0);
//    ProMenubuttonActionSet((char*)"TkDiagram",(char*)"-LayerR19",
//                        (ProMenubuttonAction)ProTestLayerR19Menu, &diagram, 0);
    ProMenubuttonActionSet((char*)"TkDiagram",(char*)"Done TkDiagram",
                        (ProMenubuttonAction)ProMenuDelete, NULL,  0);

    ProMenuCreate(PROMENUTYPE_MAIN, (char*)"TkDiagram", &menu_id);
    ProMenuProcess((char*)"", &action);

    return(0);
}


int ProTestMfg()
{
    ProMdl mfg;
    ProError status;
    int ProTestFeatures(ProMdl *);
    
    status = ProMdlCurrentGet(&mfg);

    status = (ProError) ProTestFeatures(&mfg);

    return 0;
}

/*====================================================================*\
    FUNCTION :	ProTestLayout()
    PURPOSE  :	Define and activate menu of Toolkit Test commands for layout
\*====================================================================*/
int ProTestLayout()
{
    ProMdl layout;
    ProError status;
    int menu_id, action;

    status = ProMdlCurrentGet(&layout);
    TEST_CALL_REPORT("ProMdlCurrentGet()", "ProTestLayout()",
				status, status != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"TkLayout",(char*)"tklayout.mnu", &menu_id);
    ProMenubuttonActionSet((char*)"TkLayout",(char*)"TkLayout", 
    			   (ProMenubuttonAction)ProMenuDelete, NULL,  0);
    ProMenubuttonActionSet((char*)"TkLayout",(char*)"-Parameters",
    			(ProMenubuttonAction)ProTestParams, &layout, 0);
    ProMenubuttonActionSet((char*)"TkLayout",(char*)"Done TkLayout", 
    			(ProMenubuttonAction)ProMenuDelete, NULL,  0);

    ProMenuCreate(PROMENUTYPE_MAIN,(char*)"TkLayout", &menu_id);
    ProMenuProcess((char*)"", &action);

    return(0);
}

/*====================================================================*\
    FUNCTION :	ProTestChangeDir()
    PURPOSE  :	Change Pro/E to a new directory	
\*====================================================================*/
int ProTestChangeDir()
{
    char dir[PRO_PATH_SIZE];
    char str[PRO_PATH_SIZE];
    ProPath  w_dir;
    static ProPath last_dir;
    ProError    status;

    ProUtilMsgPrint("gen", "TEST %0s", "Enter a directory name or <back>:");

    if (ProUtilStringGet(w_dir, NULL, PRO_LINE_SIZE)==0)
	return (0);

    if (ProUtilStrnwscmp((char*)"<back>", w_dir, 6)==0)
    {
	status = ProDirectoryChange(last_dir);
    }
    else
    {
	status = ProDirectoryCurrentGet(last_dir);
	TEST_CALL_REPORT("ProDirectoryCurrentGet()", "ProTestChangeDir()", 
		status, status !=PRO_TK_NO_ERROR);
	status = ProDirectoryChange(w_dir);
    }
    TEST_CALL_REPORT("ProDirectoryChange()", "ProTestChangeDir()", status, 0);
    if (status == PRO_TK_NO_ERROR)
        ProUtilMsgPrint("gen", "TEST %0s", "Directory succesfully changed");
    else
        ProUtilMsgPrint("gen", "TEST %0s", "Directory NOT changed");

    ProMessageClear();
    status = ProDirectoryCurrentGet(w_dir);
    TEST_CALL_REPORT("ProDirectoryCurrentGet()", "ProTestChangeDir()", 
		status, status !=PRO_TK_NO_ERROR);
    ProWstringToString(dir, w_dir);
    ProTKSprintf (str, "Current directory is %s", dir);
    ProUtilMsgPrint("gen", "TEST %0s", str);

    return(0);
}

/*====================================================================*\
    FUNCTION :	ProTestLayout()
    PURPOSE  :	Define and activate menu of Toolkit Test commands for mold
                products
\*====================================================================*/
int ProTestMoldProd ()
{
    ProMdl mdl;
    ProError err;
    int menu_id, action;
    int ProTestImm ();
    int ProTestMoldBase ();
   
    err = ProMdlCurrentGet(&mdl);
    TEST_CALL_REPORT("ProMdlCurrentGet()", "ProTestMoldProd()",
				err, err != PRO_TK_NO_ERROR);

    ProMenuFileRegister((char*)"TkMoldProd",(char*)"tkmoldprod.mnu", &menu_id);
    ProMenubuttonActionSet((char*)"TkMoldProd",(char*)"TkMoldProd", 
    			   (ProMenubuttonAction)ProMenuDelete, NULL,  0);
    ProMenubuttonActionSet((char*)"TkMoldProd",(char*)"-MoldBase",
    			(ProMenubuttonAction)ProTestMoldBase, mdl, 0);
    ProMenubuttonActionSet((char*)"TkMoldProd",(char*)"-Imm", 
    			(ProMenubuttonAction)ProTestImm, mdl,  0);

    ProMenuCreate(PROMENUTYPE_MAIN, (char*)"TkMoldProd", &menu_id);
    ProMenuProcess((char*)"", &action);
   
    return (0);
}

int ProTestReport()
{
    ProError status;
    ProMdl   model;
    int action;
    int ProTestDrwSimpRep();
    ProError ProTestDrwTable(ProDrawing drawing);

    status = ProMdlCurrentGet(&model);
    TEST_CALL_REPORT("ProMdlCurrentGet()", "ProTestReport()",
                                status, status != PRO_TK_NO_ERROR);
    ProMenuPush ();
    ProMenuFileRegister((char*)"TkReport",(char*)"tkreport.mnu", NULL);
    ProMenubuttonActionSet((char*)"TkReport",(char*)"-Table",
        (ProMenubuttonAction)ProTestDrwTable, &model,  0);
    ProMenubuttonActionSet((char*)"TkReport",(char*)"-simp rep",
        (ProMenubuttonAction)ProTestDrwSimpRep, &model,  0);
    ProMenubuttonActionSet((char*)"TkReport",(char*)"TkReport",
        (ProMenubuttonAction)ProMenuDelete, NULL,  0);
    ProMenubuttonActionSet((char*)"TkReport",(char*)"-Done/Return",
        (ProMenubuttonAction)ProMenuDelete, NULL,  0);

    ProMenuCreate(PROMENUTYPE_MAIN, (char*)"TkReport", NULL);
    ProMenuProcess((char*)"", &action);
    ProMenuPop();
    return (0);
}