/*
	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>


/*------------------------- External Data ----------------------------*/
extern int UserMenuDeleteAndPop();
extern int UserSheetsList();
extern int UserSheetAdd();
extern int UserSheetCopy();
extern int UserSheetDelete();
extern int UserModelAdd();
extern int UserModelDelete();
extern int UserViewsList();
extern int UserNoteCreate();
extern int UserNotesColor();
extern int UserLineCreate();
extern int UserGroupCreate();
extern int UserSymbDefCreate();
extern int UserSymbInstCopy();
extern int UserTableColorChange();
extern int UserMenuDeleteAndPop();
extern int UserFamTabSetup();
extern int UserPlotSetup();
extern int UserTreeExpand();
extern int UserTreeCollapse();
extern int UserTreeRefresh();
extern int UgDwgPublishContext_step();
extern int UgDwgPublishContext_iges();
extern int UgDwgPublishContext_dxf();
extern int UgDwgPublishContext_medusa();
extern int UgDwgPublishContext_cgm();
extern int UgDwgPublishContext_tiff();
extern ProError UserVisibleAreaSetup(); 
/*---------------------- Function Prototypes -------------------------*/
int UserDrawingSetup();
int UserSheetsSetup();
int UserModelsSetup();
int UserDtlItemSetup();
int UserTablesSetup();
int UserNotesSetup();
int UserDrawingTreeSetup();
int UserPublishSetup();

/*====================================================================*
Function : UserDrawingSetup()
Purpose  : Set up the Drawing menu of the User's guide demo
\*====================================================================*/
int UserDrawingSetup()
{
  int menu_id, action;
  ProError status;

  status = ProMenuFileRegister("UGDrawing", "ugdwg.mnu", &menu_id);
  ERROR_CHECK( "UserDrawingSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGDrawing", "-Fundamentals",
                                  UserFundSetup, NULL, PRO_MODE_DRAWING);
  ERROR_CHECK( "UserDrawingSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDrawing", "-Sheets",
                                  UserSheetsSetup, NULL, PRO_MODE_DRAWING);
  ERROR_CHECK( "UserDrawingSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDrawing", "-Models",
                                  UserModelsSetup, NULL, PRO_MODE_DRAWING);
  ERROR_CHECK( "UserDrawingSetup", "ProMenubuttonActionSet", status );
  status = ProMenubuttonActionSet("UGDrawing", "-Detail Items",
                                  UserDtlItemSetup, NULL,PRO_MODE_DRAWING );
  ERROR_CHECK( "UserDrawingSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDrawing", "-Tables",
                                  UserTablesSetup, NULL, PRO_MODE_DRAWING);
  ERROR_CHECK( "UserDrawingSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDrawing","-Family Tables",
     		(ProMenubuttonAction)UserFamTabSetup, NULL,0);
  ERROR_CHECK("UserDrawingSetup","ProMenubuttonActionSet()",status);

  status = ProMenubuttonActionSet("UGDrawing","-Plot",
     (ProMenubuttonAction)UserPlotSetup, NULL,0);
  ERROR_CHECK("UserDrawingSetup","ProMenubuttonActionSet()",status);
  
  status = ProMenubuttonActionSet("UGDrawing","-Drawing Tree",
     (ProMenubuttonAction)UserDrawingTreeSetup, NULL,0);
  ERROR_CHECK("UserDrawingSetup","ProMenubuttonActionSet()",status);

  status = ProMenubuttonActionSet("UGDrawing","-Visible Area",
     		(ProMenubuttonAction)UserVisibleAreaSetup, NULL, 0);
  ERROR_CHECK("UserDrawingSetup","ProMenubuttonActionSet()",status);

  status = ProMenubuttonActionSet("UGDrawing","-Publish",
     (ProMenubuttonAction)UserPublishSetup, NULL,0);
  ERROR_CHECK("UserPublishSetup","ProMenubuttonActionSet()",status);
  
  status = ProMenubuttonActionSet("UGDrawing", "-Done/Return",
                     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserDrawingSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDrawing", "UGDrawing",
                     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserDrawingSetup", "ProMenubuttonActionSet", status );

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

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGDrawing", &menu_id);
  ERROR_CHECK( "UserDrawingSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGDrawing", &action);
  ERROR_CHECK( "UserDrawingSetup", "ProMenuProcess", status );

  return (PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserSheetsSetup()
Purpose  : Setup the Sheets menu of the User Guide example
\*====================================================================*/
int UserSheetsSetup()
{
  int menu_id, action;
  ProError status;

  status = ProMenuFileRegister("UGSheets", "ugsheets.mnu", &menu_id);
  ERROR_CHECK( "UserSheetsSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGSheets","-List Sheets",
                                  UserSheetsList, NULL, 0);
  ERROR_CHECK( "UserSheetsSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGSheets","-Add Sheet",
                                  UserSheetAdd, NULL, 0);
  ERROR_CHECK( "UserSheetsSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGSheets","-Copy Sheet",
                                  UserSheetCopy, NULL, 0);
  ERROR_CHECK( "UserSheetsSetup", "ProMenubuttonActionSet", status );
  
  status = ProMenubuttonActionSet("UGSheets","-Delete Sheet",
                                  UserSheetDelete, NULL, 0);
  ERROR_CHECK( "UserSheetsSetup", "ProMenubuttonActionSet", status );

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

  status = ProMenubuttonActionSet("UGSheets","UGSheets",
                      (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserSheetsSetup", "ProMenubuttonActionSet", status );

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

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGSheets", &menu_id);
  ERROR_CHECK( "UserSheetsSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGSheets", &action);
  ERROR_CHECK( "UserSheetsSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserModelsSetup()
Purpose  : Setup the Models menu of the User Guide example
\*====================================================================*/
int UserModelsSetup()
{
  int menu_id, action;
  ProError status;

  status = ProMenuFileRegister("UGModels", "ugmodels.mnu", &menu_id);
  ERROR_CHECK( "UserModelsSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGModels","-Add Model",
                                  UserModelAdd, NULL, 0);
  ERROR_CHECK( "UserModelsSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGModels","-Delete Model",
                                  UserModelDelete, NULL, 0);
  ERROR_CHECK( "UserModelsSetup", "ProMenubuttonActionSet", status );

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

  status = ProMenubuttonActionSet("UGModels","UGModels",
                     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserModelsSetup", "ProMenubuttonActionSet", status );

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

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGModels", &menu_id);
  ERROR_CHECK( "UserModelsSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGModels", &action);
  ERROR_CHECK( "UserModelsSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

int UserDtlItemSetup()
{
  int menu_id, action;
  ProError status;

  status = ProMenuFileRegister("UGDtlItem", "ugdtlitem.mnu", &menu_id);
  ERROR_CHECK( "UserDtlItemSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGDtlItem","-Notes",
                                  UserNotesSetup, NULL, 0);
  ERROR_CHECK( "UserDtlItemSetup", "ProMenubuttonActionSet", status );
  status = ProMenubuttonActionSet("UGDtlItem","-Done/Return",
                    (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserDtlItemSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDtlItem","UGDtlItem",
                    (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserDtlItemSetup", "ProMenubuttonActionSet", status );

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

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGDtlItem", &menu_id);
  ERROR_CHECK( "UserDtlItemSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGDtlItem", &action);
  ERROR_CHECK( "UserDtlItemSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserNotesSetup()
Purpose  : Setup the Notes menu of the User Guide example
\*====================================================================*/
int UserNotesSetup()
{
  int menu_id, action;
  ProError status;

  status = ProMenuFileRegister("UGNotes", "ugnotes.mnu", &menu_id);
  ERROR_CHECK( "UserNotesSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGNotes","-Create Note",
                                  UserNoteCreate, NULL, 0);
  ERROR_CHECK( "UserNotesSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGNotes","-Color Notes",
                                  UserNotesColor, NULL, 0);
  ERROR_CHECK( "UserNotesSetup", "ProMenubuttonActionSet", status );

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

  status = ProMenubuttonActionSet("UGNotes","UGNotes",
                     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserNotesSetup", "ProMenubuttonActionSet", status );

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

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGNotes", &menu_id);
  ERROR_CHECK( "UserNotesSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGNotes", &action);
  ERROR_CHECK( "UserNotesSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

int UserTablesSetup()
{
  int menu_id, action;
  ProError status;

  status = ProMenuFileRegister("UGTable", "ugtable.mnu", &menu_id);
  ERROR_CHECK( "UserTablesSetup", "ProMenuFileRegister", status );
  status = ProMenubuttonActionSet("UGTable","-Change Color",
                                  UserTableColorChange, NULL, 0);
  ERROR_CHECK( "UserTablesSetup", "ProMenubuttonActionSet", status );

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

  status = ProMenubuttonActionSet("UGTable","UGTable",
                   (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserTablesSetup", "ProMenubuttonActionSet", status );

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

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGTable", &menu_id);
  ERROR_CHECK( "UserTablesSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGTable", &action);
  ERROR_CHECK( "UserTablesSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}


/*====================================================================*
Function : UserDrawingTreeSetup()
Purpose  : Setup the Drawing Tree menu of the User Guide example
\*====================================================================*/
int UserDrawingTreeSetup()
{
  int menu_id, action;
  ProError status;

  status = ProMenuFileRegister("UGDwgTree", "ugdwgtree.mnu", &menu_id);
  ERROR_CHECK( "UserDrawingTreeSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGDwgTree","-Expand",
                                  UserTreeExpand, NULL, 0);
  ERROR_CHECK( "UserDrawingTreeSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDwgTree","-Collapse",
                                  UserTreeCollapse, NULL, 0);
  ERROR_CHECK( "UserDrawingTreeSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGDwgTree","-Refresh",
                                  UserTreeRefresh, NULL, 0);
  ERROR_CHECK( "UserDrawingTreeSetup", "ProMenubuttonActionSet", status );

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

  status = ProMenubuttonActionSet("UGDwgTree","UGDwgTree",
                     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserDrawingTreeSetup", "ProMenubuttonActionSet", status );  

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

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGDwgTree", &menu_id);
  ERROR_CHECK( "UserDrawingTreeSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGDwgTree", &action);
  ERROR_CHECK( "UserDrawingTreeSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserPublishSetup()
Purpose  : Setup the Publish/Export menu of the User Guide example
\*====================================================================*/
int UserPublishSetup()
{
  int menu_id, action;
  ProError status;

  status = ProMenuFileRegister("UGPublish", "ugpublish.mnu", &menu_id);
  ERROR_CHECK( "UserPublishSetup", "ProMenuFileRegister", status );

  status = ProMenubuttonActionSet("UGPublish","-STEP",
                                  UgDwgPublishContext_step, NULL, 0);
  ERROR_CHECK( "UserPublishSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGPublish","-IGES",
                                  UgDwgPublishContext_iges, NULL, 0);
  ERROR_CHECK( "UserPublishSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGPublish","-DXF",
                                  UgDwgPublishContext_dxf, NULL, 0);
  ERROR_CHECK( "UserPublishSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGPublish","-MEDUSA",
                                  UgDwgPublishContext_medusa, NULL, 0);
  ERROR_CHECK( "UserPublishSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGPublish","-CGM",
                                  UgDwgPublishContext_cgm, NULL, 0);
  ERROR_CHECK( "UserPublishSetup", "ProMenubuttonActionSet", status );

  status = ProMenubuttonActionSet("UGPublish","-TIFF",
                                  UgDwgPublishContext_tiff, NULL, 0);
  ERROR_CHECK( "UserPublishSetup", "ProMenubuttonActionSet", status );

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

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

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGPublish", &menu_id);
  ERROR_CHECK( "UserPublishSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGPublish", &action);
  ERROR_CHECK( "UserPublishSetup", "ProMenuProcess", status );

  return(PRO_TK_NO_ERROR);
}

/*====================================================================*
Function : UserVisibleAreaSetup()
Purpose  : Setup the Visible area menu of the User Guide example
\*====================================================================*/
ProError UserVisibleAreaSetup()
{
  int menu_id, action;
  ProError status;

  status = ProMenuFileRegister("UGDwgVisibleArea", "ugdwgvisiblearea.mnu", &menu_id);
  ERROR_CHECK( "UserVisibleAreaSetup", "ProMenuFileRegister", status );

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

  status = ProMenubuttonActionSet("UGDwgVisibleArea","UGDwgVisibleArea",
                     (ProMenubuttonAction)UserMenuDeleteAndPop, NULL, 0);
  ERROR_CHECK( "UserVisibleAreaSetup", "ProMenubuttonActionSet", status );  

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

  status = ProMenuCreate(PROMENUTYPE_MAIN, "UGDwgVisibleArea", &menu_id);
  ERROR_CHECK( "UserVisibleAreaSetup", "ProMenuCreate", status );

  status = ProMenuProcess("UGDwgVisibleArea", &action);
  ERROR_CHECK( "UserVisibleAreaSetup", "ProMenuProcess", status );

  return (status);

}