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

/*---------------------- Pro/Toolkit Includes ------------------------*/
#include <ProToolkit.h>
#include <ProMenu.h>
#include <ProMdl.h>
#include <ProMode.h>

/*---------------------- Application Includes ------------------------*/
#include <TestError.h>


int UserGeometrySetup(void * user_data, int calling_menu);
int UserLayerSetup(void * user_data, int calling_menu);
int UserParamSetup(void * user_data, int calling_menu);
int UserSktFeatSetup();
int UserInterfChckSetup();
int UserAnimationSetup();
int UserMenuDeleteAndPop();
int UserCoordTransfSetup();
ProError UserViewsSetup();
int UserSectionSetup();
int UserRelationsSetup();
int CreateCascadeMenu();

/*------------------------- External Data ----------------------------*/
extern int UserVisitDemo();
extern int UserLoadPart();
extern int UserOutlineCompute();
extern int UserArcDiaDisp();
extern int UserConeAngDisp();
extern int UserChildDisp();
extern int UserSurfRename();
extern int UserSurfArea();
extern int UserCurveLength();
extern int UserHoleSrfDisp();
extern int UserBlank();
extern int UserScanLayers();
extern int UserLabelFeature();
extern int UserDatumRefs();
extern int UserAsmCompVisit();
extern int ProDemoBaseExtrudeProtrCreate();
extern ProError user_surf_clear();
extern ProError user_dist_manifolds();
extern ProError user_global_interference();
extern ProError user_part_interference();
extern int UserLayerCreate();
extern int UserAsmcompAnimate();
extern ProError UserDisplayREADME();
extern int UserDtmPlaneSetup();
extern int UserFeatCollectExample();
extern int UserDimensionChange();
extern ProError UserDimDisplayRounded();
extern ProError UserDimensionsByAxisDirectionShow();
extern int UserScreen2DrwExample();
extern int UserSolid2ScreenExample();
extern int UserSectionCreateExample();
extern int UserSectionReplace();
extern int UserAddSplineDimension();
extern int user_Family_Diffs();
extern int UserExtobjCreate();
extern int UgBaseSweepProtrCreate();
extern int UserRelsEdit();
extern int ProDemoHoleCreate();
extern ProError ProDemoGeneralCsysCreate();
extern ProError ProDemoGeneralPointCreate();
extern ProError ProDemoSketchedPointCreate();
extern ProError ProDemoOffsetPointCreate();
extern ProError ProDemoFieldPointCreate();
extern ProError ProDemoSketchedCurveCreate();
extern ProError ProDemoDatumAxisCreate();
extern ProError UserSktExtrusionProtrusion();
extern ProError UserSktExtrusionCut();
extern ProError UserSktExtrusionThin();
extern ProError UserSktExtrusionSurfaceCapped();
extern ProError UserSktExtrusionSurfaceTrim();
extern ProError UserSktRevolveProtrusion();
extern ProError UserSktRevolveThinCut();
extern ProError UserSktRevolveSurface();
extern int UgSweepProtrCreate();
extern ProError UgSktFirstFeatureCreate();
extern ProError UgSktFirstFeatureRevCreate();
extern ProError UserEdgeRoundCreate();
extern ProError UserEdgeChamferCreate();
extern ProError UserSimpleDraftCreate();
extern ProError UserSktRevolveProtrusionExtSkt();
extern ProError UserSktExtrusionProtrusionExtSkt();
extern ProError UserIntcollectionDraftCreate();
extern ProError UserOADraftCreate();
extern ProError FeatRemoveSurfExample();
extern ProError UgCreoSweepCreate();
extern ProError UserFlexModelCreateonSurface();
extern ProError UserFlexModelCreateFree();
extern ProError UserFlexModelCreateonEdge();

/*====================================================================*\
Function : UserFundSetup()
Purpose  : Set up the Fundamentals Menu
\*====================================================================*/
int UserFundSetup(void * user_data, int calling_menu)
{
  int menu_id, action, status;

  status = ProMenuFileRegister("UGFUND", "ugfund.mnu", &menu_id);
  ERROR_CHECK( "UserFundSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGFUND","-Exp Array",
     (ProMenubuttonAction)UserFeatCollectExample, NULL, 0);
  ERROR_CHECK( "UserFundSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFUND","-Visit Functions",
     (ProMenubuttonAction)UserVisitDemo, NULL, 0);
  ERROR_CHECK( "UserFundSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFUND","-Coord Transf",
     (ProMenubuttonAction)UserCoordTransfSetup, NULL, calling_menu);
  ERROR_CHECK( "UserFundSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFUND", "-Done/Return",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL,0);
  ERROR_CHECK( "UserFundSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFUND", "UGFUND",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserFundSetup", "ProMenubuttonActionSet", status );

  status = ProMenuPush();
  ERROR_CHECK( "UserFundSetup", "ProMenuPush", status );

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGFUND", &menu_id);
  ERROR_CHECK( "UserFundSetup", "ProMenuCreate", status );

  if (calling_menu != PRO_MODE_PART)
  {
	status = ProMenubuttonDeactivate("UGFUND","-Exp Array");
   	ERROR_CHECK( "UserFundSetup", "ProMenubuttonDeactivate", status );
        if (calling_menu != PRO_MODE_ASSEMBLY)
	{
	  status = ProMenubuttonDeactivate("UGFUND","-Visit Functions");
 	  ERROR_CHECK( "UserFundSetup", "ProMenubuttonDeactivate", status );
	}		
  } 

  status = ProMenuProcess("UGFUND", &action);
  ERROR_CHECK( "UserFundSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserCoordTransfSetup()
Purpose  : Set up the menu for Coordinate Transformations
\*====================================================================*/
int UserCoordTransfSetup(void * user_data, int calling_menu)
{
  int menu_id, action, status;

  status = ProMenuFileRegister("UGCoordTransf", "ugcoord.mnu", &menu_id);
  ERROR_CHECK( "UserCoordTransfSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGCoordTransf","-Screen To Drawing",
     (ProMenubuttonAction)UserScreen2DrwExample, NULL, 0);
  ERROR_CHECK( "UserCoordTransfSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGCoordTransf","-Solid To Screen",
     (ProMenubuttonAction)UserSolid2ScreenExample, NULL, 0);
  ERROR_CHECK( "UserCoordTransfSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGCoordTransf","-Done/Return",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserCoordTransfSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGCoordTransf","UGCoordTransf",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserCoordTransfSetup", "ProMenubuttonActionSet", status );

  status = ProMenuPush();
  ERROR_CHECK( "UserCoordTransfSetup", "ProMenuPush", status );

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGCoordTransf", &menu_id);
  ERROR_CHECK( "UserCoordTransfSetup", "ProMenuCreate", status );

  if ((calling_menu != PRO_MODE_PART) && (calling_menu != PRO_MODE_ASSEMBLY))
  {
        status = ProMenubuttonDeactivate("UGCoordTransf","-Solid To Screen");
        ERROR_CHECK( "UserCoordTransfSetup", "ProMenubuttonDeactivate", status );
  }

  if (calling_menu != PRO_MODE_DRAWING)
  {
        status = ProMenubuttonDeactivate("UGCoordTransf","-Screen To Drawing");
        ERROR_CHECK( "UserCoordTransfSetup", "ProMenubuttonDeactivate", status );
  }

  status = ProMenuProcess("UGCoordTransf", &action);
  ERROR_CHECK( "UserCoordTransfSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}


/*====================================================================*
Function : UserGeometrySetup()
Purpose  : Set up the Geometry menu or the User's guide demo
\*====================================================================*/
int UserGeometrySetup(void * user_data, int calling_menu)
{
  int menu_id, action, status;

  status = ProMenuFileRegister("UGGeometry","uggeom.mnu",&menu_id);
  ERROR_CHECK( "UserGeometrySetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGGeometry","-Outline",
     (ProMenubuttonAction)UserOutlineCompute, NULL, 0);
  ERROR_CHECK( "UserGeometrySetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGGeometry","-Disp Arc Dia",
     (ProMenubuttonAction)UserArcDiaDisp, NULL, 0);
  ERROR_CHECK( "UserGeometrySetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGGeometry","-Disp Cone Angle",
     (ProMenubuttonAction)UserConeAngDisp, NULL, 0);
  ERROR_CHECK( "UserGeometrySetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGGeometry","-Disp Children",
     (ProMenubuttonAction)UserChildDisp, NULL, 0);
  ERROR_CHECK( "UserGeometrySetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGGeometry","-Disp Hole Surf",
     (ProMenubuttonAction)UserHoleSrfDisp, NULL, 0);
  ERROR_CHECK( "UserGeometrySetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGGeometry","-Rename Surf",
     (ProMenubuttonAction)UserSurfRename, NULL, 0);
  ERROR_CHECK( "UserGeometrySetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGGeometry","-Interference Chck",
     (ProMenubuttonAction)UserInterfChckSetup, NULL, calling_menu);
  ERROR_CHECK( "UserGeometrySetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGGeometry","-Surf Area",
     (ProMenubuttonAction)UserSurfArea, NULL, 0);
  ERROR_CHECK( "UserGeometrySetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGGeometry","-Curve Length",
     (ProMenubuttonAction)UserCurveLength, NULL, 0);
  ERROR_CHECK( "UserGeometrySetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGGeometry","-Done/Return",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserGeometrySetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGGeometry","UGGeometry",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserGeometrySetup", "ProMenubuttonActionSet", status );

  status = ProMenuPush();
  ERROR_CHECK( "UserGeometrySetup", "ProMenuPush", status );
  
  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGGeometry", &menu_id);
  ERROR_CHECK( "UserGeometrySetup", "ProMenuCreate", status );

  if (calling_menu != PRO_MODE_PART)
  {
    status = ProMenubuttonDeactivate("UGGeometry","-Disp Hole Surf");
    ERROR_CHECK("UserGeometrySetup","ProMenubuttonDeactivate",status );
  }

  status = ProMenuProcess("UGGeometry", &action);
  ERROR_CHECK( "UserGeometrySetup", "ProMenuProcess", status );


  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserInterfChckSetup()
Purpose  : Set up the Interference Checking Menu
\*====================================================================*/
int UserInterfChckSetup(void * arg1, int calling_menu)
{
  int menu_id, action, status;

  status = ProMenuFileRegister("UGINTERFCHCK", "uginterf.mnu", &menu_id);
  ERROR_CHECK( "UserInterfChckSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGINTERFCHCK","-Srf Clearance",
     (ProMenubuttonAction)user_surf_clear, NULL, 0);
  ERROR_CHECK( "UserInterfChckSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGINTERFCHCK","-Crit Dist",
     (ProMenubuttonAction)user_dist_manifolds, NULL, 0);
  ERROR_CHECK( "UserInterfChckSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGINTERFCHCK","-Part Interf",
     (ProMenubuttonAction)user_part_interference, NULL, 0);
  ERROR_CHECK( "UserInterfChckSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGINTERFCHCK","-Global Interf",
     (ProMenubuttonAction)user_global_interference, NULL, 0);
  ERROR_CHECK( "UserInterfChckSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGINTERFCHCK", "-Done/Return", 
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL,0);
  ERROR_CHECK( "UserInterfChckSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGINTERFCHCK", "UGINTERFCHCK",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserInterfChckSetup", "ProMenubuttonActionSet", status );

  status = ProMenuPush();
  ERROR_CHECK( "UserInterfChckSetup", "ProMenuPush", status );

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGINTERFCHCK", &menu_id);
  ERROR_CHECK( "UserInterfChckSetup", "ProMenuCreate", status );

  if (calling_menu != PRO_MODE_ASSEMBLY)
  {
	status = ProMenubuttonDeactivate("UGINTERFCHCK","-Part Interf");
	ERROR_CHECK( "UserInterfChckSetup", "ProMenubuttonDeactivate", status );

	status = ProMenubuttonDeactivate("UGINTERFCHCK","-Global Interf");
        ERROR_CHECK( "UserInterfChckSetup", "ProMenubuttonDeactivate", status );
  }

  status = ProMenuProcess("UGINTERFCHCK", &action);
  ERROR_CHECK( "UserInterfChckSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserFeatCreatSetup()
Purpose  : Set up the Feature Creation Menu
\*====================================================================*/
int UserFeatCreatSetup(void * arg1, int calling_menu)
{
  int menu_id, action, status;
 
  status = ProMenuFileRegister("UGFeatCreate", "ugfeatcrt.mnu", &menu_id);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Datum Plane",
     (ProMenubuttonAction)UserDtmPlaneSetup, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Section",
     (ProMenubuttonAction)UserSectionSetup, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-General Csys",
     (ProMenubuttonAction)ProDemoGeneralCsysCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-General Point",
     (ProMenubuttonAction)ProDemoGeneralPointCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Sketched Point",
     (ProMenubuttonAction)ProDemoSketchedPointCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Offset Point",
     (ProMenubuttonAction)ProDemoOffsetPointCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Field Point",
     (ProMenubuttonAction)ProDemoFieldPointCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Sketched Curve", 
     (ProMenubuttonAction)ProDemoSketchedCurveCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Datum Axis", 
     (ProMenubuttonAction)ProDemoDatumAxisCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-First Swept Protr",
     (ProMenubuttonAction)UgBaseSweepProtrCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

    status = ProMenubuttonActionSet("UGFeatCreate","-Creo Sweep",
     (ProMenubuttonAction)UgCreoSweepCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Swept Protr",
     (ProMenubuttonAction)UgSweepProtrCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-First Feature",
     (ProMenubuttonAction)UgSktFirstFeatureCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-First Feature Rev",
     (ProMenubuttonAction)UgSktFirstFeatureRevCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Extr Protr API",
     (ProMenubuttonAction)ProDemoBaseExtrudeProtrCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Extr Protr Conv",
     (ProMenubuttonAction)UserSktExtrusionProtrusion, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Extr Protr Ext Skt",
     (ProMenubuttonAction)UserSktExtrusionProtrusionExtSkt, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Extr Cut Conv",
     (ProMenubuttonAction)UserSktExtrusionCut, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

   status = ProMenubuttonActionSet("UGFeatCreate","-Extr Thin Conv",
     (ProMenubuttonAction)UserSktExtrusionThin, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

    status = ProMenubuttonActionSet("UGFeatCreate","-Extr Surf Conv",
     (ProMenubuttonAction)UserSktExtrusionSurfaceCapped, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

    status = ProMenubuttonActionSet("UGFeatCreate","-Extr SurfTrim Conv",
     (ProMenubuttonAction)UserSktExtrusionSurfaceTrim, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Rev Protr Conv",
     (ProMenubuttonAction)UserSktRevolveProtrusion, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

 status = ProMenubuttonActionSet("UGFeatCreate","-Rev ThinCut Conv",
     (ProMenubuttonAction)UserSktRevolveThinCut, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Rev Protr Ext Skt",
     (ProMenubuttonAction)UserSktRevolveProtrusionExtSkt, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

   status = ProMenubuttonActionSet("UGFeatCreate","-Rev Surface Conv",
     (ProMenubuttonAction)UserSktRevolveSurface, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Straight Hole",
     (ProMenubuttonAction)ProDemoHoleCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Edge Round",
     (ProMenubuttonAction)UserEdgeRoundCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Edge Chamfer",
     (ProMenubuttonAction)UserEdgeChamferCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Simple Draft",
     (ProMenubuttonAction)UserSimpleDraftCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Simple Draft InterCollect",
     (ProMenubuttonAction)UserIntcollectionDraftCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Simple Draft OA",
     (ProMenubuttonAction)UserOADraftCreate, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFeatCreate","-Remove Surface",
     (ProMenubuttonAction)FeatRemoveSurfExample, NULL, 0);
  ERROR_CHECK( "FeatRemoveSurfExample", "ProMenubuttonActionSet", status );
  
  status = ProMenubuttonActionSet("UGFeatCreate","-Flexible Modelling",
	(ProMenubuttonAction)CreateCascadeMenu,NULL,0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );
  status = ProMenubuttonActionSet("UGFeatCreate", "-Done/Return",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL,0);
       ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );
    
  status = ProMenubuttonActionSet("UGFeatCreate", "UGFeatCreate",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenubuttonActionSet", status );
  
  status = ProMenuPush();
  ERROR_CHECK( "UserSktFeatSetup", "ProMenuPush", status );

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGFeatCreate", &menu_id);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenuCreate", status );
  
  if (calling_menu == PRO_MODE_UNUSED)
  {
        status = ProMenubuttonDeactivate("UGFeatCreate","-General Csys");
        ERROR_CHECK( "UserFeatCreatSetup", "ProMenubuttonDeactivate", status );

        status = ProMenubuttonDeactivate("UGFeatCreate","-General Point");
        ERROR_CHECK( "UserFeatCreatSetup", "ProMenubuttonDeactivate", status );

        status = ProMenubuttonDeactivate("UGFeatCreate","-Sketched Point");
        ERROR_CHECK( "UserFeatCreatSetup", "ProMenubuttonDeactivate", status );

        status = ProMenubuttonDeactivate("UGFeatCreate","-Offset Point");
        ERROR_CHECK( "UserFeatCreatSetup", "ProMenubuttonDeactivate", status );

        status = ProMenubuttonDeactivate("UGFeatCreate","-Field Point");
        ERROR_CHECK( "UserFeatCreatSetup", "ProMenubuttonDeactivate", status );

        status = ProMenubuttonDeactivate("UGFeatCreate","-Sketched Curve");
        ERROR_CHECK( "UserFeatCreatSetup", "ProMenubuttonDeactivate", status );

        status = ProMenubuttonDeactivate("UGFeatCreate","-Datum Axis");
        ERROR_CHECK( "UserFeatCreatSetup", "ProMenubuttonDeactivate", status );

        status = ProMenubuttonDeactivate("UGFeatCreate","-Straight Hole");
        ERROR_CHECK( "UserFeatCreatSetup", "ProMenubuttonDeactivate", status );

        status = ProMenubuttonDeactivate("UGFeatCreate","-Datum Plane");
        ERROR_CHECK( "UserFeatCreatSetup", "ProMenubuttonDeactivate", status );

        status = ProMenubuttonDeactivate("UGFeatCreate","-Extr Protr API");
        ERROR_CHECK( "UserFeatCreatSetup", "ProMenubuttonDeactivate", status );

        status = ProMenubuttonDeactivate("UGFeatCreate","-Extr Protr Conv");
        ERROR_CHECK( "UserFeatCreatSetup", "ProMenubuttonDeactivate", status );

  }

  status = ProMenuProcess("UGFeatCreate", &action);
  ERROR_CHECK( "UserSktFeatSetup", "ProMenuProcess", status );
  
  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserDtmPlaneSetup()
Purpose  : Set up the Datum Plane Creation Menu
\*====================================================================*/
int UserDtmPlaneSetup()
{
  int menu_id, action, status;

  status = ProMenuFileRegister("UGDTMCREATE", "ugdtm.mnu", &menu_id);
  ERROR_CHECK( "UserDtmPlaneSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGDTMCREATE","-Create Dtm Plane",
     (ProMenubuttonAction)UserDatumRefs, NULL, 0);
  ERROR_CHECK( "UserDtmPlaneSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDTMCREATE", "-Done/Return",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL,0);
  ERROR_CHECK( "UserDtmPlaneSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDTMCREATE", "UGDTMCREATE",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserDtmPlaneSetup", "ProMenubuttonActionSet", status );

  status = ProMenuPush();
  ERROR_CHECK( "UserDtmPlaneSetup", "ProMenuPush", status );

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGDTMCREATE", &menu_id);
  ERROR_CHECK( "UserDtmPlaneSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGDTMCREATE", &action);
  ERROR_CHECK( "UserDtmPlaneSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserSectionSetup()
Purpose  : Set up the Sketcher Menu
\*====================================================================*/
int UserSectionSetup()
{
  int menu_id, action, status;

  status = ProMenuFileRegister("UGSECTION", "ugsection.mnu", &menu_id);
  ERROR_CHECK( "UserSectionSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGSECTION","-Create SecModel",
     (ProMenubuttonAction)UserSectionCreateExample, NULL, 0);
  ERROR_CHECK( "UserSectionSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGSECTION","-Replace Section",
     (ProMenubuttonAction)UserSectionReplace, NULL, 0);
  ERROR_CHECK( "UserSectionReplace", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGSECTION","-Add Spline Dimension",
     (ProMenubuttonAction)UserAddSplineDimension, NULL, 0);
  ERROR_CHECK( "UserAddSplineDimension", "ProMenubuttonActionSet", status );  

  status = ProMenubuttonActionSet("UGSECTION", "-Done/Return",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL,0);
  ERROR_CHECK( "UserSectionSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGSECTION", "UGSECTION",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserSectionSetup", "ProMenubuttonActionSet", status );

  status = ProMenuPush();
  ERROR_CHECK( "UserSectionSetup", "ProMenuPush", status );

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGSECTION", &menu_id);
  ERROR_CHECK( "UserSectionSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGSECTION", &action);
  ERROR_CHECK( "UserSectionSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}


/*====================================================================*
Function : UserLayerSetup()
Purpose  : Set up the Layer menu or the User's guide demo
\*====================================================================*/
int UserLayerSetup(void * user_data, int calling_menu)
{
  int menu_id, action, status;

  status = ProMenuFileRegister("UGLayer", "uglayer.mnu", &menu_id);
  ERROR_CHECK( "UserLayerSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGLayer","-LayerCreate",
     (ProMenubuttonAction)UserLayerCreate, NULL, 0);
  ERROR_CHECK( "UserLayerSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGLayer","-LayerBlank",
     (ProMenubuttonAction)UserBlank, NULL, 0);
  ERROR_CHECK( "UserLayerSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGLayer","-LayerScan",
     (ProMenubuttonAction)UserScanLayers, NULL, 0);
  ERROR_CHECK( "UserLayerSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGLayer","-Done/Return",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserLayerSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGLayer","UGLayer",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserLayerSetup", "ProMenubuttonActionSet", status );

  status = ProMenuPush();
  ERROR_CHECK( "UserLayerSetup", "ProMenuPush", status );

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGLayer", &menu_id);
  ERROR_CHECK( "UserLayerSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGLayer", &action); 
  ERROR_CHECK( "UserLayerSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}


/*====================================================================*
Function : UserParamSetup()
Purpose  : Set up the Parameters menu or the User's guide demo
\*====================================================================*/
int UserParamSetup(void * user_data, int calling_menu)
{
  int menu_id, action, status;

  status = ProMenuFileRegister("UGParameter", "ugparam.mnu", &menu_id);
  ERROR_CHECK( "UserParamSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGParameter","-Label Feature",
     (ProMenubuttonAction)UserLabelFeature, NULL, 0);
  ERROR_CHECK( "UserParamSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGParameter","-Done/Return",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserParamSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGParameter","UGParameter",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserParamSetup", "ProMenubuttonActionSet", status );

  status = ProMenuPush();
  ERROR_CHECK( "UserParamSetup", "ProMenuPush", status );

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGParameter", &menu_id);
  ERROR_CHECK( "UserParamSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGParameter", &action);
  ERROR_CHECK( "UserParamSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserDimensionsSetup()
Purpose  : Set up the Menu for Dimensions
\*====================================================================*/
ProError UserDimensionsSetup()
{
  int menu_id, action, status;
  ProMdl model;

  status = ProMenuFileRegister("UGDIMS", "ugdims.mnu", &menu_id);
  ERROR_CHECK( "UserDimensionsSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGDIMS","-Change Dims",
          (ProMenubuttonAction)UserDimensionChange, NULL, 0);
  ERROR_CHECK( "UserDimensionsSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDIMS","-Rounded Display of Dims",
          (ProMenubuttonAction)UserDimDisplayRounded, NULL, 0);
  ERROR_CHECK( "UserDimensionsSetup", "ProMenubuttonActionSet", status );
  
  status = ProMenubuttonActionSet("UGDIMS","-Find Parallel Dims",
          (ProMenubuttonAction)UserDimensionsByAxisDirectionShow, NULL, 0);
  ERROR_CHECK( "UserDimensionsSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDIMS", "-Done/Return",
                                  UserMenuDeleteAndPop, NULL,0);
  ERROR_CHECK( "UserDimensionsSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDIMS", "UGDIMS",
                                  UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserDimensionsSetup", "ProMenubuttonActionSet", status );

  status = ProMenuPush();
  ERROR_CHECK( "UserDimensionsSetup", "ProMenuPush", status );

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGDIMS", &menu_id);
  ERROR_CHECK( "UserDimensionsSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGDIMS", &action);
  ERROR_CHECK( "UserDimensionsSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserFamTabSetup()
Purpose  : Set up the Family Tables Menu
\*====================================================================*/
int UserFamTabSetup()
{
  int menu_id, action, status;
  ProMdl model;

  status = ProMenuFileRegister("UGFAMTAB", "ugfamtab.mnu", &menu_id);
  ERROR_CHECK( "UserFamTabSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGFAMTAB","-Inst Comp",
     (ProMenubuttonAction)user_Family_Diffs, NULL, 0);
  ERROR_CHECK( "UserFamTabSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFAMTAB", "-Done/Return",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL,0);
  ERROR_CHECK( "UserFamTabSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGFAMTAB", "UGFAMTAB",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserFamTabSetup", "ProMenubuttonActionSet", status );

  status = ProMenuPush();
  ERROR_CHECK( "UserFamTabSetup", "ProMenuPush", status );

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGFAMTAB", &menu_id);
  ERROR_CHECK( "UserFamTabSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGFAMTAB", &action);
  ERROR_CHECK( "UserFamTabSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

/*====================================================================*\
Function : UserExtObjSetup()
Purpose  : Set up the External Objects Menu
\*====================================================================*/
int UserExtObjSetup()
{
  int menu_id, action, status;

  status = ProMenuFileRegister("UGEXTOBJ", "ugextobj.mnu", &menu_id);
  ERROR_CHECK( "UserExtObjSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGEXTOBJ","-Create",
     (ProMenubuttonAction)UserExtobjCreate, NULL, 0);
  ERROR_CHECK( "UserExtObjSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGEXTOBJ", "-Done/Return",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL,0);
  ERROR_CHECK( "UserExtObjSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGEXTOBJ", "UGEXTOBJ",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserExtObjSetup", "ProMenubuttonActionSet", status );

  status = ProMenuPush();
  ERROR_CHECK( "UserExtObjSetup", "ProMenuPush", status );

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGEXTOBJ", &menu_id);
  ERROR_CHECK( "UserExtObjSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGEXTOBJ", &action);
  ERROR_CHECK( "UserExtObjSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

/*====================================================================*\
Function : UserViewsSetup()
Purpose  : Set up the Views Menu
\*====================================================================*/
ProError UserViewsSetup()
{
  int menu_id;
  int action;
  ProError status;

  ProError UserViews();

/*---------------------------------------------------------------------------*\
  read in menu file
\*---------------------------------------------------------------------------*/
  status=ProMenuFileRegister("Views","ugviews.mnu",&menu_id);
  ERROR_CHECK("UserViewsSetup","ProMenuFileRegister",status);
/*---------------------------------------------------------------------------*\
  attach actions to menu
\*---------------------------------------------------------------------------*/
  status=ProMenubuttonActionSet("Views","Views",
      (ProMenubuttonAction)UserMenuDeleteAndPop,NULL,0);
  ERROR_CHECK("UserViewsSetup","ProMenubuttonActionSet(Views)",status);

  status=ProMenubuttonActionSet("Views","SaveViews",
      (ProMenubuttonAction)UserViews,NULL,0);
  ERROR_CHECK("UserViewsSetup","ProMenubuttonActionSet(SaveViews)",status);

  status=ProMenubuttonActionSet("Views","Done/Return",
      (ProMenubuttonAction)UserMenuDeleteAndPop,NULL,0);
  ERROR_CHECK("UserViewsSetup","ProMenubuttonActionSet(SaveViews)",status);

/*---------------------------------------------------------------------------*\
  put menu on screen
\*---------------------------------------------------------------------------*/

  status = ProMenuPush();
  ERROR_CHECK( "UserViewsSetup", "ProMenuPush", status );

  status=ProMenuCreate(PROMENUTYPE_MAIN,"Views",&menu_id);
  ERROR_CHECK("UserViewsSetup","ProMenuCreate",status);

/*---------------------------------------------------------------------------*\
  activate menu
\*---------------------------------------------------------------------------*/
  status=ProMenuProcess("", &action);
  ERROR_CHECK("UserViewsSetup","ProMenuProcess",status);

  return( status );
}

/*====================================================================*
Function : UserRelationsSetup()
Purpose  : Set up the Relations menu or the User's guide demo
\*====================================================================*/
int UserRelationsSetup(void * user_data, int calling_menu)
{
  int menu_id, action, status;
 
  status = ProMenuFileRegister("UGRelations","ugrels.mnu",  &menu_id);
  ERROR_CHECK( "UserRelationsSetup", "ProMenuFileRegister", status );
 
  status = ProMenubuttonActionSet("UGRelations","-Edit Relations",
     (ProMenubuttonAction)UserRelsEdit, NULL, 0);
  ERROR_CHECK( "UserRelationsSetup", "ProMenubuttonActionSet", status );
 
  status = ProMenubuttonActionSet("UGRelations","-Done Return",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserRelationsSetup", "ProMenubuttonActionSet", status );
 
  status = ProMenubuttonActionSet("UGRelations","UGRelations",
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserRelationsSetup", "ProMenubuttonActionSet", status );
 
  status = ProMenuPush();
  ERROR_CHECK( "UserRelationsSetup", "ProMenuPush", status );
 
  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGRelations", &menu_id);
  ERROR_CHECK( "UserRelationsSetup", "ProMenuCreate", status );
 
  status = ProMenuProcess("UGRelations", &action);
  ERROR_CHECK( "UserRelationsSetup", "ProMenuProcess", status );
 
  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserMenuDeleteAndPop()
Purpose  : Deletes the current menu and pops up its parent
\*====================================================================*/
int UserMenuDeleteAndPop()
{
  int status;

  status = ProMenuDelete();
  ERROR_CHECK( "UserMenuDeleteAndPop", "ProMenuDelete", status );

  status = ProMenuPop();
  ERROR_CHECK( "UserMenuDeleteAndPop", "ProMenuPop", status );

  return (PRO_TK_NO_ERROR);
}
int CreateCascadeMenu()
{

ProError status;
int menu_id,action;

status = ProMenuFileRegister("UGFlexModel","ugflex.mnu",  &menu_id);
ERROR_CHECK( "CreateCascadeMenu", "ProMenuFileRegister", status );

status = ProMenubuttonActionSet("UGFlexModel","-Flex On Surface",
(ProMenubuttonAction)UserFlexModelCreateonSurface,NULL,0);
ERROR_CHECK( "CreateCascadeMenu", "ProMenubuttonActionSet", status );

status = ProMenubuttonActionSet("UGFlexModel","-Flex On Edge",
	(ProMenubuttonAction)UserFlexModelCreateonEdge,NULL,0);
ERROR_CHECK( "CreateCascadeMenu", "ProMenubuttonActionSet", status );
	
status = ProMenubuttonActionSet("UGFlexModel","-Flex Free",
	(ProMenubuttonAction)UserFlexModelCreateFree,NULL,0);
ERROR_CHECK( "CreateCascadeMenu", "ProMenubuttonActionSet", status );
 
status = ProMenubuttonActionSet("UGFlexModel", "-Done/Return", 
     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL,0);
ERROR_CHECK( "CreateCascadeMenu", "ProMenubuttonActionSet", status );
  
status = ProMenuPush();
ERROR_CHECK( "CreateCascadeMenu", "ProMenuPush", status ); 
 
status = ProMenuCreate(PROMENUTYPE_MAIN,"UGFlexModel",&menu_id);
ERROR_CHECK( "CreateCascadeMenu", "ProMenuCreate", status );
    
status = ProMenuProcess("UGFlexModel", &action);
ERROR_CHECK( "CreateCascadeMenu", "ProMenuProcess", status );
    
  
return PRO_TK_NO_ERROR;
}