/*
Copyright (c) 2019 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/
/*---------------------- Pro/Toolkit Includes ------------------------*/
#include <ProToolkit.h>
#include <ProPlotdriver.h>
#include <ProArray.h>
#include <ProColor.h>
#include <PTApplsUnicodeUtils.h>
#include <ProMessage.h>
#include <ProUtil.h>
/*---------------------- Application Includes ------------------------*/
#include <TestError.h>
#include <string.h>
/*---------------------- Function Prototypes -------------------------*/
ProError user_demo_line ();
ProError user_demo_text ();
ProError user_demo_circle ();
ProError user_demo_arc ();
ProError user_demo_polyline ();
ProError user_demo_filled_poly ();
static FILE *demo_output;
/*===========================================================*\
ProDriverExecute call
\*===========================================================*/
ProError user_plot(FILE *fp, char *driver_name)
{
ProError status;
ProName *type_list;
ProAppData data;
ProLine app_name;
demo_output = fp;
ProStringToWstring(app_name, driver_name);
data = (ProAppData) &app_name;
/*-----------------------------------------------------------*\
Declare the plot format "demo".
\*-----------------------------------------------------------*/
status = ProPlotdriverInterfaceCreate (L"demo");
/*-----------------------------------------------------------*\
Make "demo" valid for Drawing mode.
\*-----------------------------------------------------------*/
status = ProArrayAlloc(2, sizeof(ProName), 1, (ProArray*) &type_list);
ProStringToWstring(type_list[0], "DRW");
ProStringToWstring(type_list[1], "");
status = ProPlotdriverInterfaceobjectsSet (L"demo", type_list);
/*-----------------------------------------------------------*\
Bind the functions user_demo*() to the primitives for
the format "demo".
\*-----------------------------------------------------------*/
status = ProPlotdriverLinefunctionSet(L"demo", user_demo_line);
status = ProPlotdriverTextfunctionSet(L"demo", user_demo_text);
status = ProPlotdriverCirclefunctionSet(L"demo", user_demo_circle);
status = ProPlotdriverArcfunctionSet(L"demo", user_demo_arc);
status = ProPlotdriverPolylinefunctionSet(L"demo", user_demo_polyline);
status = ProPlotdriverPolygonfunctionSet(L"demo", user_demo_filled_poly);
/*-----------------------------------------------------------*\
Invoke the plot.
\*-----------------------------------------------------------*/
status = ProPlotdriverExecute (L"demo", data);
ERROR_CHECK("user_plot","ProPlotdriverExecute",(status != PRO_TK_NO_ERROR));
demo_output = NULL;
return status;
}
/*===========================================================*\
Bound function for plotting a LINE in the format "demo".
\*===========================================================*/
ProError user_demo_line (data, point1, point2, color)
ProAppData data;
double point1[3],
point2[3];
int color;
{
ProLine *app_name = (ProLine *)data;
ProTKFprintf (demo_output, "%ws: LINE..\n", app_name);
ProTKFprintf (demo_output," point1 = %f, %f\n",
point1[0], point1[1]);
ProTKFprintf (demo_output," point2 = %f, %f\n",
point2[0], point2[1]);
ProTKFprintf (demo_output," color = %d\n", color);
return PRO_TK_NO_ERROR;
}
/*===========================================================*\
Bound function for plotting a TEXT item in the format
"demo".
\*===========================================================*/
ProError user_demo_text (data, point, text, size, angle, slant_angle,
width_factor, dummy, color)
ProAppData data;
double point[3];
wchar_t *text;
double size,
angle,
slant_angle,
width_factor;
int dummy, color;
{
char str[PRO_LINE_SIZE];
ProLine *app_name = (ProLine *)data;
ProTKFprintf (demo_output, "%ws: TEXT..\n", app_name);
ProTKFprintf (demo_output," point = %f, %f\n", point[0],
point[1]);
ProTKFprintf (demo_output," text = %s\n", ProWstringToString
(str, text));
ProTKFprintf (demo_output," size = %f\n", size);
ProTKFprintf (demo_output," angle = %f\n", angle);
ProTKFprintf (demo_output," slant = %f\n", slant_angle);
ProTKFprintf (demo_output," width = %f\n", width_factor);
ProTKFprintf (demo_output," color = %d\n", color);
return PRO_TK_NO_ERROR;
}
/*===========================================================*\
Bound function for plotting a CIRCLE in the format "demo"
\*===========================================================*/
ProError user_demo_circle (data, center, radius, color)
ProAppData data;
double center[3],
radius;
int color;
{
ProLine *app_name = (ProLine *)data;
ProTKFprintf (demo_output, "%ws: CIRCLE..\n, app_name");
ProTKFprintf (demo_output," center = %f, %f\n", center[0],
center[1]);
ProTKFprintf (demo_output," radius = %f\n", radius);
ProTKFprintf (demo_output," color = %d\n", color);
return PRO_TK_NO_ERROR;
}
/*===========================================================*\
Bound function for plotting an ARC in the format "demo"
\*===========================================================*/
ProError user_demo_arc (data, center, radius, point1, point2, t0, t1,
color)
ProAppData data;
double center[3],
radius,
point1[3],
point2[3],
t0,
t1;
int color;
{
ProLine *app_name = (ProLine *)data;
ProTKFprintf (demo_output, "%ws: ARC..\n", app_name);
ProTKFprintf (demo_output," center = %f, %f\n", center[0],
center[1]);
ProTKFprintf (demo_output," radius = %f\n", radius);
ProTKFprintf (demo_output," point1 = %f, %ff\n", point1[0],
point1[1]);
ProTKFprintf (demo_output," point2 = %f, %ff\n", point2[0],
point2[1]);
ProTKFprintf (demo_output," t1 = %f\n", t1);
ProTKFprintf (demo_output," color = %d\n", color);
return PRO_TK_NO_ERROR;
}
/*===========================================================*\
Bound function for plotting a POLYLINE in the format "demo"
\*===========================================================*/
ProError user_demo_polyline (data, n_pts, array, color)
ProAppData data;
int n_pts;
double array[][3];
int color;
{
int p;
ProLine *app_name = (ProLine *)data;
ProTKFprintf (demo_output, "%ws: POLYLINE..\n", app_name);
for (p = 0; p < n_pts; p++)
ProTKFprintf (demo_output," Point %d = %f, %f\n", p,
array[p][0],
array[p][1]);
ProTKFprintf (demo_output," color = %d\n", color);
return PRO_TK_NO_ERROR;
}
/*===========================================================*\
Bound function for plotting a FILLED POLYGON in the
format "demo"
\*===========================================================*/
ProError user_demo_filled_poly (data, n_pts, array, color)
ProAppData data;
int n_pts;
double array[][3];
int color;
{
int p;
ProLine *app_name = (ProLine *)data;
ProTKFprintf (demo_output, "%ws: FILLED POLY..\n", app_name);
for (p = 0; p < n_pts; p++)
ProTKFprintf (demo_output," Point %d = %f, %f\n", p,
array[p][0],
array[p][1]);
ProTKFprintf (demo_output," color = %d\n", color);
return PRO_TK_NO_ERROR;
}