/* Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved. */ /*----------------------------------------------------------------------- This code runs for test: ptr_dbms -------------------------------------------------------------------------*/ /*--------------------------------------------------------------------*\ Pro/TOOLKIT includes \*--------------------------------------------------------------------*/ #include <ProToolkit.h> #include <ProObjects.h> #include <ProMdl.h> #include <ProSolid.h> #include <ProMenu.h> #include <ProMfg.h> #include <ProUtil.h> #include <ProSurface.h> #include <ProMessage.h> /*--------------------------------------------------------------------*\ Application includes \*--------------------------------------------------------------------*/ #include "TestError.h" #include "TestFiletypes.h" #include "UtilTypes.h" #include "UtilFiles.h" #include "UtilMessage.h" #include "UtilString.h" #include "UtilNames.h" #include "UtilCollect.h" #include "UtilMenu.h" #include "PTApplsUnicodeUtils.h" /*--------------------------------------------------------------------*\ Application macros \*--------------------------------------------------------------------*/ #define ERASE_OBJECT 0 #define ERASE_NOT_DISPLAYED 1 #define DELETE_OLD 0 #define DELETE_ALL 1 #define SAVE 0 #define SAVE_AS 1 #define BACKUP 2 #define RENAME 3 typedef struct MdlData_ { ProMdl mdl; ProMdlName name; ProMdlType type; } MdlData; /*--------------------------------------------------------------------*\ Application data types \*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*\ Application global/external data \*--------------------------------------------------------------------*/ /*====================================================================*\ Function : ProUtilLogFileWrite Purpose : Create info string for a model \*====================================================================*/ static void ProUtilLogFileWrite(char *str) { FILE *fp; fp = PTApplsUnicodeFopen("dbms.log", "a"); fputs(str, fp); fputc('\n', fp); fclose(fp); } /*====================================================================*\ Function : ProUtilMdlStr Purpose : Create info string for a model \*====================================================================*/ char* ProUtilMdlStr(ProMdl mdl, char *str) { ProError err; ProType model_type; char tname[PRO_NAME_SIZE], mname[PRO_MDLNAME_SIZE], mfgtypename[PRO_NAME_SIZE]; ProMdlName w_name = L""; ProMfgType mfg_type; int model_id; err = ProMdlTypeGet(mdl, (ProMdlType*)&model_type); TEST_CALL_REPORT("ProMdlTypeGet()", "ProUtilMdlStr()", err, err != PRO_TK_NO_ERROR); err = ProMdlIdGet(mdl, &model_id); TEST_CALL_REPORT("ProMdlIdGet()", "ProUtilMdlStr()", err, err != PRO_TK_NO_ERROR); err = ProMdlMdlnameGet(mdl, w_name); TEST_CALL_REPORT("ProMdlMdlnameGet()", "ProUtilMdlStr()", err, err != PRO_TK_NO_ERROR); ProUtilstrcpy(tname, (const char *)ProUtilGetMdlTypeStr((ProMdlType)model_type)); ProWstringToString(mname, w_name); if (model_type == PRO_MFG) { err = ProMfgTypeGet((ProMfg)mdl, &mfg_type); TEST_CALL_REPORT("ProMfgTypeGet()", "ProUtilMdlStr()", err, err != PRO_TK_NO_ERROR); ProUtilMfgtypeStr(mfg_type, mfgtypename); ProTKSprintf(str, "%s (%s) %s id = %d", tname, mfgtypename, mname, model_id); } else ProTKSprintf(str, "%s %s id = %d", tname, mname, model_id); return (str); } /*====================================================================*\ Function : ProUtilMdlDisplay Purpose : Display model in new window \*====================================================================*/ ProError ProUtilMdlDisplay(ProMdl mdl) { ProError err = PRO_TK_NO_ERROR; #ifndef PT_PRODUCTS_BUILD ProMdlName w_name = L""; ProCharLine line, str; ProType type; int w_id; err = ProMdlWindowGet(mdl, &w_id); TEST_CALL_REPORT("ProMdlWindowGet()", "ProUtilMdlDisplay()", err, (err != PRO_TK_NO_ERROR)&& (err!=PRO_TK_E_NOT_FOUND)); if( err == PRO_TK_NO_ERROR ) { ProTKSprintf(line, "Model %s already displayed.", ProUtilMdlStr(mdl, str)); ProUtilMsgPrint("gen", "TEST %0s", line); ProUtilLogFileWrite(line); return (err); } err = ProMdlTypeGet(mdl, (ProMdlType*)&type); TEST_CALL_REPORT("ProMdlTypeGet()", "ProUtilMdlDisplay()", err, err != PRO_TK_NO_ERROR); err = ProMdlMdlnameGet(mdl, w_name); TEST_CALL_REPORT("ProMdlMdlnameGet()", "ProUtilMdlDisplay()", err, err != PRO_TK_NO_ERROR); err = ProObjectwindowMdlnameCreate(w_name, type, &w_id); TEST_CALL_REPORT("ProObjectwindowMdlnameCreate()", "ProUtilMdlDisplay()", err, err != PRO_TK_NO_ERROR); err = ProMdlDisplay(mdl); TEST_CALL_REPORT("ProMdlDisplay()", "ProUtilMdlDisplay()", err, err != PRO_TK_NO_ERROR); err = ProWindowActivate(w_id); TEST_CALL_REPORT("ProWindowActivate()", "ProUtilMdlDisplay()", err, err != PRO_TK_NO_ERROR); if( err == PRO_TK_NO_ERROR ) { ProTKSprintf(line, "Displayed %s", ProUtilMdlStr(mdl, str)); ProUtilMsgPrint("gen", "TEST %0s", line); ProUtilLogFileWrite(line); } #endif return (err); } /*====================================================================*\ Function : ProUtilMdlInput() Purpose : Ask user to input model name and type \*====================================================================*/ ProError ProUtilMdlInput( char *user_prompt, ProBoolean allow_def, ProName model_name, ProMdlType *p_mdl_type) { char line[PRO_PATH_SIZE], str[PRO_PATH_SIZE], tname[PRO_TYPE_SIZE]; ProMdlName w_name = L""; ProPath buff; ProMdlType type; ProMdl mdl; ProError err; int stop = 1; char * dot_occur; if (allow_def == PRO_B_TRUE) { err = ProMdlCurrentGet(&mdl); TEST_CALL_REPORT("ProMdlCurrentGet()", "ProUtilMdlInput()", err, (err != PRO_TK_NO_ERROR)&& (err != PRO_TK_BAD_CONTEXT)); if (err == PRO_TK_NO_ERROR) { err = ProMdlMdlnameGet(mdl, w_name); TEST_CALL_REPORT("ProMdlMdlnameGet()", "ProUtilMdlInput()", err, err != PRO_TK_NO_ERROR); err = ProMdlTypeGet(mdl, &type); TEST_CALL_REPORT("ProMdlTypeGet()", "ProUtilMdlInput()", err, err != PRO_TK_NO_ERROR); ProUtilstrcpy(tname, (const char *)ProUtilGetMdlTypeStr(type)); ProWstringToString(line, w_name); ProUtilstrcat(line, (const char *)"."); ProUtilstrcat(line, (const char *)tname); ProTKSprintf(str, user_prompt, line); } else { allow_def = PRO_B_FALSE; ProTKSprintf(str, user_prompt, ""); } } else ProUtilstrcpy(str, (const char*)user_prompt); do { ProUtilMsgPrint("gen", "TEST %0s", str); err = ProMessageStringRead(PRO_FILE_NAME_SIZE, buff); TEST_CALL_REPORT("ProMessageStringRead()", "ProUtilMdlInput()", err, (err != PRO_TK_NO_ERROR)&&(err!=PRO_TK_GENERAL_ERROR)); if (err != PRO_TK_NO_ERROR) { if (err != PRO_TK_MSG_USER_QUIT && allow_def == PRO_B_TRUE) { ProWstringToString(line, w_name); break; } else return(PRO_TK_BAD_INPUTS); } ProWstringToString(str, buff); if((dot_occur = strchr(str, '.')) == NULL) { ProUtilstrcpy(tname, (const char *)ProUtilGetMdlTypeStr(type)); ProUtilstrcat( str,(const char *)"."); ProUtilstrcat( str,(const char *)tname); } if( ProUtilConfirmNameType(str, line, (ProType*)&type) == PRO_TK_BAD_INPUTS) continue; else stop = 0; } while (stop); ProStringToWstring(model_name, line); *p_mdl_type = type; return (PRO_TK_NO_ERROR); } /*====================================================================*\ Function : ProTestNewAction Purpose : Menubutton action. Return with err \*====================================================================*/ static int ProTestNewAction(ProAppData data, int action) { ProError err; err = ProMenuDeleteWithStatus(action); TEST_CALL_REPORT("ProMenuDeleteWithStatus()", "ProTestNewAction()", err, err != PRO_TK_NO_ERROR); return (0); } /*====================================================================*\ Function : ProTestUnsupported Purpose : Write Message 'type unsupported' \*====================================================================*/ static int ProTestUnsupported(ProAppData data, ProType type) { char ctype[PRO_NAME_SIZE]; ProCharLine line; ProUtilObjtypeStr(type, ctype); ProTKSprintf(line, "Model creation isn't supported yet for type %s.", ctype); ProUtilMsgPrint("gen", "TEST %0s", line); return (0); } /*====================================================================*\ Function : ProTestNewMfg Purpose : Show menu new tknewmfg \*====================================================================*/ ProError ProTestNewMfg(ProName name, ProMdlfileType orig_type, ProMdl *p_mdl) { ProError err; int action; ProMdlName buff = L""; ProMdl orig_model = NULL; ProMfg mfg; ProMfgType mfgtype; err = ProMenuFileRegister((char*)"TkNewMfg", (char*)"tknewmfg.mnu", NULL); err = ProMenubuttonActionSet((char*)"TkNewMfg", (char*)"-Assembly", (ProMenubuttonAction)ProTestNewAction, NULL, (int)PRO_MFGTYPE_MACH_ASSEM); err = ProMenubuttonActionSet((char*)"TkNewMfg", (char*)"-Sheetmetal", (ProMenubuttonAction)ProTestNewAction, NULL, (int)PRO_MFGTYPE_SHEET_METAL); err = ProMenubuttonActionSet((char*)"TkNewMfg", (char*)"-Cast", (ProMenubuttonAction)ProTestNewAction, NULL, (int)PRO_MFGTYPE_CAST); err = ProMenubuttonActionSet((char*)"TkNewMfg", (char*)"-Mold", (ProMenubuttonAction)ProTestNewAction, NULL, (int)PRO_MFGTYPE_MOLD); err = ProMenubuttonActionSet((char*)"TkNewMfg", (char*)"-CMM", (ProMenubuttonAction)ProTestNewAction, NULL, (int)PRO_MFGTYPE_CMM); err = ProMenubuttonActionSet((char*)"TkNewMfg", (char*)"Done/Return", (ProMenubuttonAction)ProMenuDelete, NULL, 0); err = ProMenubuttonActionSet((char*)"TkNewMfg", (char*)"TkNewMfg", (ProMenubuttonAction)ProMenuDelete, NULL, 0); err = ProMenuCreate(PROMENUTYPE_MAIN, (char*)"TkNewMfg", NULL); err = ProMenuProcess((char*)"TkNewMfg", &action); if (err != PRO_TK_NO_ERROR) return (err); mfgtype = (ProMfgType)action; if (mfgtype == PRO_MFGTYPE_SHEET_METAL) { ProUtilMsgPrint("gen", "TEST %0s", "Enter design part name: "); if( ProUtilStringGet(buff, NULL, PRO_FILE_NAME_SIZE) == 0) return(PRO_TK_GENERAL_ERROR); } err = ProMdlnameInit(buff, orig_type, &orig_model); err = ProMfgMdlCreate(name, mfgtype, orig_model, &mfg); TEST_CALL_REPORT("ProMfgMdlCreate()", "ProTestNewMfg()", err, err != PRO_TK_NO_ERROR); if (err == PRO_TK_NO_ERROR) *p_mdl = (ProMdl)mfg; return (PRO_TK_NO_ERROR); } /*====================================================================*\ Function : ProTestNewModel Purpose : Show menu new tknew \*====================================================================*/ int ProTestNewModel() { ProError err; int action; ProMdlName buff = L""; ProCharLine line, str; ProMdl model; err = ProMenuFileRegister((char*)"TkNew", (char*)"tknew.mnu", NULL); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"-Sketch", (ProMenubuttonAction)ProTestUnsupported, NULL, (int)PRO_2DSECTION); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"-Part", (ProMenubuttonAction)ProTestNewAction, NULL, (int)PRO_PART); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"-Assembly", (ProMenubuttonAction)ProTestNewAction, NULL, (int)PRO_ASSEMBLY); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"-Manufacturing", (ProMenubuttonAction)ProTestNewAction, NULL, (int)PRO_MFG); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"-Drawing", (ProMenubuttonAction)ProTestUnsupported, NULL, (int)PRO_DRAWING); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"-Format", (ProMenubuttonAction)ProTestUnsupported, NULL, (int)PRO_DWGFORM); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"-Report", (ProMenubuttonAction)ProTestUnsupported, NULL, (int)PRO_REPORT); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"-Diagram", (ProMenubuttonAction)ProTestUnsupported, NULL, (int)PRO_DIAGRAM); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"-Layout", (ProMenubuttonAction)ProTestUnsupported, NULL, (int)PRO_LAYOUT); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"-Markup", (ProMenubuttonAction)ProTestUnsupported, NULL, (int)PRO_MARKUP); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"TkNew", (ProMenubuttonAction)ProMenuDelete, NULL, 0); err = ProMenubuttonActionSet((char*)"TkNew", (char*)"Done/Return", (ProMenubuttonAction)ProMenuDelete, NULL, 0); err = ProMenuCreate(PROMENUTYPE_MAIN, (char*)"TkNew", NULL); err = ProMenuProcess((char*)"TkNew", &action); if (err != PRO_TK_NO_ERROR) return (0); ProUtilMsgPrint("gen", "TEST %0s", "Enter new model name: "); if( ProUtilStringGet(buff, NULL, PRO_FILE_MDLNAME_SIZE) == 0) return(-1); if ((ProType)action == PRO_PART || (ProType)action == PRO_ASSEMBLY) { err = ProSolidMdlnameCreate(buff, (ProMdlfileType)action, (ProSolid *)&model); TEST_CALL_REPORT("ProSolidMdlnameCreate()", "ProTestDbmsAction()", err, err != PRO_TK_NO_ERROR); } else if ((ProType)action == PRO_MFG) { err = ProTestNewMfg(buff, (ProMdlfileType)action, &model); } if( err == PRO_TK_NO_ERROR ) { ProTKSprintf(line, "%s has been created", ProUtilMdlStr(model, str)); ProUtilMsgPrint("gen", "TEST %0s", line); ProUtilLogFileWrite(line); err = ProUtilMdlDisplay(model); } return (0); } /*====================================================================*\ Function : ProTestModelOpen Purpose : Open model window \*====================================================================*/ int ProTestModelOpen() { ProError err; int version; ProCharLine line, str; ProLine buff; ProPath sel_path, def_path; ProMdlName w_name = L""; ProMdlExtension w_type; ProMdl model; ProType type; ProStringToWstring(buff, (char*)"*.prt,*.asm,*.mfg,*.lay,*.sec," "*.drw,*.rep,*.frm,*.rep,*.mrk,*.dgm"); ProStringToWstring(def_path, (char*)"."); /* Open file */ err = ProFileMdlnameOpen(NULL, buff, NULL, NULL, NULL, NULL, sel_path); TEST_CALL_REPORT("ProFileMdlnameOpen()", "ProTestModelOpen()", err, err != PRO_TK_NO_ERROR); ProWstringToString(line, sel_path); if (err == PRO_TK_NO_ERROR) { err = ProFileMdlnameParse (sel_path, def_path, w_name, w_type, &version); TEST_CALL_REPORT("ProFileMdlnameParse1 ()", "ProTestModelOpen()", err, err != PRO_TK_NO_ERROR); err = ProPathMdlnameCreate(NULL, w_name, w_type, PRO_VALUE_UNUSED, def_path); TEST_CALL_REPORT("ProPathMdlnameCreate()", "ProTestModelOpen()", err, err != PRO_TK_NO_ERROR); ProWstringToString(str, def_path); if( ProUtilConfirmNameType(str, line, &type) != PRO_TK_BAD_INPUTS) { err = ProMdlnameRetrieve(w_name, (ProMdlfileType)type, &model); TEST_CALL_REPORT("ProMdlnameRetrieve()", "ProTestModelOpen()", err, err != PRO_TK_NO_ERROR); if( err == PRO_TK_NO_ERROR ) { ProTKSprintf(line, "%s has been retrieved", ProUtilMdlStr(model, str)); ProUtilMsgPrint("gen", "TEST %0s", line); ProUtilLogFileWrite( line); err = ProUtilMdlDisplay(model); } } } return(0); } /*====================================================================*\ Function : ProUtilModelToMdl Purpose : Convert ProModels to ProMdls \*====================================================================*/ ProError ProUtilModelToMdl( ProMdlnameShortdata **model_list, ProMdl **mdl_list, ProMdlfileType *filetypes, int *n_mdl) { ProError err; int i, ign=0; ProMdlfileType type; ProMdl mdl; char ctype[PRO_NAME_SIZE]; err = ProArrayAlloc(0, sizeof(ProMdl), 1, (ProArray*)mdl_list); TEST_CALL_REPORT("ProArrayAlloc()", "ProUtilModelToMdl()", err, err != PRO_TK_NO_ERROR); for (i=0; i<n_mdl[0]; i++) { err = ProMdlnameInit(model_list[0][i].name, filetypes[i], &mdl); TEST_CALL_REPORT("ProMdlnameInit()", "ProUtilModelToMdl()", err, err != PRO_TK_NO_ERROR); if (err != PRO_TK_NO_ERROR) { ign++; continue; } err = ProArrayObjectAdd((ProArray*)mdl_list, PRO_VALUE_UNUSED, 1, &mdl); TEST_CALL_REPORT("ProArrayObjectAdd()", "ProUtilModelToMdl()", err, err != PRO_TK_NO_ERROR); } err = ProArrayFree((ProArray*)model_list); TEST_CALL_REPORT("ProArrayFree()", "ProUtilModelToMdl()", err, err != PRO_TK_NO_ERROR); n_mdl[0] -= ign; return( n_mdl[0]>0 ? PRO_TK_NO_ERROR : PRO_TK_E_NOT_FOUND); } /*====================================================================*\ Function : ProUtilMdlDataArrayOut() Purpose : Add Mdl Data Array out Collect model info & init MdlData struct \*====================================================================*/ ProError ProUtilMdlDataArrayOut(ProMdl *in, MdlData **out) { MdlData *out_ar=NULL; ProError err; int n_mdls=0,ii; if ( out == NULL ) return PRO_TK_GENERAL_ERROR; err = ProArraySizeGet ( (ProArray*)in, &n_mdls); TEST_CALL_REPORT("ProArraySizeGet()", "ProUtilMdlDataArrayOut()", err, err != PRO_TK_NO_ERROR); err = ProArrayAlloc (0, sizeof(MdlData), 1, (ProArray *)&out_ar); TEST_CALL_REPORT("ProArrayAlloc()", "ProUtilMdlDataArrayOut()", err, err != PRO_TK_NO_ERROR); for (ii=0; ii<n_mdls;ii++) { MdlData tmp_data; tmp_data.mdl = in[ii]; err = ProMdlMdlnameGet(in[ii],tmp_data.name); TEST_CALL_REPORT("ProMdlMdlnameGet()", "ProUtilMdlDataArrayOut()", err, err != PRO_TK_NO_ERROR); err = ProMdlTypeGet(in[ii], &tmp_data.type); TEST_CALL_REPORT("ProMdlTypeGet()", "ProUtilMdlDataArrayOut()", err, err != PRO_TK_NO_ERROR); err = ProArrayObjectAdd((ProArray*)&out_ar, PRO_VALUE_UNUSED, 1, &tmp_data); TEST_CALL_REPORT("ProArrayObjectAdd()", "ProUtilMdlDataArrayOut()", err, err != PRO_TK_NO_ERROR); } *out = out_ar; return PRO_TK_NO_ERROR; } /*====================================================================*\ Function : ProTestModelErase Purpose : Erase Current / Not Displayed objects from session \*====================================================================*/ int ProTestModelErase(ProAppData data, int action) { ProMdl *mdl_array, *mdl_list, model, cur_model; ProMdlnameShortdata *model_list; ProMdlfileType *filetypes; MdlData *mdl_data_ar; ProError err; int n_mdl, i, j, k, *p_ids, n_win, n, n_nd; ProCharLine str, line; ProMdlName w_name = L""; ProMdlType mod_types[]={PRO_MDL_MFG, PRO_MDL_DRAWING, PRO_MDL_ASSEMBLY, PRO_MDL_PART, PRO_MDL_2DSECTION, PRO_MDL_LAYOUT}, type; err = ProArrayAlloc(0, sizeof(ProMdl), 1, (ProArray*)&mdl_array); TEST_CALL_REPORT("ProArrayAlloc()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); if (action == ERASE_OBJECT) { err = ProUtilMdlInput((char*)"Enter object to erase []:", PRO_B_FALSE, w_name, &type); if (err == PRO_TK_NO_ERROR) { err = ProMdlnameInit(w_name, (ProMdlfileType)type, &model); TEST_CALL_REPORT("ProMdlnameInit()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); } if (err == PRO_TK_NO_ERROR) { err = ProMdlCurrentGet(&cur_model); TEST_CALL_REPORT("ProMdlCurrentGet()", "ProTestModelErase()", err, (err != PRO_TK_NO_ERROR)&&(err != PRO_TK_BAD_CONTEXT)); if (err == PRO_TK_NO_ERROR && model == cur_model) { ProUtilMsgPrint("gen", "TEST %0s", "Unable to erase current object"); return (0); } /* If object open in window close window first */ err = ProUtilCollectWindowIds(&p_ids); err = ProArraySizeGet((ProArray)p_ids, &n_win); TEST_CALL_REPORT("ProArraySizeGet()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); for (i=0; i<n_win; i++) { err = ProWindowMdlGet(p_ids[i], &cur_model); TEST_CALL_REPORT("ProWindowMdlGet()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); if (cur_model == model) { err = ProWindowDelete(p_ids[i]); TEST_CALL_REPORT("ProWindowDelete()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); break; } } err = ProArrayFree((ProArray*)&p_ids); TEST_CALL_REPORT("ProArrayFree()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); } /* Find models and dependencies */ err = ProArrayObjectAdd((ProArray*)&mdl_array, PRO_VALUE_UNUSED, 1, &model); TEST_CALL_REPORT("ProArrayObjectAdd()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); err = ProMdlDependenciesDataList (model, &model_list, &filetypes, &n_mdl); TEST_CALL_REPORT("ProMdlDependenciesDataList ()", "ProTestModelErase()", err, (err != PRO_TK_NO_ERROR)&& (err != PRO_TK_E_NOT_FOUND)); if (err == PRO_TK_NO_ERROR) err = ProUtilModelToMdl(&model_list, &mdl_list, filetypes, &n_mdl); if (err == PRO_TK_NO_ERROR) { err = ProArrayObjectAdd((ProArray*)&mdl_array, PRO_VALUE_UNUSED, n_mdl, mdl_list); TEST_CALL_REPORT("ProArrayObjectAdd()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); err = ProArrayFree((ProArray*)&mdl_list); TEST_CALL_REPORT("ProArrayFree()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); err = ProArrayFree((ProArray*)&filetypes); TEST_CALL_REPORT("ProArrayFree()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); } } else { /* Collect all models */ for (i=0; i<sizeof(mod_types)/sizeof(mod_types[0]); i++) { err = ProSessionMdlList(mod_types[i], &mdl_list, &n_mdl); TEST_CALL_REPORT("ProSessionMdlList()", "ProTestModelErase()", err, (err != PRO_TK_NO_ERROR)&& (err != PRO_TK_E_NOT_FOUND)); if (err != PRO_TK_NO_ERROR) continue; err = ProArrayObjectAdd((ProArray*)&mdl_array, PRO_VALUE_UNUSED, n_mdl, mdl_list); TEST_CALL_REPORT("ProArrayObjectAdd()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); err = ProArrayFree((ProArray*)&mdl_list); TEST_CALL_REPORT("ProArrayFree()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); } } /* Remove objects which currently displayed */ err = ProUtilCollectWindowIds(&p_ids); err = ProArraySizeGet((ProArray)p_ids, &n_win); TEST_CALL_REPORT("ProArraySizeGet()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); err = ProArraySizeGet((ProArray)mdl_array, &n); TEST_CALL_REPORT("ProArraySizeGet()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); /* for each window found displayed objects and depend. */ for (i=0; i<n_win; i++) { err = ProWindowMdlGet(p_ids[i], &model); TEST_CALL_REPORT("ProWindowMdlGet()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); if (err != PRO_TK_NO_ERROR) continue; if(model!=NULL) { err = ProMdlDependenciesDataList (model, &model_list, &filetypes, &n_mdl); TEST_CALL_REPORT("ProMdlDependenciesDataList()", "ProTestModelErase()", err, (err != PRO_TK_NO_ERROR)&& (err != PRO_TK_E_NOT_FOUND)); if (err != PRO_TK_NO_ERROR) n_mdl = 0; if (err == PRO_TK_NO_ERROR) err = ProUtilModelToMdl(&model_list, &mdl_list, filetypes, &n_mdl); for (j=0; j<n; j++) { for (k=0; k<=n_mdl; k++) if (mdl_array[j] == (k<n_mdl ? mdl_list[k] : model)) { err = ProArrayObjectRemove((ProArray*)&mdl_array, j, 1); TEST_CALL_REPORT("ProArrayObjectRemove()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); n--; if (j>=n) break; } } } else n_mdl=0; if (n_mdl >0) { err = ProArrayFree((ProArray*)&mdl_list); TEST_CALL_REPORT("ProArrayFree()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); err = ProArrayFree((ProArray*)&filetypes); TEST_CALL_REPORT("ProArrayFree()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); } } err = ProArrayFree((ProArray*)&p_ids); TEST_CALL_REPORT("ProArrayFree()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); ProUtilMsgPrint("gen", "TEST %0s", "Are you sure to erase models from memory? [N]:"); if (ProUtilYesnoGet((char *)"n")) { if( action == ERASE_NOT_DISPLAYED) { /* Replaced for loop ProMdlErase call with ProMdlEraseNotDisplayed to get get rid of FMR error in purify */ err = ProMdlEraseNotDisplayed(); TEST_CALL_REPORT("ProMdlEraseNotdisplayed()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); } else if (action == ERASE_OBJECT) { err =ProUtilMdlDataArrayOut (mdl_array, &mdl_data_ar); TEST_CALL_REPORT("ProUtilMdlDataArrayOut()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); err = ProArraySizeGet (mdl_data_ar, &n_nd); TEST_CALL_REPORT("ProArraySizeGet()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); /* Erase all collected models */ for (i=0; i<n_nd; i++) { ProMdl tmp_mdl; /* Check that model still valid after erasing previous models */ if(ProMdlnameInit(mdl_data_ar[i].name, (ProMdlfileType)mdl_data_ar[i].type ,&tmp_mdl) != PRO_TK_NO_ERROR) { ProTKSprintf(line, "%ws not in session ",mdl_data_ar[i].name); TEST_CALL_REPORT(line,"ProTestModelErase()", err, err != PRO_TK_NO_ERROR); continue; } err = ProMdlTypeGet(mdl_data_ar[i].mdl, &type); if (err != PRO_TK_NO_ERROR || (int)type < 1 || (int)type > PRO_MDL_DIAGRAM) continue; ProTKSprintf(line, "%s has been cleared", ProUtilMdlStr(mdl_data_ar[i].mdl, str)); err = ProMdlErase(mdl_data_ar[i].mdl); TEST_CALL_REPORT("ProMdlErase()", "ProTestModelErase()", err, (err != PRO_TK_NO_ERROR) && (err != PRO_TK_E_IN_USE)); if (err == PRO_TK_NO_ERROR) { ProUtilMsgPrint("gen", "TEST %0s", line); ProUtilLogFileWrite( line); } } } } /* Free allocated memory */ err = ProArrayFree((ProArray*)&mdl_array); TEST_CALL_REPORT("ProArrayFree()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); if (action == ERASE_OBJECT) { /* Free allocated memory */ err = ProArrayFree((ProArray*)&mdl_data_ar); TEST_CALL_REPORT("ProArrayFree()", "ProTestModelErase()", err, err != PRO_TK_NO_ERROR); } return (0); } /*====================================================================*\ Function : ProTestModelEraseAll Purpose : Erase objects from session, including submodels \*====================================================================*/ int ProTestModelEraseAll(ProAppData data) { ProMdl mdl; ProError err; ProMdlName w_name = L""; ProMdlType type; err = ProUtilMdlInput((char*)"Enter object to erase []:", PRO_B_FALSE, w_name, &type); if (err != PRO_TK_NO_ERROR) return err; err = ProMdlnameInit(w_name, (ProMdlfileType)type, &mdl); TEST_CALL_REPORT("ProMdlnameInit()", "ProTestModelEraseAll()", err, err != PRO_TK_NO_ERROR); if (err != PRO_TK_NO_ERROR) return err; err = ProMdlEraseAll(mdl); TEST_CALL_REPORT("ProMdlEraseAll()", "ProTestModelEraseAll()", err, (err != PRO_TK_NO_ERROR)); return err; } /*====================================================================*\ Function : ProUtilCompareVersion() Purpose : compare two files by version \*====================================================================*/ int ProUtilCompareVersion(ProPath p1, ProPath p2) { int ver1 =0, ver2 =0; ProError err; err = ProFileMdlnameParse(p1, NULL, NULL, NULL, &ver1); TEST_CALL_REPORT("ProFileMdlnameParse()", "ProTestModelOpen()", err, err != PRO_TK_NO_ERROR); err = ProFileMdlnameParse(p2, NULL, NULL, NULL, &ver2); TEST_CALL_REPORT("ProFileMdlnameParse()", "ProTestModelOpen()", err, err != PRO_TK_NO_ERROR); return (ver1-ver2); } /*====================================================================*\ Function : ProUtilMdlPurge Purpose : Delete old version of an model \*====================================================================*/ ProError ProUtilMdlPurge(ProName w_name, ProMdlType type) { ProError err; ProCharLine line, str; ProLine w_line; ProPath *file_list, *dir_list; ProName w_nm; int i, n_files; ProUtilstrcpy(line, (const char *)ProUtilGetMdlTypeStr(type)); ProWstringToString(str, w_name); ProUtilstrcat(str, (const char *)"."); ProUtilstrcat(str, (const char *)line); ProUtilStringLower(str, str); ProStringToWstring(w_line, str); ProStringToWstring(w_nm, (char*)"."); err = ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&file_list); TEST_CALL_REPORT("ProArrayAlloc()", "ProUtilMdlPurge()", err, err != PRO_TK_NO_ERROR); err = ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&dir_list); TEST_CALL_REPORT("ProArrayAlloc()", "ProUtilMdlPurge()", err, err != PRO_TK_NO_ERROR); err = ProFilesList(w_nm, w_line, PRO_FILE_LIST_ALL, &file_list, &dir_list); TEST_CALL_REPORT("ProFilesList()", "ProUtilMdlPurge()", err, err != PRO_TK_NO_ERROR); if (err == PRO_TK_NO_ERROR) { err = ProArraySizeGet((ProArray)file_list, &n_files); TEST_CALL_REPORT("ProArraySizeGet()", "ProUtilMdlPurge()", err, err != PRO_TK_NO_ERROR); if (n_files > 1) { qsort(file_list, n_files, sizeof(file_list[0]), (int (*)(PRO_CONST_ARG void *, PRO_CONST_ARG void *)) ProUtilCompareVersion); } for (i=0; i<n_files-1; i++) { ProWstringToString(str, file_list[i]); remove(str); } } err = ProArrayFree((ProArray*)&file_list); TEST_CALL_REPORT("ProArrayFree()", "ProUtilMdlPurge()", err, err != PRO_TK_NO_ERROR); err = ProArrayFree((ProArray*)&dir_list); TEST_CALL_REPORT("ProArrayFree()", "ProUtilMdlPurge()", err, err != PRO_TK_NO_ERROR); return(PRO_TK_NO_ERROR); } /*====================================================================*\ Function : ProTestModelDelete Purpose : delete object from memory and disk \*====================================================================*/ int ProTestModelDelete(ProAppData data, int action) { ProError err; ProMdl mdl, cur_model; ProMdlType type; ProCharLine str, line; ProMdlName w_name = L""; int i, n_win, *p_ids; err = ProMdlCurrentGet(&cur_model); TEST_CALL_REPORT("ProMdlCurrentGet()", "ProTestModelDelete()", err, (err != PRO_TK_NO_ERROR)&& (err != PRO_TK_BAD_CONTEXT)); if (err != PRO_TK_NO_ERROR) cur_model = (ProMdl)NULL; if (action == DELETE_ALL) { err = ProUtilMdlInput((char*)"Enter object to delete []:", PRO_B_FALSE, w_name, &type); if (err == PRO_TK_NO_ERROR) { err = ProMdlnameInit(w_name, (ProMdlfileType)type, &mdl); TEST_CALL_REPORT("ProMdlnameInit()", "ProTestModelDelete()", err, err != PRO_TK_NO_ERROR); } if (err != PRO_TK_NO_ERROR) return (-1); if (mdl == cur_model) { ProUtilMsgPrint("gen", "TEST %0s", "Unable to delete current object"); return (0); } /* If object open in window close window first */ err = ProUtilCollectWindowIds(&p_ids); err = ProArraySizeGet((ProArray)p_ids, &n_win); TEST_CALL_REPORT("ProArraySizeGet()", "ProTestModelDelete()", err, err != PRO_TK_NO_ERROR); for (i=0; i<n_win; i++) { err = ProWindowMdlGet(p_ids[i], &cur_model); TEST_CALL_REPORT("ProWindowMdlGet()", "ProTestModelDelete()", err, err != PRO_TK_NO_ERROR); if (cur_model == mdl) { err = ProWindowDelete(p_ids[i]); TEST_CALL_REPORT("ProWindowDelete()", "ProTestModelDelete()", err, err != PRO_TK_NO_ERROR); break; } } err = ProArrayFree((ProArray*)&p_ids); TEST_CALL_REPORT("ProArrayFree()", "ProTestModelDelete()", err, err != PRO_TK_NO_ERROR); ProUtilMsgPrint("gen", "TEST %0s", "Are you sure to delete models " "from memory and work directory? [N]:"); if (ProUtilYesnoGet((char *)"n")) { ProTKSprintf(line, "%s has been deleted", ProUtilMdlStr(mdl, str)); err = ProMdlDelete(mdl); TEST_CALL_REPORT("ProMdlDelete()", "ProTestModelDelete()", err, err != PRO_TK_NO_ERROR); if (err == PRO_TK_NO_ERROR) { ProUtilMsgPrint("gen", "TEST %0s", line); ProUtilLogFileWrite( line); } } } else { if (cur_model == NULL) { err = ProUtilMdlInput((char*)"Enter object to purge []:", PRO_B_FALSE, w_name, &type); } else { mdl = cur_model; err = ProMdlMdlnameGet(mdl, w_name); TEST_CALL_REPORT("ProMdlMdlnameGet()", "ProTestModelDelete()", err, err != PRO_TK_NO_ERROR); err = ProMdlTypeGet(mdl, &type); TEST_CALL_REPORT("ProMdlTypeGet()", "ProTestModelDelete()", err, err != PRO_TK_NO_ERROR); } if (err == PRO_TK_NO_ERROR) err = ProUtilMdlPurge(w_name, type); if (err == PRO_TK_NO_ERROR) { ProWstringToString(str, w_name); ProTKSprintf(line, "%s has been purged", str); ProUtilMsgPrint("gen", "TEST %0s", line); ProUtilLogFileWrite( line); } } return (0); } /*====================================================================*\ Function : ProTestModelSave Purpose : Save current model \*====================================================================*/ int ProTestModelSave(ProAppData appdata, int action) { ProError err; ProMdl model, new_model, current_model; ProMdlType type, type1, current_type; ProLine buff; ProCharLine str, line; ProMdlName w_name = L"", w_name1 = L"", w_current_name = L""; char name[PRO_NAME_SIZE]; ProBoolean modif, current_exists; ProPath dir_path; switch(action) { case SAVE: err = ProUtilMdlInput((char*)"Enter object to save [%s]:", PRO_B_TRUE, w_name, &type); if (err != PRO_TK_NO_ERROR) break; err = ProMdlnameInit(w_name, (ProMdlfileType)type, &model); TEST_CALL_REPORT("ProMdlnameInit()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); if (err != PRO_TK_NO_ERROR) break; err = ProMdlModificationVerify (model, &modif); TEST_CALL_REPORT("ProMdlModificationVerify()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); if (err == PRO_TK_NO_ERROR) { ProTKSprintf (line, "%s %s since last save", ProUtilMdlStr(model, str), modif ? "has been changed" : "has not been changed"); ProUtilMsgPrint("gen", "TEST %0s", line); } err = ProMdlSave(model); TEST_CALL_REPORT("ProMdlSave()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); if (err == PRO_TK_NO_ERROR) { ProTKSprintf(line, "%s has been saved", ProUtilMdlStr(model, str)); ProUtilMsgPrint("gen", "TEST %0s", line); ProUtilLogFileWrite( line); } break; case SAVE_AS: err = ProUtilMdlInput((char*)"Enter object to save as [%s]:", PRO_B_TRUE, w_name, &type); if (err != PRO_TK_NO_ERROR) break; err = ProUtilMdlInput((char*)"Enter object to save to []:", PRO_B_FALSE, w_name1, &type1); if (err != PRO_TK_NO_ERROR) break; err = ProMdlnameInit(w_name, (ProMdlfileType)type, &model); TEST_CALL_REPORT("ProMdlnameInit()", "ProTestModelSave()", err, (err != PRO_TK_NO_ERROR)&& (err != PRO_TK_E_NOT_FOUND)); if (err == PRO_TK_NO_ERROR) { /* Get name and type of the current Pro/E model */ current_exists = PRO_B_FALSE; err = ProMdlCurrentGet( ¤t_model ); TEST_CALL_REPORT("ProMdlCurrentGet()", "ProTestModelSave()", err, (err != PRO_TK_NO_ERROR)&& (err != PRO_TK_BAD_CONTEXT)); if( err == PRO_TK_NO_ERROR ) { current_exists = PRO_B_TRUE; err = ProMdlMdlnameGet( current_model, w_current_name ); TEST_CALL_REPORT("ProMdlMdlnameGet()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); err = ProMdlTypeGet( current_model, ¤t_type ); TEST_CALL_REPORT("ProMdlTypeGet()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); } /* Copy the specified model */ err = ProMdlnameCopy (model, w_name1, &new_model); TEST_CALL_REPORT("ProMdlnameCopy ()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); /* Delete the copy from memory */ err = ProMdlErase(new_model); TEST_CALL_REPORT("ProMdlErase()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); if( current_exists == PRO_B_TRUE ) { /* Restore current model */ err = ProMdlnameRetrieve (w_current_name, (ProMdlfileType)current_type, ¤t_model); TEST_CALL_REPORT("ProMdlnameRetrieve ()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); } } else { err = ProMdlfileMdlnameCopy((ProMdlfileType)type, w_name, w_name1); TEST_CALL_REPORT("ProMdlfileMdlnameCopy()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); } if (err == PRO_TK_NO_ERROR) { ProWstringToString(str, w_name); ProTKSprintf(line, "%s has been copied", str); ProUtilMsgPrint("gen", "TEST %0s", line); ProUtilLogFileWrite( line); } break; case BACKUP: err = ProUtilMdlInput((char*)"Enter object to backup [%s]:", PRO_B_TRUE, w_name, &type); if (err != PRO_TK_NO_ERROR) break; err = ProMdlnameInit(w_name, (ProMdlfileType)type, &model); TEST_CALL_REPORT("ProMdlnameInit()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); if (err != PRO_TK_NO_ERROR) break; ProUtilMsgPrint("gen", "TEST %0s", "Enter dir to backup to [.]:"); ProStringToWstring(w_name1, (char*)"."); if( ProUtilStringGet(buff, w_name1, PRO_FILE_NAME_SIZE) == 0) break; ProUtilWstrcpy(dir_path, buff); err = ProMdlnameBackup( model, dir_path ); TEST_CALL_REPORT("ProMdlnameBackup()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); if (err == PRO_TK_NO_ERROR) { ProTKSprintf(line, "%s has been saved", ProUtilMdlStr(model, str)); ProUtilMsgPrint("gen", "TEST %0s", line); ProUtilLogFileWrite( line); } break; case RENAME: err = ProUtilMdlInput((char*)"Enter object to rename [%s]:", PRO_B_TRUE, w_name, &type); if (err != PRO_TK_NO_ERROR) break; err = ProUtilMdlInput((char*)"Enter new object name []:", PRO_B_FALSE, w_name1, &type1); if (err != PRO_TK_NO_ERROR) break; err = ProMdlnameInit(w_name, (ProMdlfileType)type, &model); TEST_CALL_REPORT("ProMdlnameInit()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); if (err == PRO_TK_NO_ERROR) { ProUtilMdlStr(model, str); err = ProMdlnameRename (model, w_name1); TEST_CALL_REPORT("ProMdlnameRename ()", "ProTestModelSave()", err, err != PRO_TK_NO_ERROR); } if (err == PRO_TK_NO_ERROR) { ProTKSprintf(line, "%s has been renamed to %s", str, ProWstringToString(name, w_name1)); ProUtilMsgPrint("gen", "TEST %0s", line); ProUtilLogFileWrite( line); } break; } return (0); } /*====================================================================*\ Function : ProTestDbmsInfo Purpose : Write info file \*====================================================================*/ int ProTestDbmsInfo() { ProMdlType mod_types[]={PRO_MDL_PART, PRO_MDL_ASSEMBLY, PRO_MDL_DRAWING, PRO_MDL_2DSECTION, PRO_MDL_LAYOUT}; char *mdl_name[]={"Parts", "Assemblies", "Drawings", "Sections", "Notebooks"}; int i, j, k, n_mdl, n_dep, n_dec; FILE *fp; ProMdlnameShortdata *model_listdp; ProMdlnameShortdata *model_listdc; ProMdl *mdl_list; ProError err; ProMdlName w_name = L""; ProCharLine line1, line2; fp = PTApplsUnicodeFopen("names.inf", "w"); if (fp == NULL) return (0); ProTKFprintf(fp, "Objects\t \t \t \tDependencies\t \tDeclared\n"); for (i=0; i<sizeof(mod_types)/sizeof(mod_types[0]); i++) { ProTKFprintf(fp, "\n%s\n----------------\n", mdl_name[i]); err = ProSessionMdlList(mod_types[i], &mdl_list, &n_mdl); TEST_CALL_REPORT("ProSessionMdlList()", "ProTestDbmsInfo()", err, (err != PRO_TK_NO_ERROR)&& (err != PRO_TK_E_NOT_FOUND)); if (err != PRO_TK_NO_ERROR) continue; for (j=0; j<n_mdl; j++) { /* Write model name */ err = ProMdlMdlnameGet(mdl_list[j], w_name); TEST_CALL_REPORT("ProMdlMdlnameGet()", "ProTestDbmsInfo()", err, err != PRO_TK_NO_ERROR); ProWstringToString(line1, w_name); ProTKFprintf(fp, " %s\n", line1); err = ProMdlDependenciesMdlnameList (mdl_list[j], &model_listdp, &n_dep); TEST_CALL_REPORT("ProMdlDependenciesMdlnameList ()", "ProTestDbmsInfo()", err, (err != PRO_TK_NO_ERROR)&& (err != PRO_TK_E_NOT_FOUND)); if (err != PRO_TK_NO_ERROR) n_dep = 0; err = ProMdlDeclaredMdlnameList (mdl_list[j], &model_listdc, &n_dec); TEST_CALL_REPORT("ProMdlDeclaredMdlnameList ()", "ProTestDbmsInfo()", err, (err != PRO_TK_NO_ERROR)&& (err != PRO_TK_E_NOT_FOUND)); if (err != PRO_TK_NO_ERROR) n_dec = 0; for (k=0; k<n_dec || k<n_dep; k++) { if (k<n_dep) { ProWstringToString(line1, model_listdp[k].name); ProUtilstrcat(line1, "."); ProWstringToString(line1 + strlen(line1), model_listdp[k].type); } else ProUtilstrcpy(line1, " "); if (k<n_dec) { ProWstringToString(line2, model_listdc[k].name); ProUtilstrcat(line2, "."); ProWstringToString(line2 + strlen(line2), model_listdp[k].type); } else ProUtilstrcpy(line2, " "); ProTKFprintf(fp, "\t \t \t \t%-24s%s\n", line1, line2); } if (n_dec>0) { err = ProArrayFree((ProArray*)&model_listdc); TEST_CALL_REPORT("ProArrayFree()", "ProTestDbmsInfo()", err, err != PRO_TK_NO_ERROR); } if (n_dep>0) { err = ProArrayFree((ProArray*)&model_listdp); TEST_CALL_REPORT("ProArrayFree()", "ProTestDbmsInfo()", err, err != PRO_TK_NO_ERROR); } } err = ProArrayFree((ProArray*)&mdl_list); TEST_CALL_REPORT("ProArrayFree()", "ProTestDbmsInfo()", err, err != PRO_TK_NO_ERROR); } fclose(fp); ProStringToWstring(w_name, (char*)"names.inf"); ProInfoWindowDisplay(w_name, NULL, NULL); return (0); } /*====================================================================*\ Function : ProTestCurClose Purpose : Close current window \*====================================================================*/ int ProTestCurClose() { ProError err; err = ProWindowCurrentClose(); TEST_CALL_REPORT("ProWindowCurrentClose()", "ProTestCurClose()", err, err != PRO_TK_NO_ERROR); return (0); } /*====================================================================*\ Function : ProTestModelMultipleOpen Purpose : Retrieves the models specified in the names list \*====================================================================*/ int ProTestModelMultipleOpen () { ProError err; ProName *p_names, name; ProBoolean display = PRO_B_TRUE; int n_models, i; ProMdl retrieved_mdl; static ProUtilMenuButtons disp_flag[] = { {"DisplayFlag", 0, TEST_CALL_PRO_MENU_DELETE}, {"Display", PRO_B_TRUE, 0}, {"Not Display", PRO_B_FALSE, 0}, {"",0,0} }; err = ProUtilMenuIntValueSelect(disp_flag, (int*)&display); err = ProArrayAlloc(0, sizeof(ProName), 1, (ProArray*)&p_names); TEST_CALL_REPORT("ProArrayAlloc()", "ProTestRetrieve()", err, err != PRO_TK_NO_ERROR); while (1) { ProUtilMsgPrint("gen", "TEST %0s", "Enter file name: "); if (!ProUtilStringGet (name, NULL, PRO_NAME_SIZE)) break; err = ProArrayObjectAdd ((ProArray*)&p_names, PRO_VALUE_UNUSED, 1, &name); } err = ProArraySizeGet ((ProArray)p_names, &n_models); TEST_CALL_REPORT("ProArraySizeGet()", "ProTestRetrieve()", err, err != PRO_TK_NO_ERROR); if (err == PRO_TK_NO_ERROR && n_models > 0) { for (i = 0; i < n_models; i++) { err = ProMdlFiletypeLoad(p_names[i], PRO_MDLFILE_UNUSED, PRO_B_FALSE, &retrieved_mdl); TEST_CALL_REPORT("ProMdlFiletypeLoad()", "ProTestRetrieve()", err, err != PRO_TK_NO_ERROR); if(err == PRO_TK_NO_ERROR) { if(display == PRO_B_TRUE) { err = ProMdlDisplay(retrieved_mdl); TEST_CALL_REPORT("ProMdlDisplay()", "ProTestRetrieve()", err, err != PRO_TK_NO_ERROR); } } } } err = ProArrayFree ((ProArray*)&p_names); TEST_CALL_REPORT("ProArrayFree()", "ProTestRetrieve()", err, err != PRO_TK_NO_ERROR); return (0); } /*====================================================================*\ Function : ProTestDbms Purpose : Create a menu used to test dbms functions \*====================================================================*/ int ProTestDbms() { ProError err; int menu_id, action; int ProTestSolidFunc(); int ProTestSolidProject(); err = ProMenuFileRegister((char*)"TkDbms", (char*)"tkdbms.mnu", &menu_id); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-New", (ProMenubuttonAction)ProTestNewModel, NULL, 0); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Open", (ProMenubuttonAction)ProTestModelOpen, NULL, 0); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Erase", (ProMenubuttonAction)ProTestModelErase, NULL, ERASE_OBJECT); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Erase not disp", (ProMenubuttonAction)ProTestModelErase, NULL, ERASE_NOT_DISPLAYED); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Erase with sub", (ProMenubuttonAction)ProTestModelEraseAll, NULL, 0); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Delete old ver", (ProMenubuttonAction)ProTestModelDelete, NULL, DELETE_OLD); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Delete all ver", (ProMenubuttonAction)ProTestModelDelete, NULL, DELETE_ALL); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Save", (ProMenubuttonAction)ProTestModelSave, NULL, SAVE); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Save as", (ProMenubuttonAction)ProTestModelSave, NULL, SAVE_AS); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Backup", (ProMenubuttonAction)ProTestModelSave, NULL, BACKUP); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Rename", (ProMenubuttonAction)ProTestModelSave, NULL, RENAME); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Info", (ProMenubuttonAction)ProTestDbmsInfo, NULL, 0); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Close Cur Win", (ProMenubuttonAction)ProTestCurClose, NULL, 0); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-SolidFunctions", (ProMenubuttonAction)ProTestSolidFunc, NULL, 0); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-SolidProject", (ProMenubuttonAction)ProTestSolidProject, NULL, 0); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-MultipleOpen", (ProMenubuttonAction)ProTestModelMultipleOpen, NULL, 0); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"-Done", (ProMenubuttonAction) ProMenuDelete, NULL, 0); err = ProMenubuttonActionSet((char*)"TkDbms", (char*)"TkDbms", (ProMenubuttonAction) ProMenuDelete, NULL, 0); err = ProMenuCreate(PROMENUTYPE_MAIN, (char*)"TkDbms", &menu_id); err = ProMenuProcess((char*)"TkDbms", &action); return(0); }