/*====================================================================*\ FILE : UgPlotUse.c PURPOSE : Illustrates the functions for customized plot drivers HISTORY.. DATE BUILD AUTHOR MODIFICATIONS 04-dec-97 H-02-02 Stefan $$1 Setup \*====================================================================*/ /*---------------------- Pro/Toolkit Includes ------------------------*/ #include #include "ProMenu.h" /*---------------------- Pro/Develop Includes ------------------------*/ #include "prodevelop.h" #include "pro_intf.h" #include "prodtl_str.h" /*---------------------- Application Includes ------------------------*/ #include #include /*---------------------- Function Prototypes -------------------------*/ int user_Demo_Plot(); void user_demo_line (); void user_demo_text (); void user_demo_circle (); void user_demo_arc (); void user_demo_polyline (); void user_demo_filled_poly (); /*------------------------- External Data ----------------------------*/ extern int UserMenuDeleteAndPop(); /*------------------------- Global Data -----------------------------*/ static FILE *demo_plot_file; /*====================================================================* Function : UserPlotSetup() Purpose : Set up the Customized Plot Menu \*====================================================================*/ int UserPlotSetup() { int menu_id, action, status; ProMdl model; static char type[4], null[1], *type_list[] = {type, null}; /*-----------------------------------------------------------*\ Declare the plot format "demo". \*-----------------------------------------------------------*/ prointerface_create ("demo"); /*-----------------------------------------------------------*\ Make "demo" valid for Drawing mode. \*-----------------------------------------------------------*/ strcpy (type, "DRW"); strcpy (null, ""); prointerface_object_set ("demo", type_list); /*-----------------------------------------------------------*\ Bind the functions user_demo*() to the primitives for the format "demo". \*-----------------------------------------------------------*/ prointerface_load_function ("demo", PROINTF_LINE, user_demo_line); prointerface_load_function ("demo", PROINTF_TEXT, user_demo_text); prointerface_load_function ("demo", PROINTF_CIRCLE, user_demo_circle); prointerface_load_function ("demo", PROINTF_ARC, user_demo_arc); prointerface_load_function ("demo", PROINTF_POLYLINE, user_demo_polyline); prointerface_load_function ("demo", PROINTF_FILLED_POLY, user_demo_filled_poly); status = ProMenuFileRegister("UGPLOT", "ugplot.mnu", &menu_id); ERROR_CHECK( "UserPlotSetup", "ProMenuFileRegister", status ); status = ProMenubuttonActionSet("UGPLOT","-Plot Demo", user_Demo_Plot, NULL, 0); ERROR_CHECK( "UserPlotSetup", "ProMenubuttonActionSet", status ); status = ProMenubuttonActionSet("UGPLOT", "-Done/Return", UserMenuDeleteAndPop, NULL,0); ERROR_CHECK( "UserPlotSetup", "ProMenubuttonActionSet", status ); status = ProMenubuttonActionSet("UGPLOT", "UGPLOT", UserMenuDeleteAndPop, NULL, 0); ERROR_CHECK( "UserPlotSetup", "ProMenubuttonActionSet", status ); status = ProMenuCreate(PROMENUTYPE_MAIN, "UGPLOT", &menu_id); ERROR_CHECK( "UserPlotSetup", "ProMenuCreate", status ); status = ProMenuProcess("UGPLOT", &action); ERROR_CHECK( "UserPlotSetup", "ProMenuProcess", status ); return(PRO_TK_NO_ERROR); } /*===========================================================*\ Command function to invoke a plot of type "demo" \*===========================================================*/ int user_Demo_Plot() { int status; wchar_t w_fname[PRODEV_NAME_SIZE]; char fname[PRODEV_NAME_SIZE]; ProFileName msgfil; /*-----------------------------------------------------------*\ Get the output plot file name. \*-----------------------------------------------------------*/ ProStringToWstring( msgfil, "msg_ugfund.txt" ); status = ProMessageDisplay (msgfil, "USER Demo plot filename [QUIT] : "); ERROR_CHECK("user_Demo_Plot","ProMessageDisplay",status); status = ProMessageStringRead (PRODEV_NAME_SIZE, w_fname) ; ERROR_CHECK("user_Demo_Plot","ProMessageStringRead",status); if (status != PRO_TK_NO_ERROR) return(status); ProWstringToString (fname, w_fname); demo_plot_file = fopen (fname, "w"); /*-----------------------------------------------------------*\ Invoke the plot. \*-----------------------------------------------------------*/ status = prointerface_2d ("demo"); ERROR_CHECK("user_Demo_Plot","prointerface_2d",(status <=0)); /*-----------------------------------------------------------*\ Close and display the plot file. \*-----------------------------------------------------------*/ fclose (demo_plot_file); status = ProInfoWindowDisplay (w_fname, NULL, NULL); ERROR_CHECK("user_Demo_Plot","ProInfoWindowDisplay",status); return (PRO_TK_NO_ERROR); } /*===========================================================*\ Bound function for plotting a LINE in the format "demo". \*===========================================================*/ void user_demo_line (point1, point2, color) double point1[3], point2[3]; int color; { fprintf (demo_plot_file, "LINE..\n"); fprintf (demo_plot_file," point1 = %f, %f\n", point1[0], point1[1]); fprintf (demo_plot_file," point2 = %f, %f\n", point2[0], point2[1]); fprintf (demo_plot_file," color = %d\n", color); } /*===========================================================*\ Bound function for plotting a TEXT item in the format "demo". \*===========================================================*/ void user_demo_text (point, text, size, angle, slant_angle, width_factor, dummy, color) double point[3]; wchar_t *text; double size, angle, slant_angle, width_factor; int dummy, color; { char str[PRODTL_LINE_LEN]; fprintf (demo_plot_file, "TEXT..\n"); fprintf (demo_plot_file," point = %f, %f\n", point[0], point[1]); fprintf (demo_plot_file," text = %s\n", ProWstringToString (str, text)); fprintf (demo_plot_file," size = %f\n", size); fprintf (demo_plot_file," angle = %f\n", angle); fprintf (demo_plot_file," slant = %f\n", slant_angle); fprintf (demo_plot_file," width = %f\n", width_factor); fprintf (demo_plot_file," color = %d\n", color); } /*===========================================================*\ Bound function for plotting a CIRCLE in the format "demo" \*===========================================================*/ void user_demo_circle (center, radius, color) double center[3], radius; int color; { fprintf (demo_plot_file, "CIRCLE..\n"); fprintf (demo_plot_file," center = %f, %f\n", center[0], center[1]); fprintf (demo_plot_file," radius = %f\n", radius); fprintf (demo_plot_file," color = %d\n", color); } /*===========================================================*\ Bound function for plotting an ARC in the format "demo" \*===========================================================*/ void user_demo_arc (center, radius, point1, point2, t0, t1, color) double center[3], radius, point1[3], point2[3], t0, t1; int color; { fprintf (demo_plot_file, "ARC..\n"); fprintf (demo_plot_file," center = %f, %f\n", center[0], center[1]); fprintf (demo_plot_file," radius = %f\n", radius); fprintf (demo_plot_file," point1 = %f, %ff\n", point1[0], point1[1]); fprintf (demo_plot_file," point2 = %f, %ff\n", point2[0], point2[1]); fprintf (demo_plot_file," t1 = %f\n", t1); fprintf (demo_plot_file," color = %d\n", color); } /*===========================================================*\ Bound function for plotting a POLYLINE in the format "demo" \*===========================================================*/ void user_demo_polyline (n_pts, array, color) int n_pts; double array[][3]; int color; { int p; fprintf (demo_plot_file, "POLYLINE..\n"); for (p = 0; p < n_pts; p++) fprintf (demo_plot_file," Point %d = %f, %f\n", p, array[p][0], array[p][1]); fprintf (demo_plot_file," color = %d\n", color); } /*===========================================================*\ Bound function for plotting a FILLED POLYGON in the format "demo" \*===========================================================*/ void user_demo_filled_poly (n_pts, array, color) int n_pts; double array[][3]; int color; { int p; fprintf (demo_plot_file, "FILLED POLY..\n"); for (p = 0; p < n_pts; p++) fprintf (demo_plot_file," Point %d = %f, %f\n", p, array[p][0], array[p][1]); fprintf (demo_plot_file," color = %d\n", color); }