/*
Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/
/*--------------------------------------------------------------------*\
Application includes
\*--------------------------------------------------------------------*/
#include <time.h>
# include <iostream>
using namespace std;
#include "TestError.h"
/*--------------------------------------------------------------------*\
Pro/Toolkit includes
\*--------------------------------------------------------------------*/
#include <ProToolkit.h>
#include <Pro2dEntdef.h>
#include <ProANSI.h>
#include <ProAnalysis.h>
#include <ProAnimate.h>
#include <ProArray.h>
#include <ProAsmcomp.h>
#include <ProAsmcomppath.h>
#include <ProAssembly.h>
#include <ProAutodrill.h>
#include <ProAxis.h>
#include <ProCabling.h>
#include <ProCavitylayout.h>
#include <ProCavlayrule.h>
#include <ProChamfer.h>
#include <ProClCmd.h>
#include <ProClcmdElem.h>
#include <ProCollect.h>
#include <ProColor.h>
#include <ProComm.h>
#include <ProConst.h>
#include <ProContour.h>
#include <ProContourdata.h>
#include <ProCopyGeom.h>
#include <ProCore.h>
#include <ProCsys.h>
#include <ProCsysdata.h>
#include <ProCurve.h>
#include <ProCurvedata.h>
#include <ProDatumdata.h>
#include <ProDimension.h>
#include <ProDisplist.h>
#include <ProDrawing.h>
#include <ProDtlattach.h>
#include <ProDtlentity.h>
#include <ProDtlgroup.h>
#include <ProDtlitem.h>
#include <ProDtlnote.h>
#include <ProDtlsymdef.h>
#include <ProDtlsyminst.h>
#include <ProDtmAxis.h>
#include <ProDtmCrv.h>
#include <ProDtmCrvSketch.h>
#include <ProDtmCsys.h>
#include <ProDtmPln.h>
#include <ProDtmPnt.h>
#include <ProDwgtable.h>
#include <ProEdge.h>
#include <ProEdgedata.h>
#include <ProElemId.h>
#include <ProElement.h>
#include <ProElempath.h>
#include <ProExpldstate.h>
#include <ProExtdata.h>
#include <ProExtobj.h>
#include <ProExtobjCB.h>
#include <ProExtobjDisp.h>
#include <ProExtobjRef.h>
#include <ProExtobjSel.h>
#include <ProExtrude.h>
#include <ProFaminstance.h>
#include <ProFamtable.h>
#include <ProFeatForm.h>
#include <ProFeatIntr.h>
#include <ProFeatType.h>
#include <ProFeature.h>
#include <ProFemMesh.h>
#include <ProFemObjects.h>
#include <ProFlatSrf.h>
#include <ProForeignCurve.h>
#include <ProGeomitem.h>
#include <ProGeomitemdata.h>
#include <ProGraphic.h>
#include <ProGroup.h>
#include <ProGtol.h>
#include <ProHardware.h>
#include <ProHole.h>
#include <ProImm.h>
#include <ProImportfeat.h>
#include <ProIntf3Dexport.h>
#include <ProIntfData.h>
#include <ProIntfimport.h>
#include <ProItemerr.h>
#include <ProJlink.h>
#include <ProLayer.h>
#include <ProMaterial.h>
#include <ProMdl.h>
#include <ProMdlChk.h>
#include <ProMenu.h>
#include <ProMenuBar.h>
#include <ProMessage.h>
#include <ProMfg.h>
#include <ProMfgdb.h>
#include <ProMfgoper.h>
#include <ProModFeat.h>
#include <ProMode.h>
#include <ProModelitem.h>
#include <ProMoldbase.h>
#include <ProNcseq.h>
#include <ProNcseqElem.h>
#include <ProNote.h>
#include <ProNotify.h>
#include <ProObjects.h>
#include <ProParameter.h>
#include <ProParamval.h>
#include <ProPart.h>
#include <ProPattern.h>
#include <ProPecktable.h>
#include <ProPiping.h>
#include <ProPoint.h>
#include <ProPrint.h>
#include <ProProcstep.h>
#include <ProQuilt.h>
#include <ProQuiltdata.h>
#include <ProRefInfo.h>
#include <ProRelSet.h>
#include <ProReplace.h>
#include <ProRevolve.h>
#include <ProRib.h>
#include <ProRmdt.h>
#include <ProRule.h>
#include <ProScope.h>
#include <ProSecConstr.h>
#include <ProSecdim.h>
#include <ProSecdimType.h>
#include <ProSecerror.h>
#include <ProSection.h>
#include <ProSelection.h>
#include <ProSheetmetal.h>
#include <ProShrinkwrap.h>
#include <ProSimprep.h>
#include <ProSimprepdata.h>
#include <ProSizeConst.h>
#include <ProSkeleton.h>
#include <ProSolid.h>
#include <ProStdSection.h>
#include <ProSurface.h>
#include <ProSurfacedata.h>
#include <ProSweep.h>
#include <ProTool.h>
#include <ProToolElem.h>
#include <ProToolinput.h>
#include <ProToolkitDll.h>
#include <ProUI.h>
#include <ProUICascadebutton.h>
#include <ProUICheckbutton.h>
#include <ProUICmd.h>
#include <ProUIDialog.h>
#include <ProUIInputpanel.h>
#include <ProUILabel.h>
#include <ProUILayout.h>
#include <ProUIList.h>
#include <ProUIMenubar.h>
#include <ProUIMenupane.h>
#include <ProUIMessage.h>
#include <ProUIOptionmenu.h>
#include <ProUIProgressbar.h>
#include <ProUIPushbutton.h>
#include <ProUIRadiogroup.h>
#include <ProUISlider.h>
#include <ProUISpinbox.h>
#include <ProUITab.h>
#include <ProUITable.h>
#include <ProUITextarea.h>
#include <ProUIThumbwheel.h>
#include <ProUdf.h>
#include <ProUtil.h>
#include <ProUvStat.h>
#include <ProValue.h>
#include <ProVerstamp.h>
#include <ProView.h>
#include <ProWcell.h>
#include <ProWchar.h>
#include <ProWeld.h>
#include <ProWindows.h>
#include <ProWorkspace.h>
#include <ProWstring.h>
#include <ProXsec.h>
#include <ProTKRunTime.h>
/*--------------------------------------------------------------------*\
Application global/external data
\*--------------------------------------------------------------------*/
static wchar_t MSGFIL[] = {'m','s','g','_','u','s','e','r','.','t','x','t','\0'};
static char revcode[PRO_LINE_SIZE];
/* Declare function */
ProError ProTestInstallationCheck();
ProError ProTestInstallationURLCheck();
ProError ProTestDialogCreate ( ProBoolean is_successful );
static uiCmdAccessState TestAccessDefault(uiCmdAccessMode access_mode)
{
return (ACCESS_AVAILABLE);
}
/*===========================================================================*\
Function : main
Purpose : Test the ProToolkitMain() function. main is optional function.
\*===========================================================================*/
int main(int argc, char **argv)
{
cerr << endl << "\tWelcome to Pro/TOOLKIT - The \"pt_install_test\" program" << endl;
ProToolkitMain(argc, argv);
return(0);
}
/*====================================================================*\
FUNCTION : user_initialize()
PURPOSE : Pro/DEVELOP standard initialize - define menu button
\*====================================================================*/
extern "C" int user_initialize(
int argc,
char *argv[],
char *version,
char *build,
wchar_t errbuf[80])
{
char cbuff1[PRO_PATH_SIZE], cbuff2[PRO_PATH_SIZE];
char astr1[PRO_LINE_SIZE];
int i, menu_id;
ProPath wbuff1, wbuff2;
ProError status;
uiCmdCmdId cmd_id;
ProUITranslationFilesEnable();
/*---------------------------------------------------------------------*\
Loging file open.
\*---------------------------------------------------------------------*/
if ( argc > 4 )
ProTestErrlogOpen(argv[4], version, build);
else
ProTestErrlogOpen("pt_install_cxx", version, build);
/*---------------------------------------------------------------------*\
First confirm the size of wchar_t
\*---------------------------------------------------------------------*/
status = ProWcharSizeVerify (sizeof (wchar_t), &i);
TEST_CALL_REPORT("ProWcharSizeVerify", "user_initialize",
status, status != PRO_TK_NO_ERROR);
if ( status != PRO_TK_NO_ERROR || (i != sizeof (wchar_t)) )
{
ProTKSprintf(astr1,"ERROR wchar_t Incorrect size (%d). Should be: %d",
sizeof(wchar_t), i );
status = ProMessageDisplay(MSGFIL, "USER %0s", astr1);
TEST_CALL_REPORT("ProMessageDisplay", "user_initialize",
status, status != PRO_TK_NO_ERROR);
cout << astr1 << endl;
ProStringToWstring(errbuf, astr1);
return(-1);
}
/*---------------------------------------------------------------------*\
Add new button to the menu bar
\*---------------------------------------------------------------------*/
ProTKSprintf(revcode, "%s - %s", version, build);
/* Load any menu files into memory */
status = ProCmdActionAdd("-Install Test",
(uiCmdCmdActFn)ProTestInstallationCheck,
uiProe2ndImmediate, TestAccessDefault,
PRO_B_TRUE, PRO_B_TRUE, &cmd_id);
TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
status, status != PRO_TK_NO_ERROR);
status = ProMenubarmenuPushbuttonAdd(
"File", "-Install Test", "-Install Test Label", "Install Test Help",
"File.psh_rename", PRO_B_TRUE, cmd_id, MSGFIL);
TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
status, status != PRO_TK_NO_ERROR);
/*---------------------------------------------------------------------*\
New Button for URL in Embedded Browser
\*---------------------------------------------------------------------*/
status = ProCmdActionAdd("TOOLKIT Compilers",
(uiCmdCmdActFn)ProTestInstallationURLCheck,
uiProe2ndImmediate, TestAccessDefault,
PRO_B_TRUE, PRO_B_TRUE, &cmd_id);
TEST_CALL_REPORT("ProCmdActionAdd", "user_initialize",
status, status != PRO_TK_NO_ERROR);
status = ProMenubarmenuPushbuttonAdd( "Help",
"TOOLKIT Compilers", "Creo Parametric TOOLKIT Compilers Label", "Creo Parametric TOOLKIT Compilers Help",
NULL, PRO_B_TRUE, /* Always add at the bottom of the Help Menubar */
cmd_id, MSGFIL);
TEST_CALL_REPORT("ProMenubarmenuPushbuttonAdd", "user_initialize",
status, status != PRO_TK_NO_ERROR);
/*---------------------------------------------------------------------*\
Print the protk.dat info
\*---------------------------------------------------------------------*/
status = ProToolkitApplExecPathGet(wbuff1);
TEST_CALL_REPORT("ProToolkitApplExecPathGet", "user_initialize",
status, status != PRO_TK_NO_ERROR);
status = ProToolkitApplTextPathGet(wbuff2);
TEST_CALL_REPORT("ProToolkitApplTextPathGet", "user_initialize",
status, status != PRO_TK_NO_ERROR);
ProWstringToString(cbuff1, wbuff1);
ProWstringToString(cbuff2, wbuff2);
cout << endl << " Exec_path: " << cbuff1 <<endl;
cout << " Text_path: " << cbuff2 << endl << endl;
for(i=0; i<argc; i++)
cout << " argv[" << i << "]: " << argv[i] << endl;
/* Upon success */
return (0);
#if 0
/* If unsuccessful, return non-zero.
* You may store an error message in errbuf.
* The return value and error message will be displayed to the user.
* Pro/ENGINEER will call user_terminate() and shut down your application
*/
ProStringToWstring(errbuf, "Sample error message");
return(-1);
#endif
}
/*====================================================================*\
FUNCTION : user_terminate()
PURPOSE : To handle any termination actions
\*====================================================================*/
extern "C" void user_terminate()
{
/*---------------------------------------------------------------------*\
Loging file close.
\*---------------------------------------------------------------------*/
ProTestErrlogClose();
cout << "user_terminate" << endl;
}
/*====================================================================*\
FUNCTION : ProTestInstallationCheck
PURPOSE : Open a internationalized modal dialog with the test result
\*====================================================================*/
ProError ProTestInstallationCheck()
{
int window_id;
ProError status;
ProBoolean is_successful = PRO_B_FALSE;
/* Call a sample Pro/TOOLKIT feature */
status = ProWindowCurrentGet ( &window_id );
TEST_CALL_REPORT( "ProWindowCurrentGet", "ProTestInstallationCheck",
status, status != PRO_TK_NO_ERROR);
if ( status == PRO_TK_NO_ERROR )
{
/* Set flag for a SUCCESS dialog */
is_successful = PRO_B_TRUE;
}
else
{
/* Set flag for a FAILURE dialog */
is_successful = PRO_B_FALSE;
}
/*---------------------------------------------------------------------*\
Create and Display the dialog
\*---------------------------------------------------------------------*/
status = ProTestDialogCreate ( is_successful );
TEST_CALL_REPORT( "ProTestDialogCreate", "ProTestInstallationCheck",
status, status != PRO_TK_NO_ERROR);
return (status);
}
/*====================================================================*\
FUNCTION : ProTestStdCloseAction
PURPOSE : Close Action for Dialog
\*====================================================================*/
static ProError ProTestStdCloseAction (char* dialog, char* component, ProAppData data)
{
ProError status;
status = ProUIDialogExit (dialog, PRO_TK_NO_ERROR);
TEST_CALL_REPORT( "ProUIDialogExit", "ProTestStdCloseAction",
status, status != PRO_TK_NO_ERROR);
return status;
}
/*====================================================================*\
FUNCTION : ProTestInstallationURLCheck
PURPOSE : Open the URL for PTC Supports Web Page in Embedded Browser
\*====================================================================*/
ProError ProTestInstallationURLCheck()
{
int window_id;
ProError status;
ProComment url;
/*---------------------------------------------------------------------*\
Call a sample Pro/TOOLKIT feature
\*---------------------------------------------------------------------*/
status = ProWindowCurrentGet ( &window_id );
TEST_CALL_REPORT( "ProWindowCurrentGet", "ProTestInstallationURLCheck",
status, status != PRO_TK_NO_ERROR);
if ( status == PRO_TK_NO_ERROR )
{
/*---------------------------------------------------------------------*\
Load a sample URL
\*---------------------------------------------------------------------*/
ProStringToWstring ( url, "http://www.ptc.com/partners/hardware/current/support.htm");
status = ProWindowURLShow ( window_id, url );
TEST_CALL_REPORT( "ProWindowURLShow", "ProTestInstallationURLCheck",
status, status != PRO_TK_NO_ERROR);
}
return (status);
}
/*====================================================================*\
FUNCTION : ProTestDialogCreate
PURPOSE : Common utility for creation of dialog
\*====================================================================*/
ProError ProTestDialogCreate ( ProBoolean is_successful )
{
ProMdl model;
int dialog_status;
ProError status;
ProComment message_wchar;
char * dialog = "pt_install_dialog";
status = ProUIDialogCreate( dialog, dialog );
TEST_CALL_REPORT( "ProUIDialogCreate", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
status = ProUIDialogCloseActionSet( dialog,
(ProUIAction)ProTestStdCloseAction, NULL );
TEST_CALL_REPORT( "ProUIDialogCloseActionSet", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
status = ProUIPushbuttonActivateActionSet( dialog, "CloseBtn",
(ProUIAction)ProTestStdCloseAction, NULL );
TEST_CALL_REPORT( "ProUIPushbuttonActivateActionSet", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
if ( is_successful == PRO_B_TRUE )
{
status = ProMessageToBuffer ( message_wchar, MSGFIL, "USER Succeeded" );
TEST_CALL_REPORT( "ProMessageToBuffer", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
}
else
{
status = ProMessageToBuffer ( message_wchar, MSGFIL, "USER Failed" );
TEST_CALL_REPORT( "ProMessageToBuffer", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
}
status = ProUILabelTextSet( dialog, "Message", message_wchar );
TEST_CALL_REPORT( "ProUILabelTextSet", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
status = ProUIDialogActivate( dialog, &dialog_status );
TEST_CALL_REPORT( "ProUIDialogActivate", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
status = ProUIDialogDestroy( dialog );
TEST_CALL_REPORT( "ProUIDialogDestroy", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
return (status);
}