/* Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved. */ /*----------------------------------------------------------------------------*\ Pro/TOOLKIT includes \*----------------------------------------------------------------------------*/ #include "ProSelection.h" #include "ProMessage.h" #include "ProMenu.h" #include "ProMdl.h" #include "ProDrawing.h" #include "ProUtil.h" #include "ProWindows.h" #include "ProCsys.h" #include "ProDwgtable.h" #include "ProDrawingView.h" /*----------------------------------------------------------------------------*\ Application includes \*----------------------------------------------------------------------------*/ #include "UtilMessage.h" #include "UtilMenu.h" #include "UtilFiles.h" #include <ProTKRunTime.h> #include <UtilMatrix.h> /*----------------------------------------------------------------------------*\ Application macros \*----------------------------------------------------------------------------*/ #define SET_SCALE 1 #define MOVE 2 #define DELETE_VIEW 3 #define DISPLAY_STATUS 4 #define VIEW_PROJECTION 0 #define VIEW_GENERAL 1 #define DISPLAY_STYLE 0 #define QUILT_HRL 1 #define TAN_DISPLAY 2 #define CABLE_DISPLAY 3 #define CONCEPT_MODEL 4 #define WELD_XSEC 5 #define DRAWING_VIEWS ".dvw" ProError ProTestViewVisibleAreaFull(); ProError ProTestViewVisibleAreaHalf(); ProError ProTestViewMenuDeleteAndPop(); /*===========================================================================*\ Function : ProTestDrawingView Purpose : \*===========================================================================*/ int ProTestDrawingView(ProMdl *mod) { int menu_id; ProDrawing drawing; ProError err; int ProTestDwgInfo(ProDrawing drawing); int ProTestDwgViewModify(ProDrawing drawing, int arg); int ProTestViewCreate(ProDrawing drawing); ProError ProTestDwgViewName(ProDrawing drawing); ProError ProTestViewVisibleAreaSetup(); if (mod == NULL) err = ProMdlCurrentGet ((ProMdl*)&drawing); else drawing = (ProDrawing)*mod; err = ProMenuFileRegister((char*)"DrawView",(char*)"tkdrwview.mnu", &menu_id); err = ProMenubuttonActionSet((char*)"DrawView",(char*)"Info", (ProMenubuttonAction)ProTestDwgInfo, drawing, 0); err = ProMenubuttonActionSet((char*)"DrawView",(char*)"Set Scale", (ProMenubuttonAction)ProTestDwgViewModify, drawing, SET_SCALE); err = ProMenubuttonActionSet((char*)"DrawView",(char*)"Move", (ProMenubuttonAction)ProTestDwgViewModify, drawing, MOVE); err = ProMenubuttonActionSet((char*)"DrawView",(char*)"Delete", (ProMenubuttonAction)ProTestDwgViewModify, drawing, DELETE_VIEW); err = ProMenubuttonActionSet((char*)"DrawView",(char*)"SetDisplay", (ProMenubuttonAction)ProTestDwgViewModify, drawing, DISPLAY_STATUS); err = ProMenubuttonActionSet((char*)"DrawView",(char*)"Create", (ProMenubuttonAction)ProTestViewCreate, drawing, 0); err = ProMenubuttonActionSet((char*)"DrawView",(char*)"SetView Name", (ProMenubuttonAction)ProTestDwgViewName, drawing, 0); err = ProMenubuttonActionSet((char*)"DrawView",(char*)"Set Visible area", (ProMenubuttonAction)ProTestViewVisibleAreaSetup, NULL, 0); err = ProMenubuttonActionSet((char*)"DrawView",(char*)"DrawView", (ProMenubuttonAction)ProMenuDelete, NULL, 0); err = ProMenuCreate(PROMENUTYPE_MAIN, (char*)"DrawView",&menu_id); err = ProMenuProcess((char*)"", &menu_id); return (0); } /*===========================================================================*\ Function : ProTestViewInfoPrint Purpose : \*===========================================================================*/ int ProTestViewInfoPrint (ProDrawing drawing, ProView view, FILE *fp_dview) { ProSolid solid; ProError err; ProPoint3d out_line[2]; ProMdldata data; ProName name; ProMdlName modelName; ProMdlExtension modelExtension; ProCharLine model_name, type; double scale = 0.0; ProDrawingViewDisplay disp_status; char* ProTesDisplayStyleToStr(ProDisplayStyle ); char* ProTestTanedgeDisplayToStr(ProTanedgeDisplay ); char* ProTestCableDisplayToStr(ProCableDisplay ); err = ProDrawingViewSolidGet(drawing, view, &solid); TEST_CALL_REPORT ("ProDrawingViewSolidGet()", "ProTestDwgInfo()", err, err != PRO_TK_NO_ERROR); err = ProMdlMdlnameGet (ProSolidToMdl(solid), modelName); err = ProMdlExtensionGet (ProSolidToMdl(solid), modelExtension); ProWstringToString(model_name, modelName); ProWstringToString(type, modelExtension); ProTKFprintf(fp_dview, "Model displayed in a view:\t%s.%s\t\n", model_name, type); err = ProDrawingViewNameGet (drawing, view, name); TEST_CALL_REPORT ("ProDrawingViewNameGet()", "ProTestDwgInfo()", err, err != PRO_TK_NO_ERROR); ProTKFprintf(fp_dview, "View name: %s\n", ProWstringToString (model_name, name)); err = ProDrawingViewScaleGet(drawing, view, &scale); TEST_CALL_REPORT ("ProDrawingViewScaleGet()", "ProTestDwgInfo()", err, err != PRO_TK_NO_ERROR); err = ProDrawingViewDisplayGet (drawing, view, &disp_status); TEST_CALL_REPORT ("ProDrawingViewDisplayGet()", "ProTestDwgInfo()", err, err != PRO_TK_NO_ERROR); ProTKFprintf(fp_dview, "Display Style: %s\n", ProTesDisplayStyleToStr (disp_status.style)); ProTKFprintf(fp_dview, "Tanedge Display: %s\n", ProTestTanedgeDisplayToStr (disp_status.tangent_edge_display)); ProTKFprintf(fp_dview, "Cable Display: %s\n", ProTestCableDisplayToStr (disp_status.cable_display)); ProTKFprintf(fp_dview, "Quilt Hlr: %s\n", disp_status.quilt_hlr ? "TRUE" : "FALSE" ); ProTKFprintf(fp_dview, "Concept Model: %s\n", disp_status.concept_model ? "TRUE" : "FALSE" ); ProTKFprintf(fp_dview, "Weld Xsec: %s\n", disp_status.weld_xsec ? "TRUE" : "FALSE" ); err = ProDrawingViewOutlineGet (drawing, view, out_line); TEST_CALL_REPORT ("ProDrawingViewOutlineGet()", "ProTestDwgInfo()", err, err != PRO_TK_NO_ERROR); ProTKFprintf(fp_dview, "Out line: x_pnt[1] = %6.1f x_pnt[2] = %6.1f " "x_pnt[3] = %6.1f\n", out_line[0][0], out_line[0][1], out_line[0][2]); ProTKFprintf(fp_dview, "Out line: y_pnt[1] = %6.1f y_pnt[2] = %6.1f " "y_pnt[3] = %6.1f\n", out_line[1][0], out_line[1][1], out_line[1][2]); return(0); } /*===========================================================================*\ Function : ProTestDwgInfo Purpose : \*===========================================================================*/ int ProTestDwgInfo(ProDrawing drawing) { ProCharLine fname; ProName wfname; FILE *fp_dview; ProError err; int n_views = 0, i; ProView *views = NULL; fp_dview = ProUtilGenFilePtr((ProMdl)drawing, (char*)DRAWING_VIEWS, fname, (char*)"w"); if (fp_dview == NULL) return (-1); ProTKFprintf(fp_dview, "File name : %s\n", fname); err = ProDrawingViewsCollect(drawing, &views); TEST_CALL_REPORT ("ProDrawingViewsCollect()", "ProTestDwgInfo()", err, err != PRO_TK_NO_ERROR && err != PRO_TK_E_NOT_FOUND); if (err == PRO_TK_NO_ERROR) { err = ProArraySizeGet(views, &n_views); TEST_CALL_REPORT ("ProArraySizeGet()", "ProTestDwgInfo()", err, err != PRO_TK_NO_ERROR); for(i = 0; i < n_views; i++) { ProTKFprintf(fp_dview, "\nView(%d) ", i); ProTestViewInfoPrint (drawing, views[i], fp_dview); } } err = ProArrayFree ((ProArray*)&views); fclose(fp_dview); ProStringToWstring(wfname, fname); err = ProInfoWindowDisplay(wfname, NULL, NULL); return (0); } /*===========================================================================*\ Function : ProTestViewDispChoose Purpose : \*===========================================================================*/ int ProTestViewDispChoose (ProDrawingViewDisplay *disp_status) { ProError err; int menu_id; void ProTestViewDispSet (ProDrawingViewDisplay *, int ); err = ProMenuFileRegister((char*)"ViewDisplay",(char*)"tkviewdisp.mnu", &menu_id); err = ProMenubuttonActionSet((char*)"ViewDisplay",(char*)"ViewDisplay", (ProMenubuttonAction)ProMenuDelete, NULL, 0); err = ProMenubuttonActionSet((char*)"ViewDisplay",(char*)"DispStyle", (ProMenubuttonAction)ProTestViewDispSet, disp_status, DISPLAY_STYLE); err = ProMenubuttonActionSet((char*)"ViewDisplay",(char*)"QuiltHrl", (ProMenubuttonAction)ProTestViewDispSet, disp_status, QUILT_HRL); err = ProMenubuttonActionSet((char*)"ViewDisplay",(char*)"TanDisplay", (ProMenubuttonAction)ProTestViewDispSet, disp_status, TAN_DISPLAY); err = ProMenubuttonActionSet((char*)"ViewDisplay",(char*)"CableDisplay", (ProMenubuttonAction)ProTestViewDispSet, disp_status, CABLE_DISPLAY); err = ProMenubuttonActionSet((char*)"ViewDisplay",(char*)"ConceptModel", (ProMenubuttonAction)ProTestViewDispSet, disp_status, CONCEPT_MODEL); err = ProMenubuttonActionSet((char*)"ViewDisplay",(char*)"WeldXsec", (ProMenubuttonAction)ProTestViewDispSet, disp_status, WELD_XSEC); err = ProMenubuttonActionSet((char*)"ViewDisplay",(char*)"Done", (ProMenubuttonAction)ProMenuDelete, NULL, 0); err = ProMenuCreate(PROMENUTYPE_MAIN, (char*)"ViewDisplay",&menu_id); err = ProMenuProcess((char*)"ViewDisplay", &menu_id); return (0); } /*===========================================================================*\ Function : ProTestDwgViewModify Purpose : \*===========================================================================*/ int ProTestDwgViewModify(ProDrawing drawing, int arg) { double scale; ProCharLine message, astr; ProModelitem sel_item; ProBoolean delete_children; ProSelection *sel; ProView view; ProError err; ProSolid solid; int n_sel, view_id = 0; ProPoint3d pnt, to_pnt, sel_pnt; ProVector tvec; ProMatrix trans; ProMouseButton btn; ProDrawingViewDisplay disp_status; /* Pick the view */ ProUtilMsgPrint("gen", "TEST %0s", "Select a feature to identify a view"); err = ProSelect((char*)"feature", 1, NULL, NULL, NULL, NULL, &sel, &n_sel); if (n_sel <= 0 || err!=PRO_TK_NO_ERROR) return (0); err = ProSelectionViewGet(sel[0], &view); TEST_CALL_REPORT ("ProSelectionViewGet()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); err = ProSelectionPoint3dGet (sel[0], pnt); TEST_CALL_REPORT ("ProSelectionViewGet()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); err = ProSelectionModelitemGet (sel[0], &sel_item); TEST_CALL_REPORT ("ProSelectionViewGet()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); err = ProDrawingViewIdGet(drawing, view, &view_id); err = ProDrawingViewTransformGet (drawing, view, PRO_B_TRUE, trans); TEST_CALL_REPORT ("ProDrawingViewTransformGet()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); err = ProPntTrfEval (pnt, trans, sel_pnt); TEST_CALL_REPORT ("ProPntTrfEval()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); switch (arg) { case SET_SCALE : /* Set the view scale */ /* Get the current scale to use as a default */ err = ProDrawingViewScaleGet(drawing, view, &scale); TEST_CALL_REPORT ("ProDrawingViewScaleGet()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); ProTKSprintf(message,"scale [%5.2f] ",scale); ProTKSprintf(astr, "Enter %s: ", message); ProUtilMsgPrint("gen", "TEST %0s", astr); if(ProMessageDoubleRead(NULL, &scale) != PRO_TK_NO_ERROR) return (0); err = ProDrawingViewScaleSet(drawing, view, scale); TEST_CALL_REPORT ("ProDrawingViewScaleSet()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); break; case MOVE : /* Translate the view */ ProUtilMsgPrint("gen", "TEST %0s", "Select the new position: "); err = ProMousePickGet(PRO_LEFT_BUTTON, &btn, to_pnt); TEST_CALL_REPORT ("ProMousePickGet()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); tvec[0] = to_pnt[0] - sel_pnt[0]; tvec[1] = to_pnt[1] - sel_pnt[1]; tvec[2] = to_pnt[2] - sel_pnt[2]; err = ProDrawingViewMove(drawing, view, tvec); TEST_CALL_REPORT ("ProDrawingViewMove()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); break; case DELETE_VIEW : ProUtilMsgPrint("gen", "TEST %0s", "Delete children too [N] ?"); delete_children = (ProBoolean)ProUtilYesnoGet((char*)"No"); err = ProDrawingViewSolidGet (drawing, view, &solid); TEST_CALL_REPORT ("ProDrawingViewSolidGet()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); err = ProDrawingViewDelete(drawing, view, delete_children); TEST_CALL_REPORT ("ProDrawingViewDelete()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); break; case DISPLAY_STATUS : err = ProDrawingViewDisplayGet (drawing, view, &disp_status); TEST_CALL_REPORT ("ProDrawingViewDisplayGet()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); ProTestViewDispChoose (&disp_status); err = ProDrawingViewDisplaySet (drawing, view, &disp_status); TEST_CALL_REPORT ("ProDrawingViewDisplaySet()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); break; default: break; } err = ProWindowRepaint (PRO_VALUE_UNUSED); TEST_CALL_REPORT ("ProWindowRepaint()", "ProTestDwgViewModify()", err, err != PRO_TK_NO_ERROR); return (0); } /*===========================================================================*\ Function : ProTestViewDispSet Purpose : \*===========================================================================*/ void ProTestViewDispSet (ProDrawingViewDisplay *disp_status, int action) { ProError err; static ProUtilMenuButtons disp_style[] = { {"DisplayStyle", 0, TEST_CALL_PRO_MENU_DELETE}, {"Default", PRO_DISPSTYLE_DEFAULT, 0}, {"Wireframe", PRO_DISPSTYLE_WIREFRAME, 0}, {"HiddenLine", PRO_DISPSTYLE_HIDDEN_LINE, 0}, {"NoHidden", PRO_DISPSTYLE_NO_HIDDEN, 0}, {"Shaded", PRO_DISPSTYLE_SHADED, 0}, {"FollowEnvironment", PRO_DISPSTYLE_FOLLOW_ENVIRONMENT, 0}, {"",0,0} }; static ProUtilMenuButtons cab_disp[] = { {"CableDisplay", 0, TEST_CALL_PRO_MENU_DELETE}, {"Default", PRO_CABLEDISP_DEFAULT, 0}, {"Centerline", PRO_CABLEDISP_CENTERLINE, 0}, {"Thick", PRO_CABLEDISP_THICK, 0}, {"",0,0} }; static ProUtilMenuButtons tang_disp[] = { {"TanedgeDisplay", 0, TEST_CALL_PRO_MENU_DELETE}, {"Default", PRO_TANEDGE_DEFAULT, 0}, {"None", PRO_TANEDGE_NONE, 0}, {"Centerline", PRO_TANEDGE_CENTERLINE, 0}, {"Phantom", PRO_TANEDGE_PHANTOM, 0}, {"Dimmed", PRO_TANEDGE_DIMMED, 0}, {"Solid", PRO_TANEDGE_SOLID, 0}, {"",0,0} }; switch (action) { case DISPLAY_STYLE: err = ProUtilMenuIntValueSelect(disp_style, (int*)&disp_status->style); break; case QUILT_HRL: ProUtilMsgPrint("gen", "TEST %0s", "Quilt hrl (Yes/No)? [N]:"); disp_status->quilt_hlr = (ProBoolean)ProUtilYesnoGet ((char*)"No"); break; case TAN_DISPLAY: err = ProUtilMenuIntValueSelect(tang_disp, (int*)&disp_status->tangent_edge_display); break; case CABLE_DISPLAY: err = ProUtilMenuIntValueSelect(cab_disp, (int*)&disp_status->cable_display); break; case CONCEPT_MODEL: ProUtilMsgPrint("gen", "TEST %0s", "Concept Model (Yes/No)? [N]:"); disp_status->concept_model = (ProBoolean)ProUtilYesnoGet ((char*)"No"); break; case WELD_XSEC: ProUtilMsgPrint("gen", "TEST %0s", "Weld Xsec (Yes/No)? [N]:"); disp_status->weld_xsec = (ProBoolean)ProUtilYesnoGet ((char*)"No"); break; default: break; } } /*===========================================================================*\ Function : ProTestViewCreate Purpose : \*===========================================================================*/ int ProTestViewCreate(ProDrawing drawing) { ProError err; ProSolid solid = NULL; ProModelitem sel_item; ProSelection *sel; int n_sheet = 0, view_type = 0, n_sel = 0, win_id, old_win_id; ProBoolean exploded = PRO_B_FALSE; ProPoint3d sel_pnt; double scale = 0.0; ProView view, parent_view; ProCharLine sel_path, line; ProPath current_dir, ch_dir, def_path; ProType type; ProMdlName w_name; ProMdlExtension w_type; ProMouseButton btn; ProCsys csys; ProBoolean tree_flag=PRO_B_FALSE; ProMatrix orientation; ProMatrix def_matrix = { { 0.921061, 0.000000, 0.389418, 0.000000}, {-0.305042, 0.621610, 0.721492, 0.000000}, {-0.242066, -0.783327, 0.572541, 0.000000}, { 0.000000, 0.000000, 0.000000, 1.000000} }; ProGeomitemdata* p_csys_data_ptr; static ProUtilMenuButtons create_opt[] = { {"CreateOpt", 0, TEST_CALL_PRO_MENU_DELETE}, {"General", VIEW_GENERAL, 0}, {"Projection", VIEW_PROJECTION, 0}, {"",0,0} }; err = ProUtilMenuIntValueSelect(create_opt, &view_type); err = ProDrawingCurrentSheetGet (drawing, &n_sheet); TEST_CALL_REPORT ("ProDrawingCurrentSheetGet()", "ProTestViewCreate()", err, err != PRO_TK_NO_ERROR); if (view_type) { err = ProUtilFileOpen ((char*)"*.*", sel_path); if (err != PRO_TK_NO_ERROR) return (0); err = ProDirectoryCurrentGet(current_dir); ProStringToWstring (ch_dir, sel_path); err = ProFileMdlnameParse(ch_dir, def_path, w_name, w_type, NULL); err = ProDirectoryChange(def_path); err = ProPathMdlnameCreate(NULL, w_name, w_type, PRO_VALUE_UNUSED, def_path); ProWstringToString(line, def_path); if(ProUtilConfirmNameType(line, sel_path, &type) != PRO_TK_BAD_INPUTS) { err = ProMdlnameRetrieve(w_name, (ProMdlfileType)type, (ProMdl*)&solid); TEST_CALL_REPORT ("ProMdlnameRetrieve()", "ProTestViewCreate()", err, err != PRO_TK_NO_ERROR); } err = ProDirectoryChange(current_dir); err = ProDrawingSolidAdd(drawing, solid); TEST_CALL_REPORT ("ProDrawingSolidAdd()", "ProTestViewCreate()", err, err != PRO_TK_NO_ERROR && err != PRO_TK_E_IN_USE); if (type == PRO_ASSEMBLY) { ProUtilMsgPrint("gen", "TEST %0s", "Create exploded view? [N]:"); exploded = (ProBoolean)ProUtilYesnoGet ((char*)"No"); } ProUtilMsgPrint("gen", "TEST %0s", "Pick point for view"); while(ProMousePickGet(PRO_LEFT_BUTTON, &btn, sel_pnt) != PRO_TK_NO_ERROR); sel_pnt[2] = 0; ProUtilMsgPrint("gen", "TEST %0s", "Enter view scale factor"); if (ProMessageDoubleRead(NULL, &scale) != PRO_TK_NO_ERROR) return (0); err = ProWindowCurrentGet(&old_win_id); err= ProAccessorywindowWithTreeMdlnameCreate(w_name,type,tree_flag, &win_id); err = ProMdlDisplay(solid); err = ProWindowCurrentSet(win_id); ProUtilMsgPrint("gen", "TEST %0s", "Select csys"); err = ProSelect((char*)"csys", 1, NULL, NULL, NULL, NULL, &sel, &n_sel); if (err != PRO_TK_NO_ERROR || n_sel < 1) ProUtilMatrixCopy (def_matrix, orientation); else { ProUtilMatrixCopy (NULL, orientation); err = ProSelectionModelitemGet (sel[0], &sel_item); err = ProCsysInit (solid, sel_item.id, &csys); err = ProCsysDataGet(csys, &p_csys_data_ptr); p_csys_data_ptr->data.p_csys_data->origin[0] = p_csys_data_ptr->data.p_csys_data->origin[1] = p_csys_data_ptr->data.p_csys_data->origin[2] = 0.0; err = ProMatrixInit(p_csys_data_ptr->data.p_csys_data->x_vector, p_csys_data_ptr->data.p_csys_data->y_vector, p_csys_data_ptr->data.p_csys_data->z_vector, p_csys_data_ptr->data.p_csys_data->origin, orientation); } ProWindowCurrentSet(old_win_id); ProWindowDelete(win_id); err = ProDrawingGeneralviewCreate (drawing, solid, n_sheet, exploded, sel_pnt, scale, orientation, &view); TEST_CALL_REPORT ("ProDrawingGeneralviewCreate()", "ProTestViewCreate()", err, err != PRO_TK_NO_ERROR); } else { ProUtilMsgPrint("gen", "TEST %0s", "Select a parent view."); err = ProSelect((char*)"feature", 1, NULL, NULL, NULL, NULL, &sel, &n_sel); if (err != PRO_TK_NO_ERROR || n_sel < 1) return (0); err = ProSelectionViewGet(sel[0], &parent_view); TEST_CALL_REPORT ("ProSelectionViewGet()", "ProTestViewCreate()", err, err != PRO_TK_NO_ERROR); err = ProSelectionModelitemGet (sel[0], &sel_item); TEST_CALL_REPORT ("ProSelectionModelitemGet()", "ProTestViewCreate()", err, err != PRO_TK_NO_ERROR); err = ProMdlTypeGet (sel_item.owner, (ProMdlType*)&type); TEST_CALL_REPORT ("ProMdlTypeGet()", "ProTestViewCreate()", err, err != PRO_TK_NO_ERROR); if (type == PRO_ASSEMBLY) { ProUtilMsgPrint("gen", "TEST %0s", "Create exploded view? [N]:"); exploded = (ProBoolean)ProUtilYesnoGet ((char*)"No"); } ProUtilMsgPrint("gen", "TEST %0s", "Pick point for view"); while (ProMousePickGet(PRO_LEFT_BUTTON, &btn, sel_pnt) != PRO_TK_NO_ERROR); err = ProDrawingProjectedviewCreate (drawing, parent_view, exploded, sel_pnt, &view); TEST_CALL_REPORT ("ProDrawingProjectedviewCreate()", "ProTestViewCreate()", err, err != PRO_TK_NO_ERROR); } return (0); } /*===========================================================================*\ Function : ProTesDisplayStyleToStr Purpose : \*===========================================================================*/ char* ProTesDisplayStyleToStr( ProDisplayStyle type ) { switch (type) { case PRO_DISPSTYLE_DEFAULT : return (char*)"DEFAULT"; case PRO_DISPSTYLE_WIREFRAME : return (char*)"WIREFRAME"; case PRO_DISPSTYLE_HIDDEN_LINE : return (char*)"HIDDEN_LINE"; case PRO_DISPSTYLE_NO_HIDDEN: return (char*)"NO_HIDDEN"; case PRO_DISPSTYLE_SHADED : return (char*)"SHADED"; case PRO_DISPSTYLE_FOLLOW_ENVIRONMENT: return (char*)"FOLLOW ENVIRONMENT"; default : return (char*)"INVALID"; } } /*===========================================================================*\ Function : ProTestTanedgeDisplayToStr Purpose : \*===========================================================================*/ char* ProTestTanedgeDisplayToStr( ProTanedgeDisplay type ) { switch (type) { case PRO_TANEDGE_DEFAULT : return (char*)"DEFAULT"; case PRO_TANEDGE_NONE : return (char*)"NONE"; case PRO_TANEDGE_CENTERLINE : return (char*)"CENTERLINE"; case PRO_TANEDGE_PHANTOM: return (char*)"PHANTOM"; case PRO_TANEDGE_DIMMED : return (char*)"DIMMED"; case PRO_TANEDGE_SOLID : return (char*)"SOLID"; default : return (char*)"INVALID"; } } /*===========================================================================*\ Function : ProTesDisplayStyleToStr Purpose : \*===========================================================================*/ char* ProTestCableDisplayToStr( ProCableDisplay type ) { switch (type) { case PRO_CABLEDISP_DEFAULT : return (char*)"DEFAULT"; case PRO_CABLEDISP_CENTERLINE : return (char*)"CENTERLINE"; case PRO_CABLEDISP_THICK: return (char*)"THICK"; default : return (char*)"INVALID"; } } /*====================================================================* Function : ProTestDwgViewName Purpose : To set view name \*====================================================================*/ ProError ProTestDwgViewName (ProDrawing drawing) { ProSelection *view_sel; int num_sel,max_length = 32; ProName string; ProView view; ProError status; ProFileName WMSGFIL = {'u','s','e','r','m','s','g','.','t','x','t','\0'}; /*------------------------------------------------------------*\ Get the current model \*------------------------------------------------------------*/ status = ProMdlCurrentGet ((ProMdl*)&drawing); TEST_CALL_REPORT ("ProMdlCurrentGet", "ProTestDwgViewName", status, status != PRO_TK_NO_ERROR); if (status != PRO_TK_NO_ERROR) return(status); /*------------------------------------------------------------*\ Get view to set view name \*------------------------------------------------------------*/ status = ProMessageDisplay (WMSGFIL, (char*)"USER %0s", "Select view to set view name"); TEST_CALL_REPORT ("ProMessageDisplay", "ProTestDwgViewName", status, status != PRO_TK_NO_ERROR); status = ProSelect ((char*)"dwg_view", 1, NULL, NULL, NULL, NULL, &view_sel, &num_sel); TEST_CALL_REPORT ("ProSelect", "ProTestDwgViewName", status, status != PRO_TK_NO_ERROR); if (status != PRO_TK_NO_ERROR) return(status); status = ProSelectionViewGet (view_sel[0], &view); TEST_CALL_REPORT ("ProSelectionViewGet", "ProTestDwgViewName", status, status != PRO_TK_NO_ERROR); /*------------------------------------------------------------*\ Get view name to set \*------------------------------------------------------------*/ status = ProMessageDisplay (WMSGFIL, (char*)"USER %0s", "Enter view name to set"); TEST_CALL_REPORT ("ProMessageDisplay", "ProTestDwgViewName", status, status != PRO_TK_NO_ERROR); status = ProMessageStringRead (max_length, string); TEST_CALL_REPORT ("ProMessageStringRead", "ProTestDwgViewName", status, status != PRO_TK_NO_ERROR); status = ProDrawingViewNameSet (drawing, view, string); TEST_CALL_REPORT ("ProDrawingViewNameSet", "ProTestDwgViewName", status, status != PRO_TK_NO_ERROR); status = ProDrawingtreeRefresh (drawing, PRO_VALUE_UNUSED); TEST_CALL_REPORT ("ProDrawingtreeRefresh", "ProTestDwgViewName", status, status != PRO_TK_NO_ERROR); return (status); } /*====================================================================* Function : ProTestViewMenuDeleteAndPop() Purpose : Deletes the current menu and pops up its parent \*====================================================================*/ ProError ProTestViewMenuDeleteAndPop() { ProError status; status = ProMenuDelete(); TEST_CALL_REPORT ("ProMenuDelete", "ProTestViewMenuDeleteAndPop", status, status != PRO_TK_NO_ERROR ); status = ProMenuPop(); TEST_CALL_REPORT ("ProMenuPop", "ProTestViewMenuDeleteAndPop", status, status != PRO_TK_NO_ERROR ); return (PRO_TK_NO_ERROR); } /*====================================================================* Function : ProTestViewVisibleAreaSetup Purpose : Setup the Visible area menu of the User Guide example \*====================================================================*/ ProError ProTestViewVisibleAreaSetup () { int menu_id, action; ProError status; status = ProMenuFileRegister ((char*)"TKViewVisibleArea", (char*)"tkviewvisiblearea.mnu", &menu_id); TEST_CALL_REPORT ("ProMenuFileRegister", "ProTestViewVisibleAreaSetup", status, status != PRO_TK_NO_ERROR); status = ProMenubuttonActionSet ((char*)"TKViewVisibleArea", (char*)"Full View", (ProMenubuttonAction)ProTestViewVisibleAreaFull, NULL, 0); TEST_CALL_REPORT ("ProMenubuttonActionSet", "ProTestViewVisibleAreaSetup", status, status != PRO_TK_NO_ERROR ); status = ProMenubuttonActionSet ((char*)"TKViewVisibleArea", (char*)"Half View", (ProMenubuttonAction)ProTestViewVisibleAreaHalf, NULL, 0); TEST_CALL_REPORT ("ProMenubuttonActionSet", "ProTestViewVisibleAreaSetup", status, status != PRO_TK_NO_ERROR ); status = ProMenubuttonActionSet ((char*)"TKViewVisibleArea", (char*)"Done/Return", (ProMenubuttonAction)ProTestViewMenuDeleteAndPop, NULL, 0); TEST_CALL_REPORT ("ProMenubuttonActionSet", "ProTestViewVisibleAreaSetup", status, status != PRO_TK_NO_ERROR ); status = ProMenubuttonActionSet ((char*)"TKViewVisibleArea", (char*)"TKViewVisibleArea", (ProMenubuttonAction)ProTestViewMenuDeleteAndPop, NULL, 0); TEST_CALL_REPORT ("ProMenubuttonActionSet", "ProTestViewVisibleAreaSetup", status, status != PRO_TK_NO_ERROR ); status = ProMenuPush(); TEST_CALL_REPORT ("ProMenuPush", "ProTestViewVisibleAreaSetup", status, status != PRO_TK_NO_ERROR ); status = ProMenuCreate (PROMENUTYPE_MAIN, (char*)"TKViewVisibleArea", &menu_id); TEST_CALL_REPORT ("ProMenuCreate", "ProTestViewVisibleAreaSetup", status, status != PRO_TK_NO_ERROR ); status = ProMenuProcess ((char*)"TKViewVisibleArea", &action); TEST_CALL_REPORT ("ProMenuProcess", "ProTestViewVisibleAreaSetup", status, status != PRO_TK_NO_ERROR); return (status); } /*====================================================================* Function : ProTestViewVisibleAreaFull Purpose : To set full visible area for view \*====================================================================*/ ProError ProTestViewVisibleAreaFull () { ProError status; ProDrawing drawing; ProView view; ProSelection *view_sel; int num_sel; ProFileName WMSGFIL = {'u','s','e','r','m','s','g','.','t','x','t','\0'}; /*------------------------------------------------------------*\ Get the current model \*------------------------------------------------------------*/ status = ProMdlCurrentGet ((ProMdl*)&drawing); TEST_CALL_REPORT ("ProMdlCurrentGet", "ProTestViewVisibleAreaFull", status, status != PRO_TK_NO_ERROR); if (status != PRO_TK_NO_ERROR) return(status); /*------------------------------------------------------------*\ Get view to set visible \*------------------------------------------------------------*/ status = ProMessageDisplay (WMSGFIL, (char*)"USER %0s", "Select view to set visible area"); TEST_CALL_REPORT ("ProMessageDisplay", "ProTestViewVisibleAreaFull", status, status != PRO_TK_NO_ERROR); status = ProSelect ((char*)"dwg_view", 1, NULL, NULL, NULL, NULL, &view_sel, &num_sel); TEST_CALL_REPORT ("ProSelect", "ProTestViewVisibleAreaFull", status, status != PRO_TK_NO_ERROR); if (status != PRO_TK_NO_ERROR) return(status); status = ProSelectionViewGet (view_sel[0], &view); TEST_CALL_REPORT ("ProSelectionViewGet", "ProTestViewVisibleAreaFull", status, status != PRO_TK_NO_ERROR); status = ProDrawingViewFullVisibleAreaSet (drawing, view); TEST_CALL_REPORT ("ProDrawingViewFullVisibleAreaSet", "ProTestViewVisibleAreaFull", status, status != PRO_TK_NO_ERROR); status = ProDrawingViewRegenerate (drawing, view); TEST_CALL_REPORT ("ProDrawingViewRegenerate", "ProTestViewVisibleAreaFull", status, status != PRO_TK_NO_ERROR); return (status); } /*====================================================================* Function : ProTestViewVisibleAreaHalf Purpose : To set half visible area for view \*====================================================================*/ ProError ProTestViewVisibleAreaHalf () { ProDrawing drawing; ProSelection *view_sel,*plane_sel; int num_sel,num_plane; ProView view; ProError status; ProFileName WMSGFIL = {'u','s','e','r','m','s','g','.','t','x','t','\0'}; /*------------------------------------------------------------*\ Get the current model \*------------------------------------------------------------*/ status = ProMdlCurrentGet ((ProMdl*)&drawing); TEST_CALL_REPORT ("ProMdlCurrentGet", "ProTestViewVisibleAreaHalf", status, status != PRO_TK_NO_ERROR); if (status != PRO_TK_NO_ERROR) return(status); /*------------------------------------------------------------*\ Get view to set visible \*------------------------------------------------------------*/ status = ProMessageDisplay(WMSGFIL, (char*)"USER %0s", "Select view to set visible area"); TEST_CALL_REPORT ("ProMessageDisplay", "ProTestViewVisibleAreaHalf", status, status != PRO_TK_NO_ERROR); status = ProSelect ((char*)"dwg_view", 1, NULL, NULL, NULL, NULL, &view_sel, &num_sel); TEST_CALL_REPORT ("ProSelect", "ProTestViewVisibleAreaHalf", status, status != PRO_TK_NO_ERROR); if (status != PRO_TK_NO_ERROR) return(status); status = ProSelectionViewGet (view_sel[0], &view); TEST_CALL_REPORT ("ProSelectionViewGet", "ProTestViewVisibleAreaHalf", status, status != PRO_TK_NO_ERROR); /*------------------------------------------------------------*\ Get plane to set visible \*------------------------------------------------------------*/ status = ProMessageDisplay (WMSGFIL,(char*)"USER %0s", "Select plane"); TEST_CALL_REPORT ("ProMessageDisplay", "ProTestViewVisibleAreaHalf", status, status != PRO_TK_NO_ERROR); status = ProSelect ((char*)"datum", 1, NULL, NULL, NULL, NULL, &plane_sel, &num_plane ); TEST_CALL_REPORT ("ProSelect", "ProTestViewVisibleAreaHalf", status, status != PRO_TK_NO_ERROR); if (status != PRO_TK_NO_ERROR) return(status); status = ProDrawingViewHalfVisibleAreaSet (drawing, view, plane_sel[0], PRO_B_TRUE, PRO_HVL_SOLID); TEST_CALL_REPORT ("ProDrawingViewHalfVisibleAreaSet","ProTestViewVisibleAreaHalf", status, status != PRO_TK_NO_ERROR); status = ProDrawingViewRegenerate (drawing, view); TEST_CALL_REPORT ("ProDrawingViewRegenerate", "ProTestViewVisibleAreaHalf", status, status != PRO_TK_NO_ERROR); return (status); }